Skip to content

Commit 21b9ae8

Browse files
authored
Merge pull request #42 from Jersyfi/v2.x
V2.x
2 parents f5c199c + df90d43 commit 21b9ae8

34 files changed

+6402
-2902
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"extends": [
88
"eslint:recommended",
99
"plugin:react/recommended",
10-
"plugin:@typescript-eslint/recommended"
10+
"plugin:@typescript-eslint/recommended",
11+
"prettier"
1112
],
1213
"overrides": [
1314
],

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "none",
4+
"singleQuote": true,
5+
"useTabs": true
6+
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
All notable changes to `react-cookify` will be documented in this file.
44

5+
## v2.0.0-beta.1 - 2023-02-12
6+
7+
Skipped the work on the core function from v1 to v2 and included the build-in consent manager.
8+
9+
* Prepared for v2.0.0-beta.1 and seperated into different branches
10+
* Added uuid, created_at, updated_at & revision to `consentObject`
11+
* Modified the `CookifyConsent` components with UI changes to the detail layer
12+
* Added paused option to pause consent mananger on a specific page
13+
* Added floating button to open the consent manager
14+
* Added Prettier for code formatting
15+
* Added info and detail consent
16+
* Added button to open the consent
17+
* Added new settings for initialization
18+
* Splitted into core `CookifyProvider` and consent `CookifyConsent` to choose between logic and own front-end or build-in front-end
19+
520
## v1.0.0 - 2023-01-22
621

722
* Rolled back the consent modal and all necessary components for v2.0.0

README.md

Lines changed: 3 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# 🍪 react-cookify
22

3-
![NPM Downloads](https://img.shields.io/npm/dt/react-cookify)
4-
![GitHub package.json version](https://img.shields.io/github/package-json/v/jersyfi/react-cookify)
3+
![npm](https://img.shields.io/npm/dm/react-cookify)
54
![NPM](https://img.shields.io/npm/v/react-cookify)
65
![Github Code Size](https://img.shields.io/github/languages/code-size/jersyfi/react-cookify)
76
![npm bundle size](https://img.shields.io/bundlephobia/min/react-cookify)
@@ -16,207 +15,13 @@ How to handle GDPR correctly can be found on [Cookies, the GDPR, and the ePrivac
1615
View and test how Cookify works in either [Bootstrap](https://jersyfi.github.io/cookify/test/preview/bootstrap.html) or [Tailwind CSS](https://jersyfi.github.io/cookify/test/preview/tailwindcss.html).
1716

1817
## Documentation
19-
20-
### Get started
21-
22-
#### Installation
23-
Install `react-cookify` via npm.
18+
react-cookify is essentially a set of npm packages.
2419

2520
```bash
2621
npm install react-cookify
2722
```
2823

29-
#### Add Cookify to your App
30-
Start with adding the `CookifyProvider` to your App.
31-
32-
```javascript
33-
import '../styles/globals.css'
34-
import { CookifyProvider } from 'react-cookify'
35-
36-
export default function App({ Component, pageProps }) {
37-
return (
38-
<CookifyProvider options={{
39-
name: 'own-cookify-consent',
40-
types: {
41-
marketing: false,
42-
performance: false,
43-
},
44-
jscookie: {
45-
expires: 365,
46-
path: '/',
47-
secure: true,
48-
}
49-
}}>
50-
<Component {...pageProps} />
51-
</CookifyProvider>
52-
)
53-
}
54-
```
55-
56-
Now add the logic to your Home page.
57-
58-
```javascript
59-
import { useEffect, useState } from 'react'
60-
import { useCookifyProvider, CookifyInput } from 'react-cookify'
61-
62-
export default function Home() {
63-
const {consentObject, consentDisplayed, handleConsentDisplayedChange, consentTracking, actionAccept, actionNecessary, actionAll} = useCookifyProvider()
64-
const [displayedClass, setDisplayedClass] = useState('')
65-
66-
/* CSS not provided in example */
67-
const handleToggle = () => {
68-
if (consentDisplayed) {
69-
setDisplayedClass('block') // block => display: block
70-
} else {
71-
setDisplayedClass('hidden') // hidden => display: none
72-
}
73-
}
74-
75-
/* Display the consent management */
76-
useEffect(() => {
77-
handleToggle()
78-
}, [consentDisplayed])
79-
80-
/* Track the data if needed */
81-
useEffect(() => {
82-
if (consentTracking !== 0) { // Only track after initialization
83-
console.log('Track data here', consentObject)
84-
}
85-
}, [consentTracking])
86-
87-
return (
88-
<>
89-
<button onClick={() => handleConsentDisplayedChange(true)}>
90-
Open Modal
91-
</button>
92-
93-
<div className={displayedClass}>
94-
<div>
95-
<CookifyInput type="checkbox" name="necessary" id="necessary" disabled />
96-
<label htmlFor="necessary">Necessary</label>
97-
98-
<CookifyInput type="checkbox" name="marketing" id="marketing" />
99-
<label htmlFor="marketing">Marketing</label>
100-
101-
<CookifyInput type="checkbox" name="performance" id="performance" />
102-
<label htmlFor="performance">Performance</label>
103-
</div>
104-
105-
<div>
106-
<button onClick={actionAll}>All</button>
107-
<button onClick={actionAccept}>Accept</button>
108-
<button onClick={actionNecessary}>Necessary</button>
109-
</div>
110-
</div>
111-
</>
112-
)
113-
}
114-
```
115-
116-
#### Configure Cookify
117-
All configuration options with its default values.
118-
119-
```typescript
120-
name: 'cookify-consent',
121-
storage: 'cookies', // ['cookies' and 'storage']
122-
saveWithChange: false,
123-
saveByDefault: false,
124-
typeDefault: 'necessary',
125-
types: {
126-
// `necessary: true` will be set automatically
127-
// if `typeDefault` is empty, otherwise it will use the customized `typeDefault` instead of `necessary`
128-
},
129-
// js-cookie attributes
130-
// Only needed when using `storage: 'cookies'`
131-
// More information on https://github.com/js-cookie/js-cookie
132-
jscookie: {
133-
expires: 365,
134-
path: '/',
135-
}
136-
```
137-
138-
### Provider interaction
139-
140-
#### States
141-
142-
##### consentObject
143-
**Type:** consentObject: ConsentObjectType
144-
**Syntax:** consentObject
145-
```bash
146-
console.log(consentObject)
147-
148-
> Object: {
149-
viewed: false,
150-
data: {
151-
'necessary': true,
152-
'marketing': false,
153-
'performance': false,
154-
},
155-
}
156-
```
157-
158-
##### consentDisplayed
159-
**Type:** consentDisplayed: boolean
160-
**Syntax:** consentDisplayed
161-
```bash
162-
console.log(consentDisplayed)
163-
164-
> false
165-
```
166-
167-
##### handleConsentDisplayedChange
168-
**Type:** handleConsentDisplayedChange: (newConsentDisplayed: boolean) => void
169-
**Syntax:** handleConsentDisplayedChange(false)
170-
```javascript
171-
<button onClick={() => handleConsentDisplayedChange(true)}>
172-
Open Modal
173-
</button>
174-
```
175-
176-
##### consentTracking
177-
**Type:** consentTracking: number
178-
**Syntax:** consentTracking
179-
```bash
180-
console.log(consentTracking)
181-
182-
> 0
183-
```
184-
185-
#### Actions
186-
187-
##### actionCheckbox
188-
**Type:** actionCheckbox: (type: string) => void
189-
**Syntax:** actionCheckbox('type')
190-
```javascript
191-
<input
192-
type="checkbox"
193-
name="marketing"
194-
id="marketing"
195-
checked={consentObject.data['marketing']}
196-
onChange={() => actionCheckbox('marketing')}
197-
/>
198-
```
199-
200-
##### actionAccept
201-
**Type:** actionAccept: () => void
202-
**Syntax:** actionAccept
203-
```javascript
204-
<button onClick={actionAccept}>Accept</button>
205-
```
206-
207-
##### actionNecessary
208-
**Type:** actionNecessary: () => void
209-
**Syntax:** actionNecessary
210-
```javascript
211-
<button onClick={actionNecessary}>Necessary</button>
212-
```
213-
214-
##### actionAll
215-
**Type:** actionAll: () => void
216-
**Syntax:** actionAll
217-
```javascript
218-
<button onClick={actionAll}>All</button>
219-
```
24+
To view the complete documentation, please follow the link to [Cookify Docs](https://cookify.jersyfi.dev/).
22025

22126
## Framework Support & Features
22227
You can view all library languages and supported features [here](https://github.com/Jersyfi/cookify#framework-support--features).

0 commit comments

Comments
 (0)