gatsby-core-theme 18.0.9 → 18.0.11

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ ## [18.0.11](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v18.0.10...v18.0.11) (2023-02-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * cta replace ([f66776c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f66776c673fb08e468e050825f6ce2663de6aa55))
7
+ * cta storybook ([5af20c4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5af20c4c48fc03c7d8e05437482747065c4893b2))
8
+ * operator button ([5ced63a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5ced63a4c89bff7b5ecd10eaf83297e2eb0f4d92))
9
+ * operator cta ([c1024f8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c1024f8fba1153abfaeba8d8fcd7d07ce8832a24))
10
+ * operator cta ([5701788](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5701788ab8b644920d848d7000e40dd1d6b0503d))
11
+ * operator cta ([ebaa006](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ebaa006e4a2a055b70cee10f0a5a4e8f17e8225d))
12
+ * operator cta two ([551e42c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/551e42ca4ad2bf1fff06d94c8f4ea3e20babc667))
13
+ * storybook ([4931cd3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4931cd3d291c4cd0254b8cd50308dd14aadd5284))
14
+ * style and test ([62bc6a6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/62bc6a6cac74dfc14121d8441490bdc49e2d00aa))
15
+ * typo ([976e665](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/976e6654cbdde92d0d6912d1860c619bc9e80cf2))
16
+
17
+
18
+ ### Code Refactoring
19
+
20
+ * move sticky on scroll handler in use effect ([21c91c5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/21c91c5bb2e59dc674ff2a7647c45e671b65eba5))
21
+
22
+
23
+ * Merge branch 'tm-3294-operator-cta' into 'master' ([daa438d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/daa438da27ac641ee5ac7f021e82c08c28b2ccc5))
24
+
25
+ ## [18.0.10](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v18.0.9...v18.0.10) (2023-02-07)
26
+
27
+
28
+ ### Code Refactoring
29
+
30
+ * update general scroll hook ([8527035](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/852703570a5cae67fde1bb24fc7dd76906000580))
31
+ * update general scroll hook debounceTime ([18fe029](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/18fe029b590e434642611ea5e5392f7ef42daaaa))
32
+
33
+
34
+ * Merge branch 'tm-3097-update-general-scroll-hook' into 'master' ([fd1ad08](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fd1ad0860b9543667caeda6963b3f33f8085e296))
35
+
1
36
  ## [18.0.9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v18.0.8...v18.0.9) (2023-02-06)
2
37
 
3
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "18.0.9",
3
+ "version": "18.0.11",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -0,0 +1,70 @@
1
+ import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Context } from '~context/MainProvider';
4
+ import { prettyTracker, translate } from '~helpers/getters';
5
+
6
+ import styles from './operator-cta-two.module.scss';
7
+
8
+ const OperatorCtaTwo = ({
9
+ operator,
10
+ pageTemplate,
11
+ gtmClass = '',
12
+ buttonType = 'primary',
13
+ buttonSize = 'm',
14
+ tracker = 'main',
15
+ icon = null,
16
+ translationsObj = {
17
+ active: 'Visit',
18
+ not_recommended: 'Not Recommended',
19
+ coming_soon: 'Soon Available',
20
+ inactive: 'Not Accepting New Players',
21
+ blacklisted: 'Blacklisted',
22
+ },
23
+ }) => {
24
+ const { translations } = useContext(Context) || {};
25
+ const status = operator?.status || '';
26
+ const trackerType = tracker?.toLowerCase()?.replace(' ', '_');
27
+ const prettyLink = prettyTracker(operator, trackerType, false, pageTemplate);
28
+ const textkey = `${status}_cta`;
29
+
30
+ const translateBtn = translate(translations, textkey, translationsObj[status] || '');
31
+
32
+ const classes = `${styles[buttonType]} ${styles[`${buttonSize}_size`]} ${styles[status]}`;
33
+
34
+ const inactive = ['coming_soon', 'inactive'].includes(status);
35
+
36
+ return (
37
+ <a
38
+ {...(!inactive ? { href: prettyLink } : {})}
39
+ title={typeof translateBtn === 'string' ? translateBtn : ''}
40
+ aria-label={typeof translateBtn === 'string' ? translateBtn : ''}
41
+ className={`${classes} ${gtmClass}`}
42
+ {...(!inactive ? { target: '_blank' } : {})}
43
+ {...(!inactive ? { rel: 'nofollow noreferrer' } : {})}
44
+ >
45
+ {translateBtn}
46
+ {icon && icon}
47
+ </a>
48
+ );
49
+ };
50
+
51
+ OperatorCtaTwo.propTypes = {
52
+ operator: PropTypes.shape({
53
+ name: PropTypes.string,
54
+ status: PropTypes.string,
55
+ }),
56
+ gtmClass: PropTypes.string,
57
+ pageTemplate: PropTypes.string,
58
+ buttonSize: PropTypes.string,
59
+ buttonType: PropTypes.string,
60
+ tracker: PropTypes.string,
61
+ translationsObj: PropTypes.shape({
62
+ active: PropTypes.string,
63
+ not_recommended: PropTypes.string,
64
+ coming_soon: PropTypes.string,
65
+ inactive: PropTypes.string,
66
+ }),
67
+ icon: PropTypes.node,
68
+ };
69
+
70
+ export default OperatorCtaTwo;
@@ -0,0 +1,143 @@
1
+ @mixin buttonsColor($color1, $color2, $color3, $textColor: 'white') {
2
+ display: inline-flex;
3
+ width: fit-content;
4
+ align-items: center;
5
+ justify-content: center;
6
+ background-color: $color1;
7
+ color: $textColor;
8
+
9
+ &:hover {
10
+ background-color: $color2;
11
+ color: $textColor;
12
+ }
13
+
14
+ &:active {
15
+ background-color: $color3;
16
+ color: $textColor;
17
+ }
18
+ }
19
+
20
+ .primary {
21
+ @include buttonsColor(var(--primary-button-color, #5545A9), var(--primary-button-color-hover, #776ABA), var(--primary-button-color-active, #998FCB), var(--primary-button-color-text, #FFFFFF));
22
+
23
+ &.not_recommended,
24
+ &.coming_soon,
25
+ &.inactive {
26
+ background-color: #BBB5DD;
27
+ color: #776ABA;
28
+ }
29
+ }
30
+
31
+ .secondary {
32
+ @include buttonsColor(var(--secondary-button-color, #1C1A28), var(--secondary-button-color-hover, #33313D), var(--secondary-button-color-active, #3E3C47), var(--secondary-button-color-text, #FFFFFF));
33
+
34
+ &.not_recommended,
35
+ &.coming_soon,
36
+ &.inactive {
37
+ background-color: #6B6A72;
38
+ color: #3E3C47;
39
+ }
40
+ }
41
+
42
+ .tertiary {
43
+ border-width: 1.5px;
44
+ border-style: solid;
45
+ border-color: #1C1A28;
46
+ padding: 2.4rem 3.2rem;
47
+ background-color: white;
48
+ color: #1C1A28;
49
+
50
+ &:hover {
51
+ background-color: #1C1A28;
52
+ color: white;
53
+ border-color: #1C1A28;
54
+ }
55
+
56
+ &:active {
57
+ background-color: #33313D;
58
+ color: white;
59
+ border-color: #33313D;
60
+ }
61
+
62
+ &.not_recommended,
63
+ &.coming_soon,
64
+ &.inactive {
65
+ border-color: #9C9AB0;
66
+ color: #9C9AB0;
67
+ }
68
+ }
69
+
70
+ .xs_size {
71
+ padding: .4rem .8rem;
72
+ border-radius: 4px;
73
+ font-weight: 700;
74
+ font-size: 1.2rem;
75
+ line-height: 1.6rem;
76
+ border-width: 1.5px;
77
+
78
+ >svg {
79
+ height: 0.8rem;
80
+ width: 0.8rem;
81
+ margin-left: .4rem;
82
+ }
83
+ }
84
+
85
+ .s_size {
86
+ padding: 1.1rem 1.6rem;
87
+ border-radius: 8px;
88
+ font-weight: 700;
89
+ font-size: 1.4rem;
90
+ line-height: 1.8rem;
91
+ border-width: 1.5px;
92
+
93
+ >svg {
94
+ height: 1.2rem;
95
+ width: 1.2rem;
96
+ margin-left: 1rem;
97
+ }
98
+ }
99
+
100
+ .m_size {
101
+ font-weight: 700;
102
+ border-radius: 1.2rem;
103
+ padding: 2.1rem 2.4rem;
104
+ font-size: 1.8rem;
105
+ line-height: 2rem;
106
+ border-width: 2px;
107
+
108
+ >svg {
109
+ height: 1.4rem;
110
+ width: 1.4rem;
111
+ margin-left: 11px;
112
+ }
113
+ }
114
+
115
+ .l_size {
116
+ border-radius: 1.6rem;
117
+ padding: 2.5rem 2.4rem;
118
+ font-weight: 700;
119
+ font-size: 2.4rem;
120
+ line-height: 3rem;
121
+ border-width: 2.5px;
122
+
123
+ >svg {
124
+ height: 1.6rem;
125
+ width: 1.6rem;
126
+ margin-left: 1.6rem;
127
+ }
128
+ }
129
+
130
+ .xl_size {
131
+ padding: 2.4rem 3.2rem;
132
+ font-weight: 700;
133
+ font-size: 3.2rem;
134
+ line-height: 4rem;
135
+ border-radius: 1.6rem;
136
+ border-width: 3px;
137
+
138
+ >svg {
139
+ height: 2rem;
140
+ width: 2rem;
141
+ margin-left: 1.8rem;
142
+ }
143
+ }
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+ import {
4
+ Title,
5
+ Description,
6
+ Primary,
7
+ PRIMARY_STORY,
8
+ ArgsTable,
9
+ } from '@storybook/addon-docs/blocks';
10
+ import { IoMdArrowRoundForward } from '@react-icons/all-files/io/IoMdArrowRoundForward';
11
+
12
+ import OperatorCtaTwo from '.';
13
+
14
+ export default {
15
+ title: 'Gatsby-Theme/Atoms/Operator CTA Two',
16
+ component: OperatorCtaTwo,
17
+ argTypes: {
18
+ operator: {
19
+ name: 'operator',
20
+ type: { name: 'object', required: true },
21
+ defaultValue: {
22
+ status: 'active',
23
+ links: {
24
+ main: 'https://icepromo.info/l/6231e62994b436028e219a05',
25
+ operator_review: 'https://icepromo.info/l/6231e62994b436028e219a05',
26
+ },
27
+ },
28
+ description: 'The operator data object.',
29
+ },
30
+ pageTemplate: {
31
+ name: 'PageTemplate',
32
+ type: { name: 'string' },
33
+ defaultValue: 'operator_review',
34
+ description: 'Page Template',
35
+ },
36
+ gtmClass: {
37
+ name: 'gtmClass',
38
+ type: { name: 'string' },
39
+ defaultValue: '',
40
+ description: 'Gtm class',
41
+ },
42
+ buttonType: {
43
+ name: 'buttonType',
44
+ options: ['primary', 'secondary', 'tertiary'],
45
+ control: { type: 'radio' },
46
+ },
47
+ buttonSize: {
48
+ name: 'buttonType',
49
+ options: ['xs', 's', 'm', 'l', 'xl'],
50
+ control: { type: 'radio' },
51
+ },
52
+ tracker: {
53
+ name: 'tracker',
54
+ type: { name: 'string' },
55
+ defaultValue: 'main',
56
+ description: 'Tracker',
57
+ },
58
+ disable: {
59
+ name: 'disable',
60
+ type: { name: 'string' },
61
+ defaultValue: '',
62
+ description: 'disable button style',
63
+ },
64
+ icon: {
65
+ name: 'Icon',
66
+ defaultValue: <IoMdArrowRoundForward />,
67
+ },
68
+ translationsObj: {
69
+ name: 'translationsObj',
70
+ type: { name: 'object' },
71
+ defaultValue: {
72
+ active: 'Visit',
73
+ not_recommended: 'Not Recommended',
74
+ coming_soon: 'Soon Available',
75
+ inactive: 'Not Accepting New Players',
76
+ blacklisted: 'Blacklisted',
77
+ },
78
+ },
79
+ },
80
+ parameters: {
81
+ docs: {
82
+ description: {
83
+ component: 'A component that accepts the operator data and returns a CTA button.',
84
+ },
85
+ page: () => (
86
+ <>
87
+ <Title />
88
+ <Description />
89
+ <Primary />
90
+ <ArgsTable story={PRIMARY_STORY} />
91
+ </>
92
+ ),
93
+ },
94
+ },
95
+ };
96
+
97
+ const Template = (args) => <OperatorCtaTwo {...args} />;
98
+
99
+ export const Default = Template.bind({});
100
+ Default.args = {};
@@ -0,0 +1,50 @@
1
+ /* eslint-disable no-lone-blocks */
2
+ /* eslint-disable no-unused-expressions */
3
+ import React from 'react';
4
+ import { render, cleanup } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+
7
+ import OperatorCtaTwo from '.';
8
+
9
+ const data = (activeStatus = 'active') => ({
10
+ operator: {
11
+ status: activeStatus,
12
+ },
13
+ pageTemplate: 'default',
14
+ buttonType: 'primary',
15
+ buttonSize: 'm',
16
+ tracker: 'main',
17
+ translationsObj: {
18
+ active: 'Visit',
19
+ not_recommended: 'Not Recommended',
20
+ coming_soon: 'Soon Available',
21
+ inactive: 'Not Accepting New Players',
22
+ blacklisted: 'Blacklisted',
23
+ },
24
+ });
25
+
26
+ describe('OperatorCtaTwo Component', () => {
27
+ test('OperatorCtaTwo with status active', () => {
28
+ const { getByText } = render(<OperatorCtaTwo {...data()} />);
29
+ expect(getByText('Visit')).toBeTruthy();
30
+ });
31
+
32
+ test('OperatorCtaTwo with status inactive', () => {
33
+ const { getByText } = render(<OperatorCtaTwo {...data('inactive')} />);
34
+ expect(getByText('Not Accepting New Players')).toBeTruthy();
35
+ });
36
+
37
+ test('OperatorCtaTwo with status not_recommended', () => {
38
+ const { getByText } = render(<OperatorCtaTwo {...data('not_recommended')} />);
39
+ expect(getByText('Not Recommended')).toBeTruthy();
40
+ });
41
+
42
+ test('OperatorCtaTwo with status coming_soon', () => {
43
+ const { getByText } = render(<OperatorCtaTwo {...data('coming_soon')} />);
44
+ expect(getByText('Soon Available')).toBeTruthy();
45
+ });
46
+ });
47
+
48
+ afterEach(() => {
49
+ cleanup();
50
+ });
@@ -1,11 +1,11 @@
1
- import React, { useState, useEffect, useRef, useContext } from 'react';
1
+ import React, { useState, useEffect, useContext } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
4
  import { prettyTracker, imagePrettyUrl } from '~helpers/getters';
5
5
  import LazyImage from '~hooks/lazy-image';
6
6
  import isSticky from '~hooks/stickyOnScroll';
7
7
  import Bonus from '~atoms/bonus';
8
- import OperatorCta from '~atoms/operator-cta';
8
+ import OperatorCta from '~atoms/operator-cta-two';
9
9
  import StarRating from '~molecules/star-rating';
10
10
  import Tnc from '~molecules/tnc';
11
11
  import { Context } from '~context/MainProvider';
@@ -6,7 +6,7 @@ import Bonus from '~atoms/bonus';
6
6
  import SellingPoints from '~atoms/selling-points';
7
7
  import StarRating from '~molecules/star-rating/one-star';
8
8
  import ReviewLink from '../../../atoms/review-link';
9
- import OperatorCta from '~atoms/operator-cta';
9
+ import OperatorCta from '~atoms/operator-cta-two';
10
10
  import { prettyTracker, imagePrettyUrl, getAltText } from '~helpers/getters';
11
11
  import LazyImage from '~hooks/lazy-image';
12
12
 
@@ -3,25 +3,28 @@
3
3
  import { useEffect, useState } from 'react';
4
4
  import { debounce } from '~helpers/scroll';
5
5
 
6
- export default function StickyOnScroll(stickyOffset = 0, callback, elementRef) {
6
+ export default function StickyOnScroll(stickyOffset = 0, callback, elementRef, debounceTime = 50) {
7
7
  const [sticky, setSticky] = useState(false);
8
8
 
9
- const handler = debounce(() => {
10
- if (typeof window !== 'undefined' && typeof stickyOffset === 'number') {
11
- const offset =
12
- elementRef?.current?.getBoundingClientRect()?.top + window.pageYOffset || 0 + stickyOffset;
13
- const isSticky = window.pageYOffset > offset;
14
- sticky !== isSticky && setSticky(isSticky);
15
- callback && callback(isSticky);
16
- }
17
- }, 200);
18
-
19
9
  useEffect(() => {
10
+ const handler = debounce(() => {
11
+ if (typeof window !== 'undefined' && typeof stickyOffset === 'number') {
12
+ const offset =
13
+ elementRef?.current?.getBoundingClientRect()?.top + window.pageYOffset ||
14
+ 0 + stickyOffset;
15
+ const isSticky = window.pageYOffset > offset;
16
+ setSticky(isSticky);
17
+ callback?.(isSticky);
18
+ }
19
+ }, debounceTime);
20
+
21
+ handler();
22
+
20
23
  window.addEventListener('scroll', handler);
21
24
  return () => {
22
25
  window.removeEventListener('scroll', handler);
23
26
  };
24
- }, [sticky, stickyOffset]);
27
+ }, []);
25
28
 
26
29
  return sticky;
27
30
  }