@uncinc/uncinc-react-kitchen-sink 2.2.13 → 2.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,10 +30,11 @@ const AccordionItem = ({
30
30
  iconClassName,
31
31
  duration,
32
32
  easing,
33
- titleComponent
33
+ titleComponent,
34
+ className
34
35
  }) => {
35
36
  const [collapsed, setCollapsed] = useState(true);
36
- const classes = c('Accordion__item', {
37
+ const classes = c(className, 'Accordion__item', {
37
38
  collapsed: collapsed
38
39
  });
39
40
  const iconClasses = c('icon', iconClassName);
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import Button from './';
3
+ import './stories.scss';
3
4
  export default {
4
5
  title: 'Atoms/Button'
5
6
  };
@@ -1,45 +1,43 @@
1
1
  @import '../../styles/assets/variables';
2
2
 
3
3
  .Button {
4
- &.Button--styled {
5
- display: inline-block;
6
- border-radius: 5px;
7
- text-decoration: none;
8
- text-align: center;
9
- cursor: pointer;
4
+ display: inline-block;
5
+ border-radius: 5px;
6
+ text-decoration: none;
7
+ text-align: center;
8
+ cursor: pointer;
10
9
 
11
- &--primary {
12
- font-size: 21px;
13
- background-color: black;
14
- color: #ffffff;
15
- font-weight: 600;
16
- line-height: 1.14;
17
- padding: 19px 30px;
10
+ &--primary {
11
+ font-size: 21px;
12
+ background-color: black;
13
+ color: #ffffff;
14
+ font-weight: 600;
15
+ line-height: 1.14;
16
+ padding: 19px 30px;
18
17
 
19
- &:hover {
20
- background-color: #434343;
21
- }
22
- &:disabled {
23
- font-family: inherit;
24
- background-color: rgba(0, 0, 0, 0.3);
25
- }
18
+ &:hover {
19
+ background-color: #434343;
26
20
  }
21
+ &:disabled {
22
+ font-family: inherit;
23
+ background-color: rgba(0, 0, 0, 0.3);
24
+ }
25
+ }
27
26
 
28
- &--inverted {
29
- border: solid 1px #888888;
30
- background-color: #ffffff;
31
- padding: 18px 34.5px;
32
- font-size: 18px;
33
- font-weight: 600;
34
- color: #000000;
27
+ &--inverted {
28
+ border: solid 1px #888888;
29
+ background-color: #ffffff;
30
+ padding: 18px 34.5px;
31
+ font-size: 18px;
32
+ font-weight: 600;
33
+ color: #000000;
35
34
 
36
- &:hover {
37
- background-color: #f1f1f1;
38
- }
39
- &:disabled {
40
- font-family: inherit;
41
- opacity: .5;
42
- }
35
+ &:hover {
36
+ background-color: #f1f1f1;
37
+ }
38
+ &:disabled {
39
+ font-family: inherit;
40
+ opacity: .5;
43
41
  }
44
42
  }
45
43
  }
@@ -2,42 +2,7 @@
2
2
 
3
3
  .Button {
4
4
  display: inline-block;
5
- border-radius: 5px;
6
5
  text-decoration: none;
7
6
  text-align: center;
8
7
  cursor: pointer;
9
-
10
- &--primary {
11
- font-size: 21px;
12
- background-color: black;
13
- color: #ffffff;
14
- font-weight: 600;
15
- line-height: 1.14;
16
- padding: 19px 30px;
17
-
18
- &:hover {
19
- background-color: #434343;
20
- }
21
- &:disabled {
22
- font-family: inherit;
23
- background-color: rgba(0, 0, 0, 0.3);
24
- }
25
- }
26
-
27
- &--inverted {
28
- border: solid 1px #888888;
29
- background-color: #ffffff;
30
- padding: 18px 34.5px;
31
- font-size: 18px;
32
- font-weight: 600;
33
- color: #000000;
34
-
35
- &:hover {
36
- background-color: #f1f1f1;
37
- }
38
- &:disabled {
39
- font-family: inherit;
40
- opacity: .5;
41
- }
42
- }
43
8
  }
@@ -11,13 +11,19 @@ import './style.scss';
11
11
  const CookieCompliancePopup = props => {
12
12
  const {
13
13
  className,
14
- cookieLevels,
15
14
  children,
16
15
  manualText,
17
16
  agreeText,
17
+ disagreeText,
18
+ showDisagree,
19
+ onAgree,
18
20
  onDisagree,
21
+ cookieLevels,
19
22
  cookieOptions,
20
- cookieDomain
23
+ cookieDomain,
24
+ defaultValues,
25
+ manualHeader,
26
+ manualButtonClassname
21
27
  } = props; // This is an internal state to check whether we should show the options.
22
28
 
23
29
  const [manualChoiceVisible, setManualChoiceVisible] = useState(false); // This is an extra hidden variable to internally check if we should show the notification.
@@ -30,14 +36,16 @@ const CookieCompliancePopup = props => {
30
36
 
31
37
  const [didConsent, setDidConsent] = useCookie('cookie-agreed', null); // Cookie stating whether we should render the notification.
32
38
 
33
- const [hidden, setHidden] = useState(didConsent !== null); // Default choices for select, this way we can locally manage the state of the form.
34
-
35
- const [choicesSelected, setChoicesSelected] = useState({
36
- necessary: true,
37
- voorkeuren: false,
38
- statistieken: false,
39
- marketing: false
39
+ const [hidden, setHidden] = useState(didConsent !== null);
40
+ const categories = cookieLevels.map(item => {
41
+ return item.value;
40
42
  });
43
+ const defaultState = categories.reduce((prev, category) => {
44
+ prev[category] = typeof defaultValues[category] !== undefined ? defaultValues[category] : true;
45
+ return prev;
46
+ }, {}); // Default choices for select, this way we can locally manage the state of the form.
47
+
48
+ const [choicesSelected, setChoicesSelected] = useState(defaultState);
41
49
  useEffect(() => {
42
50
  if (hidden) {
43
51
  setHiddenInternal(true);
@@ -61,7 +69,7 @@ const CookieCompliancePopup = props => {
61
69
  // and also sets the accepted categories in CookieAgreedCategories.
62
70
 
63
71
 
64
- const onAgree = choices => {
72
+ const _onAgree = choices => {
65
73
  const selectedChoices = Object.keys(choices).filter(key => {
66
74
  return choices[key];
67
75
  });
@@ -84,18 +92,37 @@ const CookieCompliancePopup = props => {
84
92
 
85
93
  const timestamp = Math.round(new Date().getTime() / 1000);
86
94
  const value = {
87
- necessary: true,
88
- preferences: true,
89
- statistics: true,
90
- marketing: true,
91
95
  ver: 1,
92
96
  utc: timestamp,
93
97
  region: 'nl'
94
98
  };
95
- Cookies.set('cookie-consent', value, {
99
+ categories.forEach(category => {
100
+ value[category] = true;
101
+ }, {});
102
+ Cookies.set('cookie-consent', JSON.stringify(value), {
96
103
  expires: 365,
97
104
  domain: cookieDomain
98
105
  });
106
+ onAgree(choices);
107
+ };
108
+
109
+ const _onDisagree = () => {
110
+ setDidConsent('0', cookieOptions);
111
+ Cookies.set('cookie-agreed-categories', JSON.stringify([]), {
112
+ expires: 365,
113
+ domain: cookieDomain
114
+ });
115
+ const timestamp = Math.round(new Date().getTime() / 1000);
116
+ const value = {
117
+ ver: 1,
118
+ utc: timestamp,
119
+ region: 'nl'
120
+ };
121
+ Cookies.set('cookie-consent', JSON.stringify(value), {
122
+ expires: 365,
123
+ domain: cookieDomain
124
+ });
125
+ onDisagree();
99
126
  }; // This function is fired when the accept button is pressed.
100
127
  // Also has eventual support for a false case.
101
128
 
@@ -103,9 +130,9 @@ const CookieCompliancePopup = props => {
103
130
  const onConsent = value => {
104
131
  return () => {
105
132
  if (value === true) {
106
- onAgree(choicesSelected);
133
+ _onAgree(choicesSelected);
107
134
  } else {
108
- onDisagree();
135
+ _onDisagree();
109
136
  }
110
137
  };
111
138
  }; // This function sets the value of the checkmark in the form state.
@@ -168,8 +195,11 @@ const CookieCompliancePopup = props => {
168
195
  className: "Button--cta",
169
196
  primary: true,
170
197
  onClick: onConsent(true)
171
- }, agreeText), /*#__PURE__*/React.createElement("a", {
172
- className: "Cookie__content__buttons__manual-agree icon-after icon-chevron-right icon-variant-2",
198
+ }, agreeText), showDisagree && /*#__PURE__*/React.createElement("button", {
199
+ className: `Cookie__content__buttons__manual Cookie__content__buttons__manual-disagree ${manualButtonClassname}`,
200
+ onClick: onConsent(false)
201
+ }, disagreeText), /*#__PURE__*/React.createElement("button", {
202
+ className: `Cookie__content__buttons__manual Cookie__content__buttons__manual-agree ${manualButtonClassname}`,
173
203
  onClick: e => {
174
204
  displayConsentChoices(e);
175
205
  }
@@ -177,7 +207,9 @@ const CookieCompliancePopup = props => {
177
207
  className: "Cookie__content__message"
178
208
  }, /*#__PURE__*/React.createElement("div", {
179
209
  className: "Cookie__checkboxes-container row"
180
- }, renderChoices())), /*#__PURE__*/React.createElement("div", {
210
+ }, /*#__PURE__*/React.createElement("div", {
211
+ className: "col-12"
212
+ }, manualHeader), renderChoices())), /*#__PURE__*/React.createElement("div", {
181
213
  className: "Cookie__content__buttons"
182
214
  }, /*#__PURE__*/React.createElement(Button, {
183
215
  className: "Button--cta",
@@ -188,9 +220,40 @@ const CookieCompliancePopup = props => {
188
220
  export default CookieCompliancePopup;
189
221
  CookieCompliancePopup.defaultProps = {
190
222
  agreeText: 'Accepteren',
223
+ disagreeText: 'Alles weigeren',
191
224
  manualText: 'Zelf instellen',
225
+ manualHeader: () => {},
226
+ onAgree: () => {},
192
227
  onDisagree: () => {},
193
- cookieLevels: [],
228
+ showDisagree: false,
229
+ manualButtonClassname: "icon-after icon-chevron-right icon-variant-2",
230
+ cookieLevels: [{
231
+ value: "necessary",
232
+ label: 'Benodigd',
233
+ description: "",
234
+ disabled: true
235
+ }, {
236
+ value: "voorkeuren",
237
+ label: "Voorkeuren",
238
+ description: "",
239
+ disabled: false
240
+ }, {
241
+ value: "statistieken",
242
+ label: "Statistieken",
243
+ description: "",
244
+ disabled: false
245
+ }, {
246
+ value: "marketing",
247
+ label: "Marketing",
248
+ description: "",
249
+ disabled: false
250
+ }],
251
+ defaultValues: {
252
+ necessary: true,
253
+ voorkeuren: false,
254
+ statistieken: false,
255
+ marketing: false
256
+ },
194
257
  cookieDomain: null,
195
258
  cookieOptions: {
196
259
  days: 365,
@@ -200,8 +263,11 @@ CookieCompliancePopup.defaultProps = {
200
263
  CookieCompliancePopup.propTypes = {
201
264
  agreeText: PropTypes.string,
202
265
  manualText: PropTypes.string,
266
+ manualHeader: PropTypes.func,
267
+ manualButtonClassname: PropTypes.string,
268
+ onAgree: PropTypes.func,
203
269
  onDisagree: PropTypes.func,
204
- // eslint-disable-next-line react/forbid-prop-types
270
+ showDisagree: PropTypes.bool,
205
271
  cookieLevels: PropTypes.arrayOf(PropTypes.shape({
206
272
  value: PropTypes.string,
207
273
  label: PropTypes.string,
@@ -7,7 +7,15 @@ export default {
7
7
  export const Default = () => /*#__PURE__*/React.createElement(Cookie, {
8
8
  agreeText: 'Accepteren',
9
9
  manualText: 'Zelf instellen',
10
+ onAgree: choices => console.log("User agreed to", choices),
11
+ onDisagree: () => console.log("User did NOT agree")
12
+ }, /*#__PURE__*/React.createElement("h1", null, "Wij gebruiken cookies"), /*#__PURE__*/React.createElement("p", null, "Aliquam accumsan sem lacus, ut laoreet urna aliquam quis. Ut ut imperdiet tortor, sed vestibulum felis. Etiam a eleifend leo, eu interdum nulla. Etiam id elit ex. Etiam condimentum facilisis venenatis. Curabitur accumsan ut dui vel laoreet. Donec dapibus convallis diam, at sodales nulla laoreet ac. Nunc maximus, orci ac tristique dapibus, dolor felis semper lorem, eu dapibus turpis enim quis urna."));
13
+ export const Advanced = () => /*#__PURE__*/React.createElement(Cookie, {
14
+ agreeText: 'Accepteren',
15
+ manualText: 'Zelf instellen',
16
+ showDisagree: true,
10
17
  onDisagree: () => {},
18
+ manualButtonClassname: "",
11
19
  cookieLevels: [{
12
20
  value: "necessary",
13
21
  label: "Noodzakelijk",
@@ -23,10 +31,11 @@ export const Default = () => /*#__PURE__*/React.createElement(Cookie, {
23
31
  label: "Statistieken",
24
32
  description: "Statistische cookies helpen eigenaren van websites begrijpen hoe bezoekers hun website gebruiken, door anoniem gegevens te verzamelen en te rapporteren.",
25
33
  disabled: false
26
- }, {
27
- value: "marketing",
28
- label: "Marketing",
29
- description: "Marketingcookies worden gebruikt om bezoekers te volgen wanneer ze verschillende websites bezoeken. Hun doel is advertenties weergeven die zijn toegesneden op en relevant zijn voor de individuele gebruiker. Deze advertenties worden zo waardevoller voor uitgevers en externe adverteerders.",
30
- disabled: false
31
- }]
34
+ }],
35
+ defaultValues: {
36
+ necessary: true,
37
+ voorkeuren: true,
38
+ statistieken: true
39
+ },
40
+ manualHeader: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "Manual choice"), /*#__PURE__*/React.createElement("p", null, "You have a choice."))
32
41
  }, /*#__PURE__*/React.createElement("h1", null, "Wij gebruiken cookies"), /*#__PURE__*/React.createElement("p", null, "Aliquam accumsan sem lacus, ut laoreet urna aliquam quis. Ut ut imperdiet tortor, sed vestibulum felis. Etiam a eleifend leo, eu interdum nulla. Etiam id elit ex. Etiam condimentum facilisis venenatis. Curabitur accumsan ut dui vel laoreet. Donec dapibus convallis diam, at sodales nulla laoreet ac. Nunc maximus, orci ac tristique dapibus, dolor felis semper lorem, eu dapibus turpis enim quis urna."));
@@ -45,6 +45,15 @@
45
45
  .Button {
46
46
  margin-right: 1rem;
47
47
  }
48
+
49
+ .Cookie__content__buttons__manual {
50
+ border: none;
51
+ background: none;
52
+ font-size: inherit;
53
+ font-family: inherit;
54
+ padding: 0;
55
+ margin-right: 1rem;
56
+ }
48
57
  }
49
58
  }
50
59
 
@@ -0,0 +1,25 @@
1
+ import { ApolloServer, gql } from 'apollo-server-micro';
2
+ export const config = {
3
+ api: {
4
+ bodyParser: false
5
+ }
6
+ };
7
+ const typeDefs = [gql`
8
+ type Query {
9
+ root: String
10
+ }
11
+
12
+ type Mutation {
13
+ root: String
14
+ }
15
+ `];
16
+ const server = new ApolloServer({
17
+ typeDefs,
18
+ resolvers: {},
19
+ introspection: true,
20
+ playground: true,
21
+ context: {}
22
+ });
23
+ export default server.createHandler({
24
+ path: '/api/graphql'
25
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.2.13",
3
+ "version": "2.2.16",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",
@@ -1,3 +0,0 @@
1
- .WysiwygField {
2
- margin-right: 200px;
3
- }
@@ -1,5 +0,0 @@
1
- const makeSafeForCSS = value => {
2
- return encodeURIComponent(value).replace(/\.|%[0-9a-z]{2}/gi, '');
3
- };
4
-
5
- export default makeSafeForCSS;