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

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
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { useSearchkit } from '@searchkit/client';
3
+ import Button from '../../Button';
4
+
5
+ const SearchLoadMore = ({
6
+ data,
7
+ label,
8
+ className
9
+ }) => {
10
+ const api = useSearchkit();
11
+
12
+ if (!data) {
13
+ return null;
14
+ }
15
+
16
+ const setNextPage = () => {
17
+ if (data) {
18
+ api.setPage({
19
+ size: data.results.hits.page.size,
20
+ from: parseInt(data.results.hits.page.size) * (parseInt(data.results.hits.page.pageNumber) + 1)
21
+ });
22
+ api.search();
23
+ }
24
+ };
25
+
26
+ const currentPage = data.results.hits.page.pageNumber;
27
+ const lastPage = data.results.hits.page.totalPages;
28
+
29
+ if (currentPage + 1 >= lastPage) {
30
+ return null;
31
+ }
32
+
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ className: className
35
+ }, /*#__PURE__*/React.createElement(Button, {
36
+ onClick: setNextPage
37
+ }, label));
38
+ };
39
+
40
+ export default SearchLoadMore;
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import usePrevious from '../../../hooks/usePrevious';
2
3
 
3
4
  const SearchResultItemDefault = ({
4
5
  item
@@ -11,17 +12,35 @@ const SearchResultHeaderDefault = ({
11
12
  const SearchResults = ({
12
13
  data,
13
14
  renderItem,
14
- renderHeader
15
+ renderHeader,
16
+ appendResults = false
15
17
  }) => {
16
18
  const SearchResultItem = renderItem || SearchResultItemDefault;
17
19
  const SearchResultHeader = renderHeader || SearchResultHeaderDefault;
20
+ const [items, setItems] = useState([]);
21
+ const [currentPage, setCurrentPage] = useState(-1);
22
+ const previousPage = usePrevious(currentPage);
23
+ const previousItems = usePrevious(items);
24
+ useEffect(() => {
25
+ if (!appendResults) {
26
+ return;
27
+ }
28
+
29
+ if (data && previousPage !== undefined && data.results.hits.page.pageNumber !== previousPage) {
30
+ setItems([...previousItems, ...data.results.hits.items]);
31
+ setCurrentPage(data.results.hits.page.pageNumber);
32
+ }
33
+ }, [data, previousPage, previousItems, appendResults]);
34
+ const searchResultItems = appendResults ? data && items.map(item => /*#__PURE__*/React.createElement(SearchResultItem, {
35
+ item: item
36
+ })) : data && data.results.hits.items.map(item => /*#__PURE__*/React.createElement(SearchResultItem, {
37
+ item: item
38
+ }));
18
39
  return /*#__PURE__*/React.createElement("div", {
19
40
  className: "SearchResults"
20
41
  }, data && /*#__PURE__*/React.createElement(SearchResultHeader, {
21
42
  data: data
22
- }), data && data.results.hits.items.map(item => /*#__PURE__*/React.createElement(SearchResultItem, {
23
- item: item
24
- })));
43
+ }), searchResultItems);
25
44
  };
26
45
 
27
46
  export default SearchResults;
@@ -9,6 +9,7 @@ import SearchFacets from './SearchFacets';
9
9
  import SearchSelectedFilters from './SearchSelectedFilters';
10
10
  import SearchReset from './SearchReset';
11
11
  import SearchSorting from './SearchSorting';
12
+ import SearchLoadMore from './SearchLoadMore';
12
13
  export default {
13
14
  title: 'Molecules/SearchKit'
14
15
  };
@@ -215,4 +216,32 @@ export const Test = () => {
215
216
  }), /*#__PURE__*/React.createElement(SearchPagination, {
216
217
  data: data
217
218
  }))));
219
+ };
220
+ export const LoadMore = () => {
221
+ const api = useSearchkit();
222
+ return /*#__PURE__*/React.createElement(SearchKit, {
223
+ uri: "http://localhost:4000/api/graphql",
224
+ query: query // useRouting={false}
225
+ ,
226
+ pageSize: 5
227
+ }, (data, loading) => {
228
+ const toggleFilter = () => {
229
+ api.toggleFilter({
230
+ identifier: "type",
231
+ value: "22"
232
+ });
233
+ api.search();
234
+ };
235
+
236
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
237
+ onClick: toggleFilter
238
+ }, "Toggle"), /*#__PURE__*/React.createElement(SearchResults, {
239
+ data: data,
240
+ renderItem: SearchItem,
241
+ renderHeader: SearchHeader,
242
+ append: true
243
+ }), /*#__PURE__*/React.createElement(SearchLoadMore, {
244
+ data: data
245
+ }));
246
+ });
218
247
  };
@@ -7,10 +7,17 @@ import Button from '../Button';
7
7
 
8
8
  const WysiwygField = ({
9
9
  html,
10
+ customElementHandler,
10
11
  ...props
11
12
  }) => {
12
13
  const parsedHtml = ReactHtmlParser(html, {
13
14
  transform: node => {
15
+ const customHandler = customElementHandler(node);
16
+
17
+ if (customHandler) {
18
+ return customHandler;
19
+ }
20
+
14
21
  switch (node.name) {
15
22
  case 'a':
16
23
  {
@@ -42,7 +49,12 @@ const WysiwygField = ({
42
49
  }, props), parsedHtml);
43
50
  };
44
51
 
45
- PropTypes.propTypes = {
46
- html: PropTypes.string.isRequired
52
+ WysiwygField.propTypes = {
53
+ html: PropTypes.string.isRequired,
54
+ customElementHandler: PropTypes.func
55
+ };
56
+ WysiwygField.defaultProps = {
57
+ html: '',
58
+ customElementHandler: () => {}
47
59
  };
48
60
  export default WysiwygField;
@@ -6,4 +6,38 @@ export default {
6
6
  const html = "<p>This is <em>some</em> example <a href='https://www.uncinc.nl'>HTML</a>.</p>";
7
7
  export const Primary = () => /*#__PURE__*/React.createElement(WysiwygField, {
8
8
  html: html
9
+ });
10
+
11
+ const Abbr = ({
12
+ title,
13
+ children
14
+ }) => {
15
+ return /*#__PURE__*/React.createElement("abbr", {
16
+ title: title
17
+ }, children);
18
+ };
19
+
20
+ const htmlCustomHandler = `
21
+ <p>Lorem ipsum dolor sit amet, <abbr title="Ut ut tellus et augue feugiat sollicitudin sit amet viverra nisi.">consectetur adipiscing</abbr> elit. Aliquam in sodales tellus. Ut ut tellus et augue feugiat sollicitudin sit amet viverra nisi. Nulla malesuada erat non massa pellentesque, ut ultricies tellus sodales. Fusce ac feugiat ligula. In vel metus diam. Maecenas diam ex, tincidunt tempor nibh sed, suscipit semper lectus. Sed eu enim vel erat tempus mollis. Integer eget gravida orci. Nunc volutpat velit id dui semper tincidunt. Nulla maximus nisl nec volutpat faucibus. Integer vitae ullamcorper ex. Vestibulum facilisis convallis arcu, ac interdum libero malesuada eget.</p>
22
+ <p>Donec feugiat, nunc vitae euismod posuere, urna nisl elementum nibh, quis ultricies libero leo sed neque. Praesent vel vestibulum sem, eget congue purus. Nunc non volutpat urna, vitae ullamcorper justo. Suspendisse in tortor ex. Phasellus euismod eget neque vitae consequat. Vestibulum sem mi, dictum id consectetur at, hendrerit in massa. Mauris quis sem condimentum, condimentum enim sed, varius sem. Curabitur convallis tempus nulla, eget consectetur quam sagittis at. Nulla a feugiat tortor. Mauris fermentum lectus ac mauris cursus ornare.</p>
23
+ <p>Nam venenatis est eget lorem laoreet, id tempor urna hendrerit. Quisque suscipit in magna nec condimentum. Duis id tempor nisi. Sed rutrum urna elit, vitae placerat enim volutpat nec. Vivamus volutpat, magna sit amet commodo ultricies, enim turpis pretium libero, quis molestie nibh augue a ex. Nulla vestibulum vestibulum tellus, vel molestie libero vehicula nec. Sed maximus tortor vel ipsum cursus egestas. Proin suscipit tortor id luctus bibendum.</p>
24
+ `;
25
+ export const CustomHandlers = () => /*#__PURE__*/React.createElement(WysiwygField, {
26
+ html: htmlCustomHandler,
27
+ customElementHandler: element => {
28
+ switch (element.name) {
29
+ case 'abbr':
30
+ {
31
+ console.log(element);
32
+ return /*#__PURE__*/React.createElement(Abbr, {
33
+ title: element.attribs.title
34
+ }, element.children[0].data);
35
+ }
36
+
37
+ default:
38
+ {
39
+ return null;
40
+ }
41
+ }
42
+ }
9
43
  });
@@ -0,0 +1,3 @@
1
+ .WysiwygField {
2
+ margin-right: 200px;
3
+ }
@@ -0,0 +1,11 @@
1
+ import { useEffect, useState } from 'react';
2
+ export default function useOnScreen(ref) {
3
+ const [isIntersecting, setIntersecting] = useState(false);
4
+ const observer = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
5
+ useEffect(() => {
6
+ observer.observe(ref.current); // Remove the observer as soon as the component is unmounted
7
+
8
+ return () => observer.disconnect();
9
+ }, [observer, ref]);
10
+ return isIntersecting;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { useEffect, useRef } from 'react';
2
+ export default function usePrevious(value) {
3
+ // The ref object is a generic container whose current property is mutable ...
4
+ // ... and can hold any value, similar to an instance property on a class
5
+ const ref = useRef(); // Store current value in ref
6
+
7
+ useEffect(() => {
8
+ ref.current = value;
9
+ }, [value]); // Only re-run if value changes
10
+ // Return previous value (happens before update in useEffect above)
11
+
12
+ return ref.current;
13
+ }
14
+ ;
@@ -0,0 +1,17 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ const useScrollPosition = () => {
4
+ const [scrollPosition, setScrollPosition] = useState(0);
5
+ useEffect(() => {
6
+ const updatePosition = () => {
7
+ setScrollPosition(window.pageYOffset);
8
+ };
9
+
10
+ window.addEventListener('scroll', updatePosition);
11
+ updatePosition();
12
+ return () => window.removeEventListener('scroll', updatePosition);
13
+ }, []);
14
+ return scrollPosition;
15
+ };
16
+
17
+ export default useScrollPosition;
@@ -0,0 +1,25 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function getWindowDimensions() {
4
+ const {
5
+ innerWidth: width,
6
+ innerHeight: height
7
+ } = window;
8
+ return {
9
+ width,
10
+ height
11
+ };
12
+ }
13
+
14
+ export default function useWindowDimensions() {
15
+ const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
16
+ useEffect(() => {
17
+ function handleResize() {
18
+ setWindowDimensions(getWindowDimensions());
19
+ }
20
+
21
+ window.addEventListener('resize', handleResize);
22
+ return () => window.removeEventListener('resize', handleResize);
23
+ }, []);
24
+ return windowDimensions;
25
+ }
package/dist/index.js CHANGED
@@ -42,4 +42,10 @@ 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 SearchLoadMore } from './components/SearchKit/SearchLoadMore';
47
+ export { default as Cookie } from './components/Cookie';
48
+ export { default as useOnScreen } from './hooks/useOnScreen';
49
+ export { default as usePrevious } from './hooks/usePrevious';
50
+ export { default as useScrollPosition } from './hooks/useScrollPosition';
51
+ export { default as useWindowDimensions } from './hooks/useWindowDimensions';
@@ -17,8 +17,8 @@
17
17
  @each $breakpoint in map-keys($gutters) {
18
18
  @include media-breakpoint-up($breakpoint) {
19
19
  $gutter: map-get($gutters, $breakpoint);
20
- padding-left: ($gutter / 2);
21
- padding-right: ($gutter / 2);
20
+ padding-left: calc($gutter / 2);
21
+ padding-right: calc($gutter / 2);
22
22
  }
23
23
  }
24
24
  }
@@ -27,8 +27,8 @@
27
27
  @each $breakpoint in map-keys($gutters) {
28
28
  @include media-breakpoint-up($breakpoint) {
29
29
  $gutter: map-get($gutters, $breakpoint);
30
- padding-left: ($gutter / 2);
31
- padding-right: ($gutter / 2);
30
+ padding-left: calc($gutter / 2);
31
+ padding-right: calc($gutter / 2);
32
32
  }
33
33
  }
34
34
  }
@@ -41,13 +41,13 @@
41
41
  @include media-breakpoint-up($breakpoint) {
42
42
  $gutter: map-get($gutters, $breakpoint);
43
43
  @if $sides == all {
44
- margin: ($gutter / -2);
44
+ margin: calc($gutter / -2);
45
45
  } @else if $sides == left-right {
46
- margin-left: ($gutter / -2);
47
- margin-right: ($gutter / -2);
46
+ margin-left: calc($gutter / -2);
47
+ margin-right: calc($gutter / -2);
48
48
  } @else if $sides == top-bottom {
49
- margin-top: ($gutter / -2);
50
- margin-bottom: ($gutter / -2);
49
+ margin-top: calc($gutter / -2);
50
+ margin-bottom: calc($gutter / -2);
51
51
  }
52
52
  }
53
53
  }
@@ -62,8 +62,8 @@
62
62
  @each $breakpoint in map-keys($grid-gutter-widths) {
63
63
  @include media-breakpoint-up($breakpoint) {
64
64
  $gutter: map-get($grid-gutter-widths, $breakpoint);
65
- padding-left: ($gutter / 2);
66
- padding-right: ($gutter / 2);
65
+ padding-left: calc($gutter / 2);
66
+ padding-right: calc($gutter / 2);
67
67
  }
68
68
  }
69
69
  }
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.2",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",
@@ -46,11 +46,11 @@
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",
52
53
  "next-with-apollo": "^5.2.1",
53
- "node-sass": "^4.14.0",
54
54
  "ola": "^1.1.1",
55
55
  "path": "^0.12.7",
56
56
  "react": "^16.14.0",
@@ -70,7 +70,9 @@
70
70
  "react-select": "^3.1.0",
71
71
  "react-share": "^4.3.1",
72
72
  "react-slick": "^0.27.14",
73
+ "react-use-cookie": "^1.3.0",
73
74
  "redux": "^4.0.5",
75
+ "sass": "^1.49.9",
74
76
  "sass-loader": "^8.0.2",
75
77
  "slick-carousel": "^1.8.1"
76
78
  },