gatsby-core-theme 1.6.9 → 1.6.10

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,14 @@
1
+ ## [1.6.10](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.9...v1.6.10) (2021-11-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * sitemap changed to a page from hercules ([a0e90e4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a0e90e4916fcc0a2918dde39971265cc48fe89da))
7
+ * sitemap fixes ([7c35ba4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7c35ba42cf54a937800140387b84278479caad92))
8
+
9
+
10
+ * Merge branch 'master' of git.ilcd.rocks:team-floyd/themes/gatsby-themes ([a75119b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a75119b9e50cf2f5143242dcedc49b54abcfb6ce))
11
+
1
12
  ## [1.6.9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.8...v1.6.9) (2021-11-24)
2
13
 
3
14
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-unused-vars */
1
2
  /* eslint no-console: ["error", { allow: ["log"] }], no-shadow: ["error", { "allow": ["marketSections", "prefilledModules"] }] */
2
3
  /* eslint-disable dot-notation */
3
4
 
@@ -233,6 +234,12 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
233
234
  });
234
235
  } else if (page.path === '404') {
235
236
  context404 = contextData;
237
+ } else if (page.path === 'sitemap') {
238
+ createPage({
239
+ path: `/${page.path}`,
240
+ component: require.resolve('./src/components/app.js'),
241
+ context: { ...contextData, sitemapData: { ...htmlSitemapPages }, templates },
242
+ });
236
243
  } else {
237
244
  createPage({
238
245
  path: page.path.charAt(0) === '/' ? page.path : `/${page.path}`,
@@ -297,31 +304,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
297
304
  exports.onCreatePage = ({ page, actions }) => {
298
305
  const { createPage } = actions;
299
306
 
300
- if (page.path.includes('sitemap')) {
301
- const pageNotFoundData = {
302
- meta_title: 'Sitemap',
303
- template: 'sitemap',
304
- title: 'Site Map',
305
- type: 'page',
306
- sections: {
307
- main: null,
308
- navigation: null,
309
- sidebar: null,
310
- footer: null,
311
- },
312
- language: languageKey,
313
- translations,
314
- relation: {
315
- sports,
316
- },
317
- };
318
- page = Object.assign(pageNotFoundData, page); // eslint-disable-line no-param-reassign
319
- createPage({
320
- path: page.path,
321
- component: require.resolve('./src/pages/sitemap/'),
322
- context: { page, siteInfo, marketSections, sitemapData: { ...htmlSitemapPages }, templates },
323
- });
324
- } else if (page.path.includes('404')) {
307
+ if (page.path.includes('404')) {
325
308
  createPage({
326
309
  path: page.path,
327
310
  component: require.resolve('./src/pages/404/'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -60,7 +60,8 @@
60
60
  "react-google-recaptcha": "^2.1.0",
61
61
  "react-helmet": "^6.0.0",
62
62
  "react-icons": "^4.2.0",
63
- "react-lazyload": "^2.6.5"
63
+ "react-lazyload": "^2.6.5",
64
+ "react-masonry-css": "^1.0.16"
64
65
  },
65
66
  "devDependencies": {
66
67
  "@babel/core": "^7.13.1",
@@ -1,18 +1,27 @@
1
1
  /* eslint-disable array-callback-return */
2
2
  /* eslint-disable react/forbid-prop-types */
3
- import React from 'react';
3
+ import React, { useContext } from 'react';
4
4
  import PropTypes from 'prop-types';
5
+ import { BiSitemap } from 'react-icons/bi';
6
+ import { IoMdLink } from 'react-icons/io';
7
+ // eslint-disable-next-line import/no-extraneous-dependencies
8
+ import Masonry from 'react-masonry-css';
9
+ import { Context } from '~context/TranslationsProvider';
10
+ import { translate } from '~helpers/getters';
5
11
  import styles from './sitemap.module.scss';
6
- import Body from '~pages/body';
7
- import Head from '~organisms/head';
8
12
  import Link from '~hooks/link';
9
13
 
10
- const Sitemap = ({ pageContext, templateIcon, linkIcon }) => {
14
+ const Sitemap = ({ pageContext, templateIcon = <BiSitemap />, linkIcon = <IoMdLink /> }) => {
11
15
  const { templates, sitemapData } = pageContext;
16
+ const { translations } = useContext(Context) || {};
12
17
  const market = Object.keys(sitemapData)[0];
13
18
 
14
19
  const getTemplateName = (template) => {
15
- const templateName = templates[template].short_name.replace('_', ' ');
20
+ const templateName = translate(
21
+ translations,
22
+ templates[template].short_name,
23
+ templates[template].short_name.replace('_', ' ')
24
+ );
16
25
  const templatePages = sitemapData[market][template];
17
26
  const templatePagesCount = templatePages && templatePages.length;
18
27
 
@@ -47,19 +56,14 @@ const Sitemap = ({ pageContext, templateIcon, linkIcon }) => {
47
56
  };
48
57
 
49
58
  return (
50
- <>
51
- <Head page={pageContext.page} siteInfo={pageContext.siteInfo} />
52
- <Body pageContext={pageContext}>
53
- <div className={styles.container}>
54
- {Object.keys(templates).map((template) => (
55
- <ul key={template} className={styles.list}>
56
- {getTemplateName(template)}
57
- {getTemplatePages(template)}
58
- </ul>
59
- ))}
60
- </div>
61
- </Body>
62
- </>
59
+ <Masonry breakpointCols={3} className={styles.container} columnClassName={styles.list}>
60
+ {Object.keys(templates).map((template) => (
61
+ <ul key={template}>
62
+ {getTemplateName(template)}
63
+ {getTemplatePages(template)}
64
+ </ul>
65
+ ))}
66
+ </Masonry>
63
67
  );
64
68
  };
65
69
 
@@ -67,8 +71,6 @@ Sitemap.propTypes = {
67
71
  pageContext: PropTypes.shape({
68
72
  sitemapData: PropTypes.object,
69
73
  templates: PropTypes.object,
70
- siteInfo: PropTypes.object,
71
- page: PropTypes.object,
72
74
  }),
73
75
  templateIcon: PropTypes.element,
74
76
  linkIcon: PropTypes.element,
@@ -0,0 +1,111 @@
1
+ .container {
2
+ display: flex;
3
+ max-width: var(--main-container-max);
4
+ margin: 0 auto;
5
+ padding: 0 2.4rem 2rem 2.4rem;
6
+
7
+ @include min(mobile) {
8
+ padding: 0 1.6rem 2rem 1.6rem;
9
+ }
10
+
11
+ @include max(mobile) {
12
+ display: block;
13
+ }
14
+ }
15
+
16
+ .list {
17
+ @include max(mobile) {
18
+ width: 100% !important;
19
+ }
20
+
21
+ > ul {
22
+ display: flex;
23
+ flex-direction: column;
24
+ padding: 1rem;
25
+
26
+ > div {
27
+ position: relative;
28
+ @include flex-align(center, flex-start);
29
+
30
+ svg {
31
+ fill: white !important;
32
+ background-color: var(--template-name-icon-background, red);
33
+ padding: 1rem;
34
+ width: 4.8rem;
35
+ height: 4.8rem;
36
+ border-radius: 2.8rem;
37
+ }
38
+
39
+ > span {
40
+ color: black;
41
+ font-weight: 700;
42
+ font-size: 2rem;
43
+ margin-left: 1.6rem;
44
+ text-transform: capitalize;
45
+ }
46
+
47
+ span:last-child {
48
+ @include flex-align(center, center);
49
+ position: absolute;
50
+ top: -1.2rem;
51
+ background-color: var(--page-number-background, green);
52
+ border-radius: 1.2rem;
53
+ border: 0.2rem solid white;
54
+ margin: 0;
55
+ font-size: 1rem;
56
+ color: var(--page-number-color, white);
57
+ font-weight: 700;
58
+ width: 2.4rem;
59
+ height: 2.4rem;
60
+ left: 3.2rem;
61
+ }
62
+ }
63
+
64
+ > ul {
65
+ padding-top: 3rem;
66
+ padding-left: 2.7rem;
67
+ margin-left: 2.3rem;
68
+ border-left: dashed 1px #e3e6ef;
69
+
70
+ li {
71
+ display: grid;
72
+ grid-template-columns: 0.1fr 1fr;
73
+ gap: 0.5rem;
74
+ margin-bottom: 1rem;
75
+ position: relative;
76
+
77
+ &:before {
78
+ content: ' ';
79
+ position: absolute;
80
+ left: -2.7rem;
81
+ width: 2.5rem;
82
+ top: 1.2rem;
83
+ border: dashed 1px #e3e6ef;
84
+ }
85
+
86
+ &:last-child:after {
87
+ content: ' ';
88
+ width: 1rem;
89
+ height: 5rem;
90
+ background-color: var(--sitemap-background-color);
91
+ position: absolute;
92
+ top: 1.3rem;
93
+ left: -2.8rem;
94
+ }
95
+
96
+ svg {
97
+ fill: white !important;
98
+ background-color: #6e6e84;
99
+ padding: 0.3rem;
100
+ width: 2.4rem;
101
+ height: 2.4rem;
102
+ border-radius: 0.8rem;
103
+ }
104
+
105
+ a {
106
+ padding-left: 0.3rem;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
@@ -0,0 +1,96 @@
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
+
11
+ import Sitemap from '.';
12
+
13
+ export default {
14
+ title: 'Gatsby-Theme/Atoms/Sitemap',
15
+ component: Sitemap,
16
+ argTypes: {
17
+ // pageContext: {
18
+ // name: 'sitemapData',
19
+ // type: { name: 'object', required: true },
20
+ // defaultValue: null,
21
+ // description: 'Object containing all links grouped by page type.',
22
+ // table: {
23
+ // type: { summary: 'object' },
24
+ // defaultValue: { summary: null },
25
+ // },
26
+ // },
27
+ },
28
+ parameters: {
29
+ docs: {
30
+ description: {
31
+ component: 'An HTML sitemap showing all pages as links',
32
+ },
33
+ page: () => (
34
+ <>
35
+ <Title />
36
+ <Description />
37
+ <Primary />
38
+ <ArgsTable story={PRIMARY_STORY} />
39
+ </>
40
+ ),
41
+ },
42
+ },
43
+ };
44
+
45
+ const Template = (args) => <Sitemap {...args} />;
46
+
47
+ export const Default = Template.bind({});
48
+ Default.args = {
49
+ pageContext: {
50
+ sitemapData: {
51
+ ie_en: {
52
+ 1: [
53
+ {
54
+ title: 'test one',
55
+ path: '/test_one',
56
+ },
57
+ {
58
+ title: 'test two',
59
+ path: '/test_two',
60
+ },
61
+ {
62
+ title: 'test three',
63
+ path: '/test_three',
64
+ },
65
+ ],
66
+ 2: [
67
+ {
68
+ title: 'template page one',
69
+ path: '/template_page_one',
70
+ },
71
+ {
72
+ title: 'template page two',
73
+ path: '/template_page_two',
74
+ },
75
+ ],
76
+ 3: [
77
+ {
78
+ title: 'template two page',
79
+ path: 'template_teo_page',
80
+ },
81
+ ],
82
+ },
83
+ },
84
+ templates: {
85
+ 1: {
86
+ short_name: 'template one',
87
+ },
88
+ 2: {
89
+ short_name: 'template two',
90
+ },
91
+ 3: {
92
+ short_name: 'template three',
93
+ },
94
+ },
95
+ },
96
+ };
@@ -5,14 +5,17 @@ import Module from '~molecules/module';
5
5
  import styles from './main.module.scss';
6
6
  import keygen from '~helpers/keygen';
7
7
 
8
- const Main = ({ section = {}, page = {}, pageContext = {} }) => {
8
+ const Main = ({ section = {}, pageContext = {} }) => {
9
+ const { page } = pageContext;
9
10
  const SearchPage = page.path === 's' ? loadable(() => import(`~pages/search`)) : null;
11
+ const HtmlSitemap = page.path === 'sitemap' ? loadable(() => import(`~atoms/sitemap`)) : null;
10
12
  const AuthorBox = page.author ? loadable(() => import(`~atoms/author-box`)) : null;
11
13
  const NotFound = page?.path?.includes('404') ? loadable(() => import(`~atoms/not-found`)) : null;
12
14
 
13
15
  return (
14
16
  <main className={styles.modulePage}>
15
17
  {NotFound && <NotFound />}
18
+ {HtmlSitemap && <HtmlSitemap pageContext={pageContext} />}
16
19
  {section.modules &&
17
20
  section.modules.map((module) => (
18
21
  <Module key={keygen()} module={module} page={page} pageContext={pageContext} />
@@ -10,16 +10,16 @@ const section = {
10
10
  modules: [
11
11
  {
12
12
  name: 'content',
13
- ...getSingleContentData()
13
+ ...getSingleContentData(),
14
14
  },
15
15
  ],
16
16
  };
17
17
 
18
- const pagePath = 's';
18
+ const pageObject = { page: { path: 's' } };
19
19
 
20
20
  describe('Main Component', () => {
21
21
  test('render main', async () => {
22
- const { container, getByText } = render(<Main section={section} pagePath={pagePath} />);
22
+ const { container, getByText } = render(<Main section={section} pageContext={pageObject} />);
23
23
  expect(container).toBeTruthy();
24
24
  expect(container.querySelectorAll('main.modulePage')).toHaveLength(1);
25
25
 
@@ -24,7 +24,7 @@ function Body({ pageContext, children }) {
24
24
  <>
25
25
  {navigation && <Navigation template={template} section={navigation} />}
26
26
  {!is404 && <Header section={pageContext} />}
27
- {main && !children && <Main section={main} page={pageContext.page} />}
27
+ {main && !children && <Main section={main} pageContext={pageContext} />}
28
28
  {children && <main>{children}</main>}
29
29
  {Sidebar && <Sidebar section={sidebar} />}
30
30
  <ScrollToTop />
@@ -77,6 +77,12 @@
77
77
  --second-table-background: var(--color-17);
78
78
  --secondary-module-background: var(--color-42);
79
79
 
80
+ // HTML Sitemap
81
+ --template-name-icon-background: #ff893f;
82
+ --page-number-background: #393939;
83
+ --page-number-color: #fff;
84
+ --sitemap-background-color: #fff;
85
+
80
86
  --storybook-soccer: var(--color-45);
81
87
  --storybook-tennis: var(--color-46);
82
88
  --storybook-handball: var(--color-47);
@@ -1,21 +0,0 @@
1
-
2
- .container {
3
- display: flex;
4
- flex-flow: row;
5
- }
6
-
7
- .list {
8
- display: flex;
9
- flex-direction: column;
10
-
11
- padding: 1rem;
12
-
13
- > div {
14
- font-weight: 700;
15
- font-size: 1.6rem;
16
- }
17
-
18
- >ul {
19
- padding-top: 2rem;
20
- }
21
- }