gatsby-core-theme 1.2.5 → 1.2.6

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.2.6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.2.5...v1.2.6) (2021-10-12)
2
+
3
+
4
+ ### Code Refactoring
5
+
6
+ * add once property to lazy images ([8487472](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/84874723d6f43816b2791f93ef75709f8bff393c))
7
+ * add once property to link-list to be passed to lazyload images ([2bbe3a0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2bbe3a0ede23f2eb49f6e293b7e247ded6b695fe))
8
+
9
+
10
+ * Merge branch 'tm-2496-once-lazy-images' into 'master' ([dea0f3c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/dea0f3cb167bd8163c373990988613648c088508))
11
+
1
12
  ## [1.2.5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.2.4...v1.2.5) (2021-10-11)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,3 +1,5 @@
1
+ /* eslint-disable arrow-body-style */
2
+ /* eslint-disable no-nested-ternary */
1
3
  import React from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
 
@@ -16,6 +18,9 @@ const LinkList = ({
16
18
  listIcon = <></>,
17
19
  multiIcon = false,
18
20
  classes,
21
+ once = false,
22
+ height,
23
+ width,
19
24
  }) => {
20
25
  function renderLinkContent(item, index) {
21
26
  const icon = listIcon[index];
@@ -25,10 +30,26 @@ const LinkList = ({
25
30
  <>
26
31
  {multiIcon ? icon : listIcon}
27
32
  <span>{item.title}</span>
28
- {item.image && <LazyImage src={imagePrettyUrl(item.image)} alt={item.title} />}
33
+ {item.image && (
34
+ <LazyImage
35
+ src={imagePrettyUrl(item.image)}
36
+ alt={item.title}
37
+ once={once}
38
+ width={width}
39
+ height={height}
40
+ />
41
+ )}
29
42
  </>
30
43
  )}
31
- {item.image && imageOnly && <LazyImage src={imagePrettyUrl(item.image)} alt={item.title} />}
44
+ {item.image && imageOnly && (
45
+ <LazyImage
46
+ src={imagePrettyUrl(item.image)}
47
+ alt={item.title}
48
+ once={once}
49
+ width={width}
50
+ height={height}
51
+ />
52
+ )}
32
53
  </>
33
54
  );
34
55
  }
@@ -102,6 +123,9 @@ LinkList.propTypes = {
102
123
  listIcon: PropTypes.oneOfType([PropTypes.element, PropTypes.any, PropTypes.node]),
103
124
  multiIcon: PropTypes.bool,
104
125
  classes: PropTypes.string,
126
+ once: PropTypes.bool,
127
+ width: PropTypes.number,
128
+ height: PropTypes.number,
105
129
  };
106
130
 
107
131
  export default LinkList;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
+
2
3
  import {
3
4
  Title,
4
5
  Description,
5
6
  Primary,
6
7
  PRIMARY_STORY,
7
8
  ArgsTable,
9
+ // eslint-disable-next-line import/no-extraneous-dependencies
8
10
  } from '@storybook/addon-docs/blocks';
9
11
  import { FaChevronRight } from 'react-icons/fa';
10
12
 
@@ -68,6 +70,38 @@ export default {
68
70
  type: null,
69
71
  },
70
72
  },
73
+ once: {
74
+ name: 'once',
75
+ type: { name: 'boolean', required: false },
76
+ defaultValue: '',
77
+ description:
78
+ 'When set to True, once this component is loaded, LazyLoad will not care about it anymore',
79
+ table: {
80
+ type: { summary: 'boolean' },
81
+ defaultValue: { summary: false },
82
+ },
83
+ },
84
+ height: {
85
+ name: 'height',
86
+ type: { name: 'number', required: false },
87
+ defaultValue: '',
88
+ description:
89
+ 'Lazy loading images is supported out of box, no extra config needed, set `height` for better experience',
90
+ table: {
91
+ type: { summary: 'number' },
92
+ defaultValue: { summary: '' },
93
+ },
94
+ },
95
+ width: {
96
+ name: 'width',
97
+ type: { name: 'number', required: false },
98
+ defaultValue: '',
99
+ description: 'set width to the image',
100
+ table: {
101
+ type: { summary: 'number' },
102
+ defaultValue: { summary: '' },
103
+ },
104
+ },
71
105
  },
72
106
  parameters: {
73
107
  docs: {
@@ -133,4 +167,6 @@ Default.args = {
133
167
  },
134
168
  ],
135
169
  },
170
+ height: 30,
171
+ width: 40,
136
172
  };
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from 'react';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
3
  import LazyLoad from 'react-lazyload';
3
4
  import PropTypes from 'prop-types';
4
5
 
@@ -16,6 +17,7 @@ export default function LazyImage({
16
17
  alt = '',
17
18
  sizes,
18
19
  defaultImg,
20
+ once = false,
19
21
  }) {
20
22
  const [errorImage, setErrorImage] = useState(false);
21
23
 
@@ -24,7 +26,7 @@ export default function LazyImage({
24
26
  }
25
27
 
26
28
  return (
27
- <LazyLoad height={`${height}px`} width={`${width}px`} offset={offset} debounce={0}>
29
+ <LazyLoad height={`${height}px`} width={`${width}px`} offset={offset} debounce={0} once={once}>
28
30
  <img
29
31
  src={src}
30
32
  className={className}
@@ -51,4 +53,5 @@ LazyImage.propTypes = {
51
53
  sizes: PropTypes.string,
52
54
  srcSet: PropTypes.string,
53
55
  defaultImg: PropTypes.element,
56
+ once: PropTypes.bool,
54
57
  };
@@ -7,6 +7,7 @@ import {
7
7
  Stories,
8
8
  PRIMARY_STORY,
9
9
  ArgsTable,
10
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
11
  } from '@storybook/addon-docs/blocks';
11
12
  import { FaRegFrownOpen } from 'react-icons/fa';
12
13
 
@@ -122,6 +123,17 @@ export default {
122
123
  type: null,
123
124
  },
124
125
  },
126
+ once: {
127
+ name: 'once',
128
+ type: { name: 'boolean', required: false },
129
+ defaultValue: '',
130
+ description:
131
+ 'When set to True, once this component is loaded, LazyLoad will not care about it anymore',
132
+ table: {
133
+ type: { summary: 'boolean' },
134
+ defaultValue: { summary: false },
135
+ },
136
+ },
125
137
  },
126
138
  parameters: {
127
139
  docs: {
@@ -172,5 +184,6 @@ BrokenURL.story = {
172
184
  srcSet: '',
173
185
  alt: 'This image has a broken URL',
174
186
  defaultImg: <FaRegFrownOpen size={250} />,
187
+ once: false,
175
188
  },
176
189
  };