gatsby-core-theme 2.1.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ # [2.2.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v2.1.0...v2.2.0) (2022-01-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add track background color ([8886659](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/888665908dc7a97e008d42321e1a61482d1d31d8))
7
+ * add variable thumb-color ([7d0d1da](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7d0d1da9f6244573fa38dca0fbc463ceb0e5840d))
8
+ * dmca ([a320701](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a320701a80b61e1a354fcc295f531d763b683261))
9
+ * fixes ([3886daf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3886daf5e8771ae69e4379a440ed944b23d39ae6))
10
+ * menu item, cards row gap ([6fca1e4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6fca1e4f9117bd0d84c143ba57eb0531b467327b))
11
+ * menu item, cards row gap ([cd319ca](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cd319ca0f4efa1845e5cf2df1e22644dd366e312))
12
+ * placeholder ([8c9b5bd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8c9b5bdaef7173406689e3e210e586b237d46ba3))
13
+ * relocate placeholders to processor ([96c17f6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/96c17f636abc652013d0bf396b3a496a167748ea))
14
+ * removed slider from anchor module ([185975f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/185975f75a3f6a592a4477d772ccf148e17e07ce))
15
+ * small fixes ([cc29dfa](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cc29dfa365105bbaae1b14c0b9641d2d936c1ffe))
16
+ * use generateplaceholder for sitemap titles ([9e3ef4e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9e3ef4ee5f8f0c5dff129f2da8a50f3997215feb))
17
+
18
+
19
+ ### Code Refactoring
20
+
21
+ * move replacePlaceholder to gatsby node esm ([9eb9d84](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9eb9d842f2ef1496550348a502d1323ce1552475))
22
+ * update counter li key prop ([8796b36](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8796b361618e44347e1250943e2d31a6b8977b09))
23
+ * update generators tests ([39dd1f5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/39dd1f5e24f7e79abbaf98793be83ede80ca7a14))
24
+ * update placeholder generation in gatsby-node.esm, processSitemapPages and generatePlaceholderString ([52ae3fe](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/52ae3fe551d4520296be05302df58a1880f46970))
25
+ * update processSitemapPages for tests and remove generatePlaceholderString import ([3b73cb8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3b73cb84a2d4d00ceb625aa0f21a4416990dfc34))
26
+ * update siteInfo check for node process ([6940762](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/69407626dda1f4541b86589c2f738929363ddb09))
27
+
28
+
29
+ * Merge branch 'tm-2625-dmca' into 'master' ([d75e192](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d75e1927e5c8eac06426c43b5e18396202359b72))
30
+ * Merge branch 'tm-2654-minor-fixes' into 'master' ([d207bd6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d207bd6a376d390714c157f82f98ccdca3334844))
31
+ * Merge branch 'tm-2656-placeholder' into 'master' ([92d1b1b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/92d1b1b36f733f9b880750b36aa710bd5bba536a))
32
+ * Merge branch 'tm-2557-cards-v2-changes' into 'master' ([bd5c28f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/bd5c28f764cb38a949d0638d6bf4782a7ad9de14))
33
+ * Merge branch 'tm-2655-anchor-module' into 'master' ([4748e7a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4748e7a8458003eea7c8dd0c163fb338dcd2f173))
34
+ * Merge branch 'tm-2656-fix-placeholders' into 'master' ([b8a06f3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b8a06f3cc24fc39df0ca949c404c41ed69a13ad8))
35
+
36
+
37
+ ### Features
38
+
39
+ * cards v2 filters cvhanges ([b0f3a96](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b0f3a96cc784fcf432cee9c14b63574df362e05f))
40
+
1
41
  # [2.1.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v2.0.19...v2.1.0) (2022-01-13)
2
42
 
3
43
 
@@ -5,7 +5,7 @@
5
5
  import { cloneDeep, chunk, pick } from 'lodash';
6
6
  import chalk from 'chalk';
7
7
  import { getData, getLocalData } from './src/helpers/api';
8
- import { generatePlaceholderString, generateTrackerLink } from './src/helpers/generators';
8
+ import { generateTrackerLink } from './src/helpers/generators';
9
9
  import processor, { processSitemapPages } from './src/helpers/processor';
10
10
  import { pickAuthorsPageKeys } from './src/constants/pick-keys';
11
11
 
@@ -150,13 +150,13 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
150
150
  // add data to modules
151
151
  const processed = processor.run(response, themeOptions, fs);
152
152
  pages = processed.pages;
153
- htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
154
153
  siteInfo = processed.general;
155
154
  operators = processed.relations.operator;
156
155
  templates = processed.templates;
157
156
  // eslint-disable-next-line prefer-destructuring
158
157
  languageKey = Object.keys(processed.relations.translations)[0];
159
158
  translations = processed.relations.translations[languageKey];
159
+ htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
160
160
 
161
161
  if (themeOptions.siteType === 'sport') {
162
162
  sports = Object.keys(response.relations['sports_data'].sports).map(
@@ -204,26 +204,6 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
204
204
  pick(authors[key], pickAuthorsPageKeys)
205
205
  );
206
206
 
207
- // replacing string placehoders with year, month, date, etc.
208
- page.title =
209
- page.title &&
210
- generatePlaceholderString(page.title, translations, {
211
- siteName: response.general.site_name,
212
- siteTitle: page.title,
213
- });
214
- page.meta_title =
215
- page.meta_title &&
216
- generatePlaceholderString(page.meta_title, translations, {
217
- siteName: response.general.site_name,
218
- siteTitle: page.title,
219
- });
220
- page.meta_description =
221
- page.meta_description &&
222
- generatePlaceholderString(page.meta_description, translations, {
223
- siteName: response.general.site_name,
224
- siteTitle: page.title,
225
- });
226
-
227
207
  if (hasArchiveModule(page)) {
228
208
  createArchivePage(page, marketSections, prefilledModules, createPage);
229
209
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -15,8 +15,8 @@ const dmcaImg = (
15
15
  describe('Disclaimer Component', () => {
16
16
  test('render disclaimer badge', () => {
17
17
  const { container } = render(<Disclaimer image={dmcaImg} />);
18
- expect(container.querySelectorAll('.lazyload-placeholder')).toHaveLength(1);
19
- expect(container.querySelector('div')).toBeTruthy();
18
+ expect(container.querySelectorAll('a')).toHaveLength(1);
19
+ expect(container.querySelectorAll('img')).toHaveLength(1);
20
20
  });
21
21
  });
22
22
  afterEach(() => {
@@ -1,21 +1,42 @@
1
- import React from 'react';
1
+ /* eslint-disable no-return-assign */
2
+ /* eslint-disable no-plusplus */
3
+ /* eslint-disable no-var */
4
+ import React, { useRef } from 'react';
2
5
  import PropTypes from 'prop-types';
3
- import LazyLoad from 'react-lazyload';
4
6
 
5
- const Disclaimer = ({ image }) => (
6
- <LazyLoad>
7
- <a
8
- href="//www.dmca.com/Protection/Status.aspx?ID=9e466e76-827d-4247-ac51-4eb75b227301"
9
- title="DMCA.com Protection Status"
10
- className="dmca-badge"
11
- target="_blank"
12
- rel="noreferrer"
13
- >
14
- {image}
15
- </a>
16
- <script src="https://images.dmca.com/Badges/DMCABadgeHelper.min.js"> </script>
17
- </LazyLoad>
18
- );
7
+ const Disclaimer = ({ image }) => {
8
+ const anchorElement = useRef(null);
9
+
10
+ function dmca() {
11
+ document.addEventListener(
12
+ 'click',
13
+ () => {
14
+ const element = anchorElement.current;
15
+ if (element.getAttribute('href').indexOf('refurl') < 0) {
16
+ element.href = `${`${
17
+ element.href + (element.href.indexOf('?') === -1 ? '?' : '&')
18
+ }refurl`}=${document.location}`;
19
+ }
20
+ },
21
+ false
22
+ );
23
+ }
24
+
25
+ return (
26
+ <>
27
+ <a
28
+ ref={anchorElement}
29
+ onClick={dmca}
30
+ href="//www.dmca.com/Protection/Status.aspx?ID=9e466e76-827d-4247-ac51-4eb75b227301"
31
+ title="DMCA.com Protection Status"
32
+ target="_blank"
33
+ rel="noreferrer"
34
+ >
35
+ {image}
36
+ </a>
37
+ </>
38
+ );
39
+ };
19
40
 
20
41
  export default Disclaimer;
21
42
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-nested-ternary */
1
2
  import React, { useState, useEffect, useContext } from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import Link from '~hooks/link';
@@ -63,7 +64,7 @@ export default function Item({
63
64
  {item.value?.includes('http') || item.value?.includes('www') ? (
64
65
  <a
65
66
  aria-label={`${item?.title} link`}
66
- href={item.value}
67
+ href={item.value ? item.value : '#'}
67
68
  title={item.title}
68
69
  rel={`noreferrer ${item.nofollow && 'nofollow'}`}
69
70
  target="_blank"
@@ -78,7 +79,7 @@ export default function Item({
78
79
  <ItemImage />
79
80
  {item.title}
80
81
  </a>
81
- ) : (
82
+ ) : item.value !== null ? (
82
83
  <Link
83
84
  className={`${gtmClass} ${styles.item} ${opened && styles.openedLink} ${active} ${
84
85
  !options.mobile.subMenuDropDownButton && isMobile && hasChildren
@@ -87,7 +88,8 @@ export default function Item({
87
88
  } ${hasChildren ? styles.hasChildren : ''} ${
88
89
  !options.mobile.subMenuDropDownButton ? styles.noDropDownButton : ''
89
90
  }`}
90
- to={item.value ? item.value : '#'}
91
+ disabled={item.value === null}
92
+ to={item.value}
91
93
  title={item.title}
92
94
  rel={item.nofollow && 'nofollow'}
93
95
  aria-label={`${item?.title} link`}
@@ -96,6 +98,8 @@ export default function Item({
96
98
  <ItemImage />
97
99
  {item.title}
98
100
  </Link>
101
+ ) : (
102
+ <div className={styles.item}>{item.title}</div>
99
103
  )}
100
104
  {options.mobile.subMenuDropDownButton && isMobile && hasChildren && (
101
105
  <button
@@ -15,8 +15,8 @@ const Counter = ({ module }) => (
15
15
  <ul className={styles.counter}>
16
16
  {module.items.map((item) => {
17
17
  return (
18
- <li>
19
- <CounterItem data={item} key={keygen()} />;
18
+ <li key={keygen()}>
19
+ <CounterItem data={item} />;
20
20
  </li>
21
21
  );
22
22
  })}
@@ -1,13 +1,26 @@
1
- .sliderWrapper {
1
+ .anchor {
2
+ @include flex-direction(row);
3
+ &::-webkit-scrollbar {
4
+ height: 0.5rem;
5
+ }
6
+ &::-webkit-scrollbar-track {
7
+ background: var(--anchor-track-color);
8
+ }
9
+ &::-webkit-scrollbar-thumb {
10
+ background: var(--anchor-thumb-color);
11
+ }
12
+ overflow-x: scroll;
2
13
  .link {
3
14
  word-break: inherit;
4
15
  white-space: nowrap;
5
-
16
+ margin-bottom: 0.5rem;
6
17
  background-color: var(--color-7);
7
18
  padding: 1rem 2.5rem;
8
19
  border-radius: 0.6rem;
9
20
  color: #000;
10
21
  font-weight: 400;
22
+ margin-right: 1.6rem;
23
+ margin-bottom: 0.5rem;
11
24
 
12
25
  &:hover {
13
26
  background-color: var(--secondary-color);
@@ -15,10 +28,10 @@
15
28
  }
16
29
  }
17
30
  }
18
- .storyDivs{
31
+ .storyDivs {
19
32
  width: 100%;
20
33
  display: block;
21
34
  margin: 3rem 0;
22
35
  background-color: #eee;
23
36
  padding: 2rem;
24
- }
37
+ }
@@ -1,12 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- import Slider from '~molecules/slider';
5
4
  import keygen from '~helpers/keygen';
6
5
  import { anchorLink } from '~helpers/strings';
7
6
  import styles from './anchor.module.scss';
8
7
 
9
- function Anchor({ module: { items }, headerOffset = 80, sliderGap = 0 }) {
8
+ function Anchor({ module: { items }, headerOffset = 80 }) {
10
9
  const handleClick = (event) => {
11
10
  event.preventDefault();
12
11
  const scrollToElementId = event.currentTarget.getAttribute('href').replace('#', '');
@@ -23,13 +22,7 @@ function Anchor({ module: { items }, headerOffset = 80, sliderGap = 0 }) {
23
22
  };
24
23
 
25
24
  return (
26
- <Slider
27
- useArrows={false}
28
- usePagination={false}
29
- settings={{ numberOfSlides: 0, sliderGap }}
30
- className={styles.sliderWrapper}
31
- gtmClass="anchor-carousel-gtm"
32
- >
25
+ <div className={styles.anchor} gtmClass="anchor-carousel-gtm">
33
26
  {items.map((anchor) => (
34
27
  <a
35
28
  className={`${styles.link} anchor-carousel-gtm anchor-menu-gtm`}
@@ -40,7 +33,7 @@ function Anchor({ module: { items }, headerOffset = 80, sliderGap = 0 }) {
40
33
  {anchor?.label}
41
34
  </a>
42
35
  ))}
43
- </Slider>
36
+ </div>
44
37
  );
45
38
  }
46
39
 
@@ -53,7 +46,6 @@ Anchor.propTypes = {
53
46
  ),
54
47
  }).isRequired,
55
48
  headerOffset: PropTypes.number.isRequired,
56
- sliderGap: PropTypes.number,
57
49
  styles: PropTypes.shape({}),
58
50
  };
59
51
 
@@ -13,6 +13,8 @@
13
13
  grid-template-columns: repeat(var(--cards-desktop-column), minmax(0,1fr));
14
14
  }
15
15
  column-gap: 0.8rem;
16
+ row-gap: 1rem;
17
+
16
18
  @include min(desktop) {
17
19
  column-gap: 1.6rem;
18
20
  }
@@ -21,7 +21,7 @@ export function generateTrackerLink(operator, trackerType) {
21
21
  }
22
22
  }
23
23
 
24
- export function generatePlaceholderString(string, translations, props) {
24
+ export function generatePlaceholderString(string = '', translations, data) {
25
25
  const date = new Date();
26
26
  const day = date.getDate();
27
27
  const month = months[date.getMonth()];
@@ -38,8 +38,8 @@ export function generatePlaceholderString(string, translations, props) {
38
38
  '[currentdate]': `${(translations && translations[month]) || month} ${day}, ${year}`,
39
39
  '[currentmonth]': (translations && translations[month]) || month,
40
40
  '[currentyear]': year,
41
- '[sitename]': (props && props.siteName) || '',
42
- '[title]': (props && props.siteTitle) || '',
41
+ '[sitename]': (data && data.siteName) || '',
42
+ '[title]': (data && data.pageTitle) || '',
43
43
  }[match])
44
44
  );
45
45
  }
@@ -32,7 +32,7 @@ describe('Generate Placeholders String', () => {
32
32
  null,
33
33
  {
34
34
  siteName: 'Site Name',
35
- siteTitle: 'Site Title',
35
+ pageTitle: 'Site Title',
36
36
  }
37
37
  );
38
38
  const date = new Date();
@@ -4,7 +4,7 @@ import settings from '../../constants/settings';
4
4
  // eslint-disable-next-line import/no-cycle
5
5
  import { processExtraFields } from '.';
6
6
 
7
- export function groupBy(list, keyName = 'author_id', single = false) {
7
+ export function groupBy(list = {}, keyName = 'author_id', single = false) {
8
8
  const newObj = Object.values(list).reduce((acc, currentVal) => {
9
9
  if (!acc[currentVal[keyName]]) {
10
10
  acc[currentVal[keyName]] = [];
@@ -8,7 +8,7 @@ import chalk from 'chalk';
8
8
  import ModuleValue from '../../constants/module-value';
9
9
  import SearchTypesEnable from '../../constants/search-types-enable';
10
10
  import { pickHTMLSitemapPageKeys } from '../../constants/pick-keys';
11
-
11
+ import { generatePlaceholderString } from '../generators';
12
12
  // eslint-disable-next-line import/no-cycle
13
13
  import { processModule } from './modules';
14
14
  // eslint-disable-next-line import/no-cycle
@@ -131,6 +131,31 @@ export function processExtraFields(extraFields) {
131
131
  });
132
132
  }
133
133
 
134
+ function updatePlaceholders(page, data) {
135
+ const languageKey = Object.keys(data.relations.translations)[0];
136
+ const translations = data.relations.translations[languageKey];
137
+
138
+ // replacing string placehoders with year, month, date, etc.
139
+ page.title =
140
+ page.title &&
141
+ generatePlaceholderString(page.title, translations, {
142
+ siteName: data.general.site_name,
143
+ siteTitle: page.title,
144
+ });
145
+ page.meta_title =
146
+ page.meta_title &&
147
+ generatePlaceholderString(page.meta_title, translations, {
148
+ siteName: data.general.site_name,
149
+ siteTitle: page.title,
150
+ });
151
+ page.meta_description =
152
+ page.meta_description &&
153
+ generatePlaceholderString(page.meta_description, translations, {
154
+ siteName: data.general.site_name,
155
+ siteTitle: page.title,
156
+ });
157
+ }
158
+
134
159
  export default {
135
160
  run(data, themeOptions, fs) {
136
161
  const start = new Date();
@@ -163,6 +188,7 @@ export default {
163
188
  transformedPages[market][pageType].forEach((page, index) => {
164
189
  // process page extra fields
165
190
  processExtraFields(page.extra_fields);
191
+ updatePlaceholders(page, data);
166
192
 
167
193
  // set page relation
168
194
  if (
@@ -114,19 +114,25 @@ export function processCardsV2(module, pagesCloned, pagesMappedById) {
114
114
  pagesMappedById[page_id] && module.items.push(pagesMappedById[page_id]);
115
115
  });
116
116
  } else if (cardSelector === 'use_filters') {
117
- // Get all pages by the selected page type
118
- const pagesGroupedByType = pagesCloned[pageType];
117
+ let pagesList = [];
119
118
 
120
- // Grouping pages by template ID
121
- if (!pagesGroupedByTemplateId[pageType]) {
122
- pagesGroupedByTemplateId[pageType] = groupBy(pagesGroupedByType, 'template_id');
123
- }
119
+ if (pageType) {
120
+ // Get all pages by the selected page type
121
+ const pagesGroupedByType = pagesCloned[pageType];
122
+
123
+ // Grouping pages by template ID
124
+ if (!pagesGroupedByTemplateId[pageType]) {
125
+ pagesGroupedByTemplateId[pageType] = groupBy(pagesGroupedByType, 'template_id');
126
+ }
124
127
 
125
- // Populate pagesList if page type and template exists
126
- const pagesList =
127
- !pagesGroupedByTemplateId[pageType] || !pagesGroupedByTemplateId[pageType][pageTemplateId]
128
- ? []
129
- : pagesGroupedByTemplateId[pageType][pageTemplateId];
128
+ // Populate pagesList if page type and template exists
129
+ pagesList =
130
+ !pagesGroupedByTemplateId[pageType] || !pagesGroupedByTemplateId[pageType][pageTemplateId]
131
+ ? []
132
+ : pagesGroupedByTemplateId[pageType][pageTemplateId];
133
+ } else {
134
+ pagesList = pagesMappedById.map((page) => page);
135
+ }
130
136
 
131
137
  // Check if there are pages before starting filtering
132
138
  if (pagesList.length > 0) {