gatsby-matrix-theme 37.0.7 → 37.0.9

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/package.json +2 -2
  3. package/src/components/atoms/cards/comparison-table/table/index.js +1 -0
  4. package/src/components/atoms/cards/game-cards/template-five/index.js +1 -0
  5. package/src/components/atoms/cards/game-cards/template-four/index.js +1 -0
  6. package/src/components/atoms/cards/game-cards/template-one/index.js +1 -0
  7. package/src/components/atoms/cards/game-cards/template-three/index.js +1 -0
  8. package/src/components/atoms/cards/game-cards/template-two/index.js +1 -0
  9. package/src/components/atoms/cards/operator-card/template-one/index.js +1 -0
  10. package/src/components/atoms/cards/operator-card/template-three/index.js +1 -0
  11. package/src/components/atoms/cards/popup-card/index.js +1 -0
  12. package/src/components/atoms/table/column/index.js +5 -1
  13. package/src/components/molecules/operator-exclusive/index.js +1 -0
  14. package/src/components/molecules/toplist/row/variant-one.js +1 -0
  15. package/src/components/molecules/wagering-calculator/index.js +6 -1
  16. package/src/components/organisms/cards/index.js +23 -0
  17. package/src/components/organisms/cards/module-introduction/index.js +54 -0
  18. package/src/components/organisms/cards/module-introduction/styles.module.scss +31 -0
  19. package/src/{gatsby-core-theme/components/organisms/cards → components/organisms/cards/template-one}/index.js +4 -8
  20. package/src/components/organisms/cards/template-one/template-one.stories.js +40 -0
  21. package/src/components/organisms/cards/template-two/buttons/buttons.module.scss +58 -0
  22. package/src/components/organisms/cards/template-two/buttons/index.js +37 -0
  23. package/src/components/organisms/cards/template-two/index.js +77 -0
  24. package/src/components/organisms/cards/template-two/item/index.js +36 -0
  25. package/src/components/organisms/cards/template-two/template-two.stories.js +56 -0
  26. package/src/gatsby-core-theme/components/atoms/module-title/index.js +15 -11
  27. package/src/gatsby-core-theme/components/molecules/module/index.js +27 -22
  28. package/src/gatsby-core-theme/components/molecules/module/module.module.scss +125 -1
  29. package/src/helpers/cards.js +7 -77
  30. package/storybook/public/127.ff669276.iframe.bundle.js +1 -0
  31. package/storybook/public/128.1d816ef4.iframe.bundle.js +1 -0
  32. package/storybook/public/162.d30676dc.iframe.bundle.js +1 -0
  33. package/storybook/public/172.fe4ee9e5.iframe.bundle.js +1 -0
  34. package/storybook/public/200.58e72b2b.iframe.bundle.js +1 -0
  35. package/storybook/public/238.ef62d1ab.iframe.bundle.js +1 -0
  36. package/storybook/public/313.f14e679f.iframe.bundle.js +1 -0
  37. package/storybook/public/355.98fe7319.iframe.bundle.js +1 -0
  38. package/storybook/public/357.109f6237.iframe.bundle.js +1 -0
  39. package/storybook/public/{408.66ddb646.iframe.bundle.js → 408.a15d93ee.iframe.bundle.js} +2 -2
  40. package/storybook/public/487.45abc0d9.iframe.bundle.js +1 -0
  41. package/storybook/public/495.384c1d3c.iframe.bundle.js +1 -0
  42. package/storybook/public/555.3898ed1b.iframe.bundle.js +1 -0
  43. package/storybook/public/60.c3ac15e1.iframe.bundle.js +1 -0
  44. package/storybook/public/{487.a0ab2ddb.iframe.bundle.js → 652.16161342.iframe.bundle.js} +4 -4
  45. package/storybook/public/{487.a0ab2ddb.iframe.bundle.js.map → 652.16161342.iframe.bundle.js.map} +1 -1
  46. package/storybook/public/658.0bf05662.iframe.bundle.js +1 -0
  47. package/storybook/public/713.888f0872.iframe.bundle.js +1 -0
  48. package/storybook/public/758.729fbe5e.iframe.bundle.js +1 -0
  49. package/storybook/public/836.659f6c94.iframe.bundle.js +1 -0
  50. package/storybook/public/864.cbf8e102.iframe.bundle.js +1 -0
  51. package/storybook/public/866.df95c862.iframe.bundle.js +1 -0
  52. package/storybook/public/871.5ceb4bc5.iframe.bundle.js +1 -0
  53. package/storybook/public/938.f1a4065f.iframe.bundle.js +1 -0
  54. package/storybook/public/iframe.html +1 -1
  55. package/storybook/public/main.3d0e1fc9.iframe.bundle.js +2 -0
  56. package/storybook/public/runtime~main.b0842e70.iframe.bundle.js +1 -0
  57. package/tests/factories/modules/matrix/card.factory.js +268 -7
  58. package/src/components/atoms/cards/game-cards/index.js +0 -17
  59. package/storybook/public/238.856d8725.iframe.bundle.js +0 -1
  60. package/storybook/public/263.d26badb6.iframe.bundle.js +0 -1
  61. package/storybook/public/521.282e4f6f.iframe.bundle.js +0 -1
  62. package/storybook/public/555.6eba6df4.iframe.bundle.js +0 -1
  63. package/storybook/public/60.ff674703.iframe.bundle.js +0 -1
  64. package/storybook/public/main.43caee2d.iframe.bundle.js +0 -2
  65. package/storybook/public/runtime~main.daeb2a8f.iframe.bundle.js +0 -1
  66. /package/storybook/public/{408.66ddb646.iframe.bundle.js.LICENSE.txt → 408.a15d93ee.iframe.bundle.js.LICENSE.txt} +0 -0
  67. /package/storybook/public/{487.a0ab2ddb.iframe.bundle.js.LICENSE.txt → 652.16161342.iframe.bundle.js.LICENSE.txt} +0 -0
  68. /package/storybook/public/{main.43caee2d.iframe.bundle.js.LICENSE.txt → main.3d0e1fc9.iframe.bundle.js.LICENSE.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## [37.0.9](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v37.0.8...v37.0.9) (2023-11-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update to latest theme ([b64f909](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/b64f90998035c6a60837178f0e97d58f6edf4ba4))
7
+
8
+ ## [37.0.8](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v37.0.7...v37.0.8) (2023-11-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add storybook ([dc13fe4](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/dc13fe483c99c8a76923bb6c32a2c99b3220cb5a))
14
+ * clean up ([7b92d6b](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/7b92d6b251e7fe2db17998abb264ba74e73606c7))
15
+ * clean up ([5bc173d](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/5bc173d4f0cad7e574eff9cdae88b35d8e94a0c5))
16
+ * cleanup cards ([6c48ddd](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/6c48ddda337ee792b429d60befecf81866364a3d))
17
+ * enable scroll event ([0d7727a](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/0d7727addc581359506e5792bce98d3fd6553265))
18
+ * fix tests ([926861b](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/926861bd225f3fda9d8ab26144bc7a46151f2541))
19
+ * follow standart name ([035e8c1](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/035e8c1da442c10201b5b52cd06cc034d629be2c))
20
+ * maket logic ([c8ef3a6](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/c8ef3a67a4e11f92aa1e67ee3e73e0bbc02d593d))
21
+ * rename storybook ([668fb3d](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/668fb3d2dd29b0fa82618b1271da7fad0f1d4303))
22
+ * scroll left first time is zero and we need to add shift space ([0f4beb0](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/0f4beb00f355469cbff874ac63a54de1a889a96c))
23
+ * template cards img ([012bfc9](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/012bfc9e22dd6c6a93916ff351f1a0d55f02c672))
24
+ * update theme ([0b4d6db](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/0b4d6dbf7ca0f2e78cf5bb96b92b08a3452955da))
25
+ * updated to latest core theme ([c501e57](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/c501e57804b49d8d2aaec7e84e2b8c06734072bb))
26
+
27
+
28
+ * Merge branch 'cleanup' into 'master' ([3291de0](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/3291de071f91d600349dcc5ed3db1b770672b8f4))
29
+ * Merge branch 'tm-3814' into 'master' ([ac45c76](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/ac45c765808289b5955a7af361ed477374a93d9c))
30
+
1
31
  ## [37.0.7](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v37.0.6...v37.0.7) (2023-11-17)
2
32
 
3
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "37.0.7",
3
+ "version": "37.0.9",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@react-icons/all-files": "^4.1.0",
27
27
  "gatsby": "^5.11.0",
28
- "gatsby-core-theme": "30.0.19",
28
+ "gatsby-core-theme": "30.0.24",
29
29
  "gatsby-plugin-sharp": "^5.11.0",
30
30
  "gatsby-plugin-sitemap": "^3.3.0",
31
31
  "gatsby-transformer-sharp": "^5.11.0",
@@ -102,6 +102,7 @@ export default function ComparisonTable({
102
102
  <span>{itemName}</span>
103
103
  {item?.relation?.status !== 'not_recommended' && (
104
104
  <OperatorCta
105
+ module="comparison-table"
105
106
  tracker="main"
106
107
  operator={item?.relation}
107
108
  translationsObj={{
@@ -106,6 +106,7 @@ const TemplateFive = ({
106
106
  <>
107
107
  {operator && operator.status !== 'not_recommended' ? (
108
108
  <OperatorCta
109
+ module="cards_v2"
109
110
  tracker="main"
110
111
  operator={operator}
111
112
  translationsObj={{
@@ -92,6 +92,7 @@ const TemplateFour = ({
92
92
  {operator && operator.status !== 'not_recommended' ? (
93
93
  <OperatorCta
94
94
  tracker="main"
95
+ module="cards_v2"
95
96
  operator={operator}
96
97
  translationsObj={{
97
98
  active: { translationKey: 'play_now_game', defaultValue: 'Play for Real' },
@@ -92,6 +92,7 @@ const TemplateOne = ({
92
92
  {operator && operator.status !== 'not_recommended' ? (
93
93
  <OperatorCta
94
94
  tracker="main"
95
+ module="cards_v2"
95
96
  operator={operator}
96
97
  translationsObj={{
97
98
  active: { translationKey: 'play_now_game', defaultValue: 'Play for Real' },
@@ -90,6 +90,7 @@ const TemplateThree = ({
90
90
  <>
91
91
  {operator && operator.status !== 'not_recommended' ? (
92
92
  <OperatorCta
93
+ module="cards_v2"
93
94
  tracker="main"
94
95
  operator={operator}
95
96
  translationsObj={{
@@ -92,6 +92,7 @@ const TemplateTwo = ({
92
92
  <>
93
93
  {operator && operator.status !== 'not_recommended' ? (
94
94
  <OperatorCta
95
+ module="cards_v2"
95
96
  tracker="main"
96
97
  operator={operator}
97
98
  translationsObj={{
@@ -84,6 +84,7 @@ const TemplateOne = ({
84
84
  {relation?.status !== 'not_recommended' && (
85
85
  <OperatorCta
86
86
  tracker="main"
87
+ module="cards_v2"
87
88
  operator={relation}
88
89
  buttonSize="m"
89
90
  translationsObj={{
@@ -61,6 +61,7 @@ const TemplateThree = ({
61
61
  <OperatorCta
62
62
  tracker="main"
63
63
  buttonSize="m"
64
+ module="cards_v2"
64
65
  operator={relation}
65
66
  translationsObj={{
66
67
  active: { translationKey: 'play_now', defaultValue: 'Play Now' },
@@ -43,6 +43,7 @@ const PopupCard = ({
43
43
  <div className={styles?.buttonContainer || ''}>
44
44
  <OperatorCta
45
45
  tracker={tracker}
46
+ module="Popup"
46
47
  operator={item}
47
48
  buttonSize={buttonSize}
48
49
  buttonType={buttonType}
@@ -63,7 +63,11 @@ const Index = ({
63
63
  <p>{item.name}</p>
64
64
  </div>
65
65
  <div className={styles?.cta || ''}>
66
- <OperatorCta operator={item} gtmClass="table-operator-cta-gtm" />
66
+ <OperatorCta
67
+ module="comparison_table"
68
+ operator={item}
69
+ gtmClass="table-operator-cta-gtm"
70
+ />
67
71
  </div>
68
72
  </div>
69
73
  </td>
@@ -60,6 +60,7 @@ const Banner = ({ bonus, template, closeButtonIcon = true }) => {
60
60
  <div className={styles?.button || ''}>
61
61
  <OperatorCta
62
62
  operator={bonus.value}
63
+ module="exclusive_operator"
63
64
  translationsObj={{
64
65
  active: { translationKey: 'play_now', defaultValue: 'Play now' },
65
66
  not_recommended: {
@@ -59,6 +59,7 @@ export default function Row({
59
59
  operator={item}
60
60
  tracker={tracker}
61
61
  gtmClass="toplist-operator-cta-gtm"
62
+ module="top_list"
62
63
  pageTemplate={template}
63
64
  />
64
65
  </>
@@ -201,7 +201,12 @@ const WageringCalculator = ({
201
201
  />
202
202
  </a>
203
203
  <Bonus item={operator} tracker="main" />
204
- <OperatorCta operator={operator} tracker="main" buttonType={buttonType} />
204
+ <OperatorCta
205
+ module="wagering_calculator"
206
+ operator={operator}
207
+ tracker="main"
208
+ buttonType={buttonType}
209
+ />
205
210
  </div>
206
211
  );
207
212
  })}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import GridLayout from './template-one';
3
+ import SrcollLayout from './template-two';
4
+ import ModuleIntroduction from './module-introduction';
5
+
6
+ export default function index(props) {
7
+ const { module, page } = props;
8
+ const Component = () => {
9
+ switch (module?.style) {
10
+ case 'template_two':
11
+ return <SrcollLayout module={module} page={page} />;
12
+ default:
13
+ return <GridLayout module={module} page={page} />;
14
+ }
15
+ };
16
+
17
+ return (
18
+ <>
19
+ <ModuleIntroduction module={module} />
20
+ <Component />
21
+ </>
22
+ );
23
+ }
@@ -0,0 +1,54 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import loadable from '@loadable/component';
5
+ import { FiArrowRight } from '@react-icons/all-files/fi/FiArrowRight';
6
+ import { anchorLink } from 'gatsby-core-theme/src/helpers/strings';
7
+ import styles from './styles.module.scss';
8
+ import ModuleTitle from '../../../../gatsby-core-theme/components/atoms/module-title';
9
+ import Link from '~hooks/link';
10
+ import { removeSymbols } from '../../../../helpers/strings';
11
+
12
+ const ModuleIntroduction = ({ module }) => {
13
+ const anchorLabel = module?.anchor_label && removeSymbols(anchorLink(module?.anchor_label));
14
+
15
+ const ModuleIntro = module?.module_introduction
16
+ ? loadable(() => import('~molecules/content'))
17
+ : null;
18
+
19
+ return (
20
+ <div className={ModuleIntro ? '' : styles.noIntroModuleCards}>
21
+ <ModuleTitle
22
+ module={module}
23
+ anchorLabel={module.name === 'archive' && anchorLabel}
24
+ showMoreLink={!ModuleIntro}
25
+ />
26
+ {ModuleIntro && (
27
+ <ModuleIntro
28
+ isModuleIntroduction={module?.module_introduction}
29
+ module={{ value: module?.module_introduction }}
30
+ />
31
+ )}
32
+ {ModuleIntro && module.see_more_link?.value && (
33
+ <Link to="/" className={`${styles.viewMore || ''} module-title-gtm`}>
34
+ {module.see_more_link.title}
35
+ <FiArrowRight title="Right-pointing Arrow Icon" />
36
+ </Link>
37
+ )}
38
+ </div>
39
+ );
40
+ };
41
+
42
+ ModuleIntroduction.propTypes = {
43
+ module: PropTypes.shape({
44
+ anchor_label: PropTypes.string,
45
+ name: PropTypes.string.isRequired,
46
+ module_introduction: PropTypes.string,
47
+ see_more_link: PropTypes.shape({
48
+ value: PropTypes.string,
49
+ title: PropTypes.string,
50
+ }),
51
+ }),
52
+ };
53
+
54
+ export default ModuleIntroduction;
@@ -0,0 +1,31 @@
1
+ .noIntroModuleCards {
2
+ > div {
3
+ @include flex-align(flex-start, space-between);
4
+ width: 100%;
5
+ flex-direction: column;
6
+
7
+ @include min(tablet) {
8
+ flex-direction: row;
9
+ align-items: space-between;
10
+ }
11
+
12
+ a {
13
+ @include flex-align(center, space-between);
14
+ }
15
+ }
16
+ }
17
+
18
+
19
+ .viewMore {
20
+ font-size: 1.6rem;
21
+ font-style: normal;
22
+ font-weight: 700;
23
+ line-height: 2.7rem;
24
+ text-transform: capitalize;
25
+ @include flex-align(center, flex-start);
26
+ color: #165AF8;
27
+ gap: .4rem;
28
+ svg{
29
+ margin-top: .2rem;
30
+ }
31
+ }
@@ -5,20 +5,16 @@ import React from 'react';
5
5
  import Card from 'gatsby-core-theme/src/components/organisms/cards/index';
6
6
  import { getCard } from '../../../../helpers/cards';
7
7
 
8
- export default (props) => {
9
- const customCardComponent = getCard(
10
- props.module.model_type || props.module.cards_page_type,
11
- props.module.style
12
- );
13
-
8
+ export default ({ module, page }) => {
9
+ const customCardComponent = getCard(module?.model_type || module?.cards_page_type);
14
10
  return (
15
11
  <Card
16
- {...props}
12
+ module={module}
17
13
  mobileColumns={1}
18
14
  tabletColumns={2}
19
15
  desktopColumns={3}
20
16
  CustomCardComponent={customCardComponent}
21
- pageTemplate={props?.page?.template}
17
+ pageTemplate={page?.template}
22
18
  />
23
19
  );
24
20
  };
@@ -0,0 +1,40 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import {
4
+ Title,
5
+ Description,
6
+ Primary,
7
+ PRIMARY_STORY,
8
+ ArgsTable,
9
+ } from '@storybook/addon-docs/blocks';
10
+ import { sampleOperatorCards } from '../../../../../tests/factories/modules/matrix/card.factory';
11
+ import TemplateOne from '.';
12
+
13
+ const operatorData = sampleOperatorCards;
14
+
15
+ export default {
16
+ title: 'Theme/Modules/Cards/Layout/Template One',
17
+ component: TemplateOne,
18
+ args: {
19
+ module: operatorData,
20
+ },
21
+ parameters: {
22
+ docs: {
23
+ description: {
24
+ component: 'A Default Footer Component - Template One',
25
+ },
26
+ page: () => (
27
+ <>
28
+ <Title />
29
+ <Description />
30
+ <Primary />
31
+ <ArgsTable story={PRIMARY_STORY} />
32
+ </>
33
+ ),
34
+ },
35
+ },
36
+ };
37
+
38
+ const Template = (args) => <TemplateOne {...args} />;
39
+ export const Default = Template.bind({});
40
+ Default.args = {};
@@ -0,0 +1,58 @@
1
+ .buttLeft,
2
+ .buttRight {
3
+ position: absolute;
4
+ left: 3.8rem;
5
+ bottom: 4rem;
6
+ width: 4rem;
7
+ height: 4rem;
8
+ border-radius: 100px;
9
+ background: var(--background-card-slider-button, #262629);
10
+ color: var(--card-color-slider-button, white);
11
+ display: none;
12
+
13
+ @include min(tablet) {
14
+ @include flex-direction(column);
15
+ @include flex-align(center, center);
16
+ bottom: 1.6rem;
17
+ left: 5.6rem;
18
+ }
19
+
20
+ @include min(desktop) {
21
+ left: 9.6rem;
22
+ }
23
+ }
24
+
25
+ .buttRight {
26
+ left: 12.4rem;
27
+
28
+ @include min(tablet) {
29
+ left: 10rem;
30
+ }
31
+
32
+ @include min(desktop) {
33
+ left: 14rem;
34
+ }
35
+ }
36
+
37
+ .disabled {
38
+ background: var(--disabled-background-card-slider-button, #dedede);
39
+ color: var(--disabled-color-card-slider-button, #262629);
40
+ }
41
+
42
+ .nointroButtLeft {
43
+ left: 1%;
44
+ bottom: 4rem;
45
+
46
+ @include min(desktop) {
47
+ left: 15%;
48
+ }
49
+ }
50
+
51
+ .nointroButtRight {
52
+ left: calc(1% + 4.5rem);
53
+ bottom: 4rem;
54
+
55
+ @include min(desktop) {
56
+ left: calc(15% + 4.5rem);
57
+ }
58
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { IoIosArrowBack } from '@react-icons/all-files/io/IoIosArrowBack';
4
+ import { IoIosArrowForward } from '@react-icons/all-files/io/IoIosArrowForward';
5
+ import styles from './buttons.module.scss';
6
+
7
+ const Buttons = ({ scrollX, noModuleIntro, scrollEnd, scroll }) => (
8
+ <>
9
+ <button
10
+ className={`${styles.buttLeft} ${noModuleIntro ? styles.nointroButtLeft : ''} ${
11
+ scrollX <= 0 ? styles.disabled : ''
12
+ }`}
13
+ onClick={() => scroll(-200)}
14
+ type="button"
15
+ >
16
+ <IoIosArrowBack />
17
+ </button>
18
+ <button
19
+ className={`${styles.buttRight} ${noModuleIntro ? styles.nointroButtRight : ''} ${
20
+ !scrollEnd ? '' : styles.disabled
21
+ }`}
22
+ onClick={() => scroll(200)}
23
+ type="button"
24
+ >
25
+ <IoIosArrowForward />
26
+ </button>
27
+ </>
28
+ );
29
+
30
+ Buttons.propTypes = {
31
+ scrollX: PropTypes.number,
32
+ noModuleIntro: PropTypes.bool,
33
+ scrollEnd: PropTypes.bool,
34
+ scroll: PropTypes.func,
35
+ };
36
+
37
+ export default Buttons;
@@ -0,0 +1,77 @@
1
+ /* eslint-disable react/no-array-index-key */
2
+ /* eslint-disable react/forbid-prop-types */
3
+ import React, { useRef, useState, useEffect } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import ScrollX from 'gatsby-core-theme/src/hooks/scroll-x';
6
+ import Compoo from './item';
7
+ import Buttons from './buttons';
8
+
9
+ const CustomCarousel = ({ page, module, noModuleIntro }) => {
10
+ const container = useRef(null);
11
+ const [scrollX, setScrollX] = useState(0);
12
+ const [scrollEnd, setScrollEnd] = useState(false);
13
+ const [showButtons, setShowButtons] = useState(false);
14
+
15
+ const updateButtons = (shift) => {
16
+ setScrollEnd(
17
+ Math.floor(container.current.scrollWidth - (container.current.scrollLeft + shift)) <=
18
+ container.current.offsetWidth
19
+ );
20
+ };
21
+
22
+ const scroll = (shift) => {
23
+ container.current.scrollTo({
24
+ left: container.current.scrollLeft + shift,
25
+ behavior: 'smooth',
26
+ });
27
+ updateButtons(shift);
28
+ setScrollX(scrollX + shift);
29
+ };
30
+
31
+ const onStopScrolling = () => {
32
+ setScrollX(container.current.scrollLeft);
33
+ updateButtons(0);
34
+ };
35
+
36
+ const onScroll = (scrollLeft) => {
37
+ updateButtons(0);
38
+ setScrollX(scrollLeft);
39
+ };
40
+
41
+ useEffect(() => {
42
+ const timer = setTimeout(() => {
43
+ setShowButtons(container.current.scrollWidth > container.current.offsetWidth);
44
+ }, 500);
45
+ return () => clearTimeout(timer);
46
+ }, []);
47
+
48
+ return (
49
+ <ScrollX refTag={container} scroll stopScrolling={() => onStopScrolling()} onScroll={onScroll}>
50
+ <div ref={container}>
51
+ {module.items &&
52
+ module.items.map((item, index) => (
53
+ <Compoo key={index} index={index} item={item} page={page} module={module} />
54
+ ))}
55
+ {showButtons && (
56
+ <Buttons
57
+ scroll={scroll}
58
+ noModuleIntro={noModuleIntro}
59
+ scrollX={scrollX}
60
+ scrollEnd={scrollEnd}
61
+ />
62
+ )}
63
+ </div>
64
+ </ScrollX>
65
+ );
66
+ };
67
+
68
+ CustomCarousel.propTypes = {
69
+ page: PropTypes.shape({}),
70
+ module: PropTypes.shape({
71
+ items: PropTypes.arrayOf(PropTypes.object),
72
+ style: PropTypes.string,
73
+ }).isRequired,
74
+ noModuleIntro: PropTypes.bool,
75
+ };
76
+
77
+ export default CustomCarousel;
@@ -0,0 +1,36 @@
1
+ /* eslint-disable react/forbid-prop-types */
2
+ import React, { memo } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { getCard } from '../../../../../helpers/cards';
5
+ import keygen from '~helpers/keygen';
6
+
7
+ const CustomCardComponent = memo(({ module, item, page, index, template = 'template_five' }) => {
8
+ const Compo = getCard(module.model_type || module.cards_page_type, template);
9
+ return (
10
+ <Compo
11
+ key={keygen()}
12
+ featured={module.style === 'featured'}
13
+ item={item}
14
+ type={item.type}
15
+ number={index + 1}
16
+ page={page}
17
+ />
18
+ );
19
+ });
20
+
21
+ CustomCardComponent.propTypes = {
22
+ page: PropTypes.shape({}),
23
+ module: PropTypes.shape({
24
+ items: PropTypes.array,
25
+ style: PropTypes.string,
26
+ model_type: PropTypes.string,
27
+ cards_page_type: PropTypes.string,
28
+ }),
29
+ item: PropTypes.shape({
30
+ type: PropTypes.string,
31
+ }),
32
+ index: PropTypes.number,
33
+ template: PropTypes.string,
34
+ };
35
+
36
+ export default CustomCardComponent;
@@ -0,0 +1,56 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import {
4
+ Title,
5
+ Description,
6
+ Primary,
7
+ ArgsTable,
8
+ PRIMARY_STORY,
9
+ } from '@storybook/addon-docs/blocks';
10
+ import { sampleOperatorCards } from '../../../../../tests/factories/modules/matrix/card.factory';
11
+ import TemplateTwo from '../../../../gatsby-core-theme/components/molecules/module';
12
+
13
+ const operatorData = sampleOperatorCards;
14
+
15
+ export default {
16
+ title: 'Theme/Modules/Cards/Layout/Template Two',
17
+ component: TemplateTwo,
18
+ argTypes: {
19
+ module: {
20
+ control: 'object',
21
+ },
22
+ },
23
+ args: {
24
+ module: {
25
+ ...operatorData,
26
+ },
27
+ removeModuleIntroduction: false,
28
+ },
29
+ parameters: {
30
+ docs: {
31
+ description: {
32
+ component: 'A Cards Layout Component - Template Two',
33
+ },
34
+ page: () => (
35
+ <>
36
+ <Title />
37
+ <Description />
38
+ <Primary />
39
+ <ArgsTable story={PRIMARY_STORY} />
40
+ </>
41
+ ),
42
+ },
43
+ },
44
+ };
45
+
46
+ const Template = (args) => <TemplateTwo {...args} />;
47
+ export const VariantOne = Template.bind({});
48
+ VariantOne.args = {};
49
+
50
+ export const VariantTwo = Template.bind({});
51
+ VariantTwo.args = {
52
+ module: {
53
+ ...operatorData,
54
+ module_introduction: null,
55
+ },
56
+ };