@uncinc/uncinc-react-kitchen-sink 2.1.14 → 2.2.0

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.
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import './style.scss';
3
+
4
+ const CheckboxAndRadio = ({
5
+ name,
6
+ id,
7
+ value,
8
+ label,
9
+ checked,
10
+ onChange,
11
+ disabled,
12
+ type
13
+ }) => {
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: "Checkbox"
16
+ }, /*#__PURE__*/React.createElement("input", {
17
+ type: type || "checkbox",
18
+ className: "Checkbox__input",
19
+ name: name,
20
+ id: id,
21
+ value: value,
22
+ checked: checked,
23
+ onChange: onChange,
24
+ disabled: disabled
25
+ }), /*#__PURE__*/React.createElement("label", {
26
+ htmlFor: id,
27
+ className: "icon-before icon-checkmark"
28
+ }, label));
29
+ };
30
+
31
+ export default CheckboxAndRadio;
@@ -0,0 +1,36 @@
1
+ @import 'assets/variables';
2
+ @import 'assets/mixins';
3
+
4
+ // Radio's and checkboxes
5
+ input[type='checkbox'],
6
+ input[type='radio'] {
7
+ position: absolute;
8
+ opacity: 0;
9
+
10
+ // Unchecked
11
+ ~ label:not(.no-styling) {
12
+ position: relative;
13
+ display: inline-block;
14
+ margin-bottom: 0;
15
+ font-weight: bold;
16
+ color: black;
17
+ user-select: none;
18
+ cursor: pointer;
19
+
20
+ display: flex;
21
+ align-items: center;
22
+
23
+ &:before {
24
+ margin-right: 1rem;
25
+ font-size: 1.8rem;
26
+ }
27
+ }
28
+
29
+ // Checked
30
+ &:checked ~ label:not(.no-styling) {
31
+ &:before {
32
+
33
+ background-position-y: -1em;
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,211 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import useCookie from 'react-use-cookie';
4
+ import Cookies from 'js-cookie';
5
+ import classNames from 'classnames';
6
+ import Button from '../Button';
7
+ import Container from '../Layout/Container';
8
+ import Checkbox from './Checkbox';
9
+ import './style.scss';
10
+
11
+ const CookieCompliancePopup = props => {
12
+ const {
13
+ className,
14
+ cookieLevels,
15
+ children,
16
+ manualText,
17
+ agreeText,
18
+ onDisagree,
19
+ cookieOptions,
20
+ cookieDomain
21
+ } = props; // This is an internal state to check whether we should show the options.
22
+
23
+ const [manualChoiceVisible, setManualChoiceVisible] = useState(false); // This is an extra hidden variable to internally check if we should show the notification.
24
+ // This also allows us to add an animation when the user accepts.
25
+
26
+ const [hiddenInternal, setHiddenInternal] = useState(false); // Cookie stating if the cookie has already been accepted. Uses the following states:
27
+ // 0: Declined (Not yet used).
28
+ // 1: Not yet agreed/disagreed (Not yet used).
29
+ // 2: Accepted.
30
+
31
+ const [didConsent, setDidConsent] = useCookie('cookie-agreed', null); // Cookie stating whether we should render the notification.
32
+
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: true,
38
+ statistieken: true,
39
+ marketing: true
40
+ });
41
+ useEffect(() => {
42
+ if (hidden) {
43
+ setHiddenInternal(true);
44
+ } // We don't want to add hidden to the dependency list, as this would -
45
+ // unrender the notification immediately on save.
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
+
48
+ }, []); // Check if didConsent has been changed.
49
+ // If so, set the hidden cookie for page reloads.
50
+
51
+ useEffect(() => {
52
+ if (didConsent !== null) {
53
+ setHidden(true);
54
+ }
55
+ }, [didConsent, cookieOptions, setHidden]); // This function expands the notification to show the options.
56
+
57
+ const displayConsentChoices = e => {
58
+ e.preventDefault();
59
+ setManualChoiceVisible(true);
60
+ }; // This function sets cookie-agreed to 2 ( accepted state ),
61
+ // and also sets the accepted categories in CookieAgreedCategories.
62
+
63
+
64
+ const onAgree = choices => {
65
+ const selectedChoices = Object.keys(choices).filter(key => {
66
+ return choices[key];
67
+ });
68
+ Object.keys(choices).forEach(key => {
69
+ if (choicesSelected[key]) {
70
+ window.dataLayer = window.dataLayer || [];
71
+ window.dataLayer.push({
72
+ event: `cookies-accepted-${key}`
73
+ });
74
+ }
75
+ });
76
+ setDidConsent('2', cookieOptions); // I used js-cookie for this insead of react-use-cookie because the encoding is not what we want
77
+ // for arrays in react-use-cookie. This shouldn't be an issue, as we don't want to keep track of
78
+ // CookieAgreedCategories, as we have that in state already.
79
+
80
+ Cookies.set('cookie-agreed-categories', JSON.stringify(selectedChoices), {
81
+ expires: 365,
82
+ domain: cookieDomain
83
+ }); // Set cookie for current domain, so it does not appear twice.
84
+
85
+ const timestamp = Math.round(new Date().getTime() / 1000);
86
+ const value = {
87
+ necessary: true,
88
+ preferences: true,
89
+ statistics: true,
90
+ marketing: true,
91
+ ver: 1,
92
+ utc: timestamp,
93
+ region: 'nl'
94
+ };
95
+ Cookies.set('cookie-consent', value, {
96
+ expires: 365,
97
+ domain: cookieDomain
98
+ });
99
+ }; // This function is fired when the accept button is pressed.
100
+ // Also has eventual support for a false case.
101
+
102
+
103
+ const onConsent = value => {
104
+ return () => {
105
+ if (value === true) {
106
+ onAgree(choicesSelected);
107
+ } else {
108
+ onDisagree();
109
+ }
110
+ };
111
+ }; // This function sets the value of the checkmark in the form state.
112
+
113
+
114
+ const handleChoiceState = event => {
115
+ const {
116
+ value,
117
+ checked
118
+ } = event.target;
119
+ setChoicesSelected({ ...choicesSelected,
120
+ [value]: checked
121
+ });
122
+ };
123
+
124
+ const classes = classNames('Cookie', className, {
125
+ 'Cookie--hidden': didConsent !== null
126
+ }); // If hiddenInternal is true, we do not render the notification.
127
+
128
+ if (hiddenInternal === true) {
129
+ return null;
130
+ } // This function renders the different options of checkboxes,
131
+ // allowing us to add more checkboxes eventually.
132
+
133
+
134
+ const renderChoices = () => {
135
+ return cookieLevels.map(choice => {
136
+ return /*#__PURE__*/React.createElement("div", {
137
+ className: "Cookie__category col-xs-12 col-lg-6",
138
+ key: choice.value
139
+ }, /*#__PURE__*/React.createElement("div", {
140
+ className: "Checkbox"
141
+ }, /*#__PURE__*/React.createElement(Checkbox, {
142
+ name: "cookie-categories",
143
+ type: "checkbox",
144
+ id: `cookie-category-${choice.value}`,
145
+ onChange: handleChoiceState,
146
+ label: choice.label,
147
+ value: choice.value,
148
+ checked: choicesSelected[choice.value],
149
+ disabled: choice.disabled
150
+ })), /*#__PURE__*/React.createElement("div", {
151
+ className: "Cookie__category__description"
152
+ }, choice.description));
153
+ });
154
+ };
155
+
156
+ return /*#__PURE__*/React.createElement("div", {
157
+ className: classes
158
+ }, /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement("div", {
159
+ className: `Cookie__content ${manualChoiceVisible ? 'Cookie__content--full-height' : ''}`
160
+ }, !manualChoiceVisible ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
161
+ className: "row"
162
+ }, /*#__PURE__*/React.createElement("div", {
163
+ className: "col-12 Cookie__content__message"
164
+ }, children), /*#__PURE__*/React.createElement("div", {
165
+ className: "col-12 Cookie__content__buttons"
166
+ }, /*#__PURE__*/React.createElement(Button, {
167
+ id: "complete-agree",
168
+ className: "Button--cta",
169
+ primary: true,
170
+ onClick: onConsent(true)
171
+ }, agreeText), /*#__PURE__*/React.createElement("a", {
172
+ className: "Cookie__content__buttons__manual-agree icon-after icon-chevron-right icon-variant-2",
173
+ onClick: e => {
174
+ displayConsentChoices(e);
175
+ }
176
+ }, manualText)))) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
177
+ className: "Cookie__content__message"
178
+ }, /*#__PURE__*/React.createElement("div", {
179
+ className: "Cookie__checkboxes-container row"
180
+ }, renderChoices())), /*#__PURE__*/React.createElement("div", {
181
+ className: "Cookie__content__buttons"
182
+ }, /*#__PURE__*/React.createElement(Button, {
183
+ className: "Button--cta",
184
+ onClick: onConsent(true)
185
+ }, agreeText))))));
186
+ };
187
+
188
+ export default CookieCompliancePopup;
189
+ CookieCompliancePopup.defaultProps = {
190
+ agreeText: 'Accepteren',
191
+ manualText: 'Zelf instellen',
192
+ onDisagree: () => {},
193
+ cookieLevels: [],
194
+ cookieDomain: null,
195
+ cookieOptions: {
196
+ days: 365,
197
+ path: '/'
198
+ }
199
+ };
200
+ CookieCompliancePopup.propTypes = {
201
+ agreeText: PropTypes.string,
202
+ manualText: PropTypes.string,
203
+ onDisagree: PropTypes.func,
204
+ // eslint-disable-next-line react/forbid-prop-types
205
+ cookieLevels: PropTypes.arrayOf(PropTypes.shape({
206
+ value: PropTypes.string,
207
+ label: PropTypes.string,
208
+ description: PropTypes.string,
209
+ disabled: PropTypes.bool
210
+ }))
211
+ };
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import Cookie from './';
3
+ import './stories.scss';
4
+ export default {
5
+ title: 'Organisms/Cookie'
6
+ };
7
+ export const Default = () => /*#__PURE__*/React.createElement(Cookie, {
8
+ agreeText: 'Accepteren',
9
+ manualText: 'Zelf instellen',
10
+ onDisagree: () => {},
11
+ cookieLevels: [{
12
+ value: "necessary",
13
+ label: "Noodzakelijk",
14
+ description: "Noodzakelijke cookies helpen een website bruikbaarder te maken, door basisfuncties als paginanavigatie en toegang tot beveiligde gedeelten van de website mogelijk te maken. Zonder deze cookies kan de website niet naar behoren werken.",
15
+ disabled: true
16
+ }, {
17
+ value: "voorkeuren",
18
+ label: "Voorkeuren",
19
+ description: "Voorkeurscookies zorgen ervoor dat een website informatie kan onthouden die van invloed is op het gedrag en de vormgeving van de website, zoals de taal van uw voorkeur of de regio waar u woont.",
20
+ disabled: false
21
+ }, {
22
+ value: "statistieken",
23
+ label: "Statistieken",
24
+ description: "Statistische cookies helpen eigenaren van websites begrijpen hoe bezoekers hun website gebruiken, door anoniem gegevens te verzamelen en te rapporteren.",
25
+ 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
+ }]
32
+ }, /*#__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."));
@@ -0,0 +1,71 @@
1
+ @import 'assets/variables';
2
+ @import 'assets/mixins';
3
+
4
+
5
+ @keyframes fade-out-and-transform {
6
+ 0% {
7
+ transform: translateX(-50%) translateY(0px);
8
+ }
9
+
10
+ 25% {
11
+ opacity: 1;
12
+ }
13
+
14
+ 75% {
15
+ opacity: 0;
16
+ }
17
+
18
+ 100% {
19
+ transform: translateX(-50%) translateY(110%);
20
+ opacity: 0;
21
+ }
22
+ }
23
+
24
+ .Cookie {
25
+ bottom: 1rem;
26
+
27
+ @media #{$tablet} {
28
+ bottom: 3rem;
29
+ }
30
+
31
+ &--hidden {
32
+ animation-name: fade-out-and-transform;
33
+ animation-duration: .6s;
34
+ animation-timing-function: cubic-bezier(0.32, 0, 0.67, 0);
35
+ animation-fill-mode: forwards;
36
+ }
37
+
38
+ &__content {
39
+ background: #F4F4F4;
40
+ padding: 2rem;
41
+ border-radius: 10px;
42
+ margin-bottom: 10px;
43
+ width: 100%;
44
+ box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2);
45
+
46
+ @media #{$tablet-down} {
47
+ width: auto;
48
+ }
49
+
50
+ @media #{$tablet} {
51
+ padding: 4rem;
52
+ }
53
+
54
+ &__full-height {
55
+ overflow-y: scroll;
56
+
57
+ @media #{$mobile-down} {
58
+ position: fixed;
59
+ top: 2rem;
60
+ bottom: 2rem;
61
+ right: 2rem;
62
+ left: 2rem;
63
+ }
64
+
65
+ @media #{$normal} {
66
+ height: auto;
67
+ overflow-y: unset;
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,55 @@
1
+ @import 'assets/variables';
2
+ @import 'assets/mixins';
3
+
4
+ .Cookie {
5
+ width: 100%;
6
+ position: fixed;
7
+ left: 50%;
8
+ max-height: 100%;
9
+ bottom: 0;
10
+ transform: translateX(-50%);
11
+ z-index: 10000;
12
+
13
+ &--hidden {
14
+ &__content__full-height {
15
+ position: inherit;
16
+ top: inherit;
17
+ bottom: inherit;
18
+ right: inherit;
19
+ left: inherit;
20
+ }
21
+ }
22
+
23
+ &__content {
24
+ max-height: 100vh;
25
+ overflow-y: auto;
26
+
27
+ &__full-height {
28
+ overflow-y: scroll;
29
+
30
+ @media #{$normal} {
31
+ height: auto;
32
+ overflow-y: unset;
33
+ }
34
+ }
35
+
36
+ &__buttons {
37
+ display: flex;
38
+ align-items: center;
39
+ flex-direction: column;
40
+
41
+ @media #{$tablet} {
42
+ flex-direction: row;
43
+ }
44
+
45
+ .Button {
46
+ margin-right: 1rem;
47
+ }
48
+ }
49
+ }
50
+
51
+ &__category {
52
+ display: inline-block;
53
+ margin-bottom: 2rem;
54
+ }
55
+ }
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import Lottie from './';
3
3
  import LottieAnimationWithMousePosition from './LottieAnimationWithMousePosition';
4
4
  import exampleLottie from '../../assets/lottie/example.json';
@@ -10,7 +10,8 @@ export default {
10
10
  export const DefaultAnimation = () => /*#__PURE__*/React.createElement(Lottie, {
11
11
  id: "example",
12
12
  data: exampleLottie,
13
- onInit: lottie => console.log(lottie)
13
+ onInit: lottie => console.log(lottie),
14
+ autoPlay: false
14
15
  }); // Animation active on hover
15
16
 
16
17
  export const activateOnHoverAnimation = () => /*#__PURE__*/React.createElement(Lottie, {
@@ -33,4 +34,28 @@ export const pauseOnClickAnimation = () => /*#__PURE__*/React.createElement(Lott
33
34
 
34
35
  export const PathLoad = () => /*#__PURE__*/React.createElement(Lottie, {
35
36
  path: "https://maxst.icons8.com/vue-static/landings/animated-icons/icons/checkmark-ok/checkmark-ok.json"
36
- });
37
+ });
38
+ export const Custom = () => {
39
+ const l = useRef();
40
+ const direction = useRef(true);
41
+ return /*#__PURE__*/React.createElement("div", {
42
+ className: "fooo",
43
+ onClick: () => {
44
+ console.log('click');
45
+
46
+ if (direction.current) {
47
+ direction.current = false;
48
+ l.current.playSegments([0, 5], true);
49
+ } else {
50
+ direction.current = true;
51
+ l.current.playSegments([5, 0], true);
52
+ }
53
+ }
54
+ }, /*#__PURE__*/React.createElement(Lottie, {
55
+ id: "example",
56
+ data: exampleLottie,
57
+ onInit: lottie => l.current = lottie,
58
+ autoPlay: false,
59
+ loop: false
60
+ }));
61
+ };
@@ -188,12 +188,15 @@ export const Test = () => {
188
188
  uri: "http://localhost:4000/api/graphql",
189
189
  query: query,
190
190
  useRouting: false,
191
- filters: [{
191
+ defaultFilters: [{
192
192
  identifier: 'type',
193
193
  value: 'article'
194
194
  }],
195
- searchQuery: q
196
- }, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchResults, {
195
+ defaultQuery: q
196
+ }, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchFacets, {
197
+ data: data,
198
+ loading: loading
199
+ }), /*#__PURE__*/React.createElement(SearchResults, {
197
200
  data: data,
198
201
  renderItem: SearchItem,
199
202
  renderHeader: SearchHeader
@@ -203,12 +206,16 @@ export const Test = () => {
203
206
  uri: "http://localhost:4000/api/graphql",
204
207
  query: query,
205
208
  useRouting: false,
206
- filters: [{
209
+ pageSize: 5,
210
+ defaultFilters: [{
207
211
  identifier: 'type',
208
212
  value: 'landing_page'
209
213
  }],
210
- searchQuery: q
211
- }, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchResults, {
214
+ defaultQuery: q
215
+ }, (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchFacets, {
216
+ data: data,
217
+ loading: loading
218
+ }), /*#__PURE__*/React.createElement(SearchResults, {
212
219
  data: data,
213
220
  renderItem: SearchItem,
214
221
  renderHeader: SearchHeader
package/dist/index.js CHANGED
@@ -42,4 +42,5 @@ export { default as SearchSelectedFilters } from './components/SearchKit/SearchS
42
42
  export { default as SearchSorting } from './components/SearchKit/SearchSorting';
43
43
  export { default as SearchReset } from './components/SearchKit/SearchReset';
44
44
  export { default as SearchResults } from './components/SearchKit/SearchResults';
45
- export { default as SearchPagination } from './components/SearchKit/SearchPagination';
45
+ export { default as SearchPagination } from './components/SearchKit/SearchPagination';
46
+ export { default as Cookie } from './components/Cookie';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.1.14",
3
+ "version": "2.2.0",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",
@@ -46,6 +46,7 @@
46
46
  "formik": "^2.2.6",
47
47
  "graphql": "^15.7.0",
48
48
  "immutable": "^4.0.0-rc.15",
49
+ "js-cookie": "^3.0.1",
49
50
  "lottie-web": "^5.7.7",
50
51
  "mini-css-extract-plugin": "^1.4.1",
51
52
  "moment": "^2.29.1",
@@ -70,6 +71,7 @@
70
71
  "react-select": "^3.1.0",
71
72
  "react-share": "^4.3.1",
72
73
  "react-slick": "^0.27.14",
74
+ "react-use-cookie": "^1.3.0",
73
75
  "redux": "^4.0.5",
74
76
  "sass-loader": "^8.0.2",
75
77
  "slick-carousel": "^1.8.1"