sfc-utils 1.3.66 → 1.3.67
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/components/captioncredit.mjs +21 -21
- package/components/ogpubdate.mjs +18 -0
- package/components/slideshow/captioncreditslideshow.mjs +7 -4
- package/components/slideshow/imageslideshow.mjs +17 -2
- package/components/topper2.mjs +184 -23
- package/components/topperimage.mjs +7 -2
- package/example/gatsby-node.js +3 -4
- package/example/package-lock.json +18566 -133
- package/example/src/pages/index.js +2 -0
- package/package.json +1 -1
- package/settings.js +1 -1
- package/styles/brandStylesCommon.less +5 -9
- package/styles/modules/imageslideshow.module.less +45 -0
- package/styles/modules/topper2.module.less +239 -0
- package/styles/modules/topperimage.module.less +85 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
// import * as capcredStyles from "../styles/modules/captioncredit.module.less"
|
|
3
2
|
|
|
4
|
-
const CaptionCredit = (
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const CaptionCredit = ({ caption, credit, extraStyles, creditStyles = [] }) => {
|
|
4
|
+
let captionCss = ["topper-image", "caption"];
|
|
5
|
+
if (extraStyles) {
|
|
6
|
+
captionCss = captionCss.concat(extraStyles);
|
|
7
|
+
}
|
|
9
8
|
|
|
9
|
+
let creditCss = `credit ${creditStyles.join(" ")}`
|
|
10
10
|
return (
|
|
11
11
|
<>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
{caption && credit && (
|
|
13
|
+
<figcaption className={captionCss.join(' ')}>
|
|
14
|
+
{caption} <span className={creditCss}>{credit}</span>
|
|
15
|
+
</figcaption>
|
|
16
|
+
)}
|
|
17
|
+
{!caption && credit && (
|
|
18
|
+
<figcaption className={captionCss.join(' ')}>
|
|
19
|
+
<span className={creditCss}>{credit}</span>
|
|
20
|
+
</figcaption>
|
|
21
|
+
)}
|
|
22
|
+
{caption && !credit && (
|
|
23
|
+
<figcaption className={captionCss.join(' ')}>
|
|
24
|
+
{caption}
|
|
25
|
+
</figcaption>
|
|
26
|
+
)}
|
|
27
27
|
</>
|
|
28
28
|
)
|
|
29
29
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
pubdateString,
|
|
5
|
+
moddateString
|
|
6
|
+
} from './helpers/datehelpers.mjs'
|
|
7
|
+
|
|
8
|
+
const OgPubDate = ({ settings }) => {
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{moddateString &&
|
|
12
|
+
<p><i>Originally published on {pubdateString}</i></p>
|
|
13
|
+
}
|
|
14
|
+
</>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default OgPubDate
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from "react"
|
|
2
2
|
|
|
3
|
-
const CaptionCreditSlideshow = ({ captionList, creditList, extraStyles }) => {
|
|
3
|
+
const CaptionCreditSlideshow = ({ captionList, creditList, extraStyles, creditStyles = [] }) => {
|
|
4
4
|
let captionCss = ["topper-image", "caption"];
|
|
5
|
-
if (extraStyles)
|
|
5
|
+
if (extraStyles) {
|
|
6
|
+
captionCss = extraStyles.concat(captionCss);
|
|
7
|
+
}
|
|
6
8
|
|
|
7
9
|
const [index, setIndex] = useState(0);
|
|
8
10
|
const timeoutRef = useRef(null);
|
|
@@ -29,16 +31,17 @@ const CaptionCreditSlideshow = ({ captionList, creditList, extraStyles }) => {
|
|
|
29
31
|
|
|
30
32
|
const hasCaption = (captionList.length > 0)
|
|
31
33
|
const hasCredit = (creditList.length > 0)
|
|
34
|
+
let creditCss = `credit ${creditStyles.join(" ")}`
|
|
32
35
|
return (
|
|
33
36
|
<>
|
|
34
37
|
{hasCaption && hasCredit && (
|
|
35
38
|
<figcaption className={captionCss.join(' ')}>
|
|
36
|
-
{captionList[index]} <span className=
|
|
39
|
+
{captionList[index]} <span className={creditCss}>{creditList[index]}</span>
|
|
37
40
|
</figcaption>
|
|
38
41
|
)}
|
|
39
42
|
{!hasCaption && hasCredit && (
|
|
40
43
|
<figcaption className={captionCss.join(' ')}>
|
|
41
|
-
<span className=
|
|
44
|
+
<span className={creditCss}>{creditList[index]}</span>
|
|
42
45
|
</figcaption>
|
|
43
46
|
)}
|
|
44
47
|
{hasCaption && !hasCredit && (
|
|
@@ -4,7 +4,7 @@ import * as styles from "../../styles/modules/imageslideshow.module.less"
|
|
|
4
4
|
import * as imageStyles from "../../styles/modules/topperimage.module.less"
|
|
5
5
|
import { TransitionGroup, CSSTransition } from "react-transition-group"
|
|
6
6
|
|
|
7
|
-
const ImageSlideshow = ({ wcmData, imageList, altList, topperStyle }) => {
|
|
7
|
+
const ImageSlideshow = ({ wcmData, imageList, altList, topperStyle, isLayoutInverted = false }) => {
|
|
8
8
|
const [index, setIndex] = useState(0);
|
|
9
9
|
const timeoutRef = useRef(null);
|
|
10
10
|
|
|
@@ -31,7 +31,6 @@ const ImageSlideshow = ({ wcmData, imageList, altList, topperStyle }) => {
|
|
|
31
31
|
const getContainerClass = () => {
|
|
32
32
|
switch (topperStyle) {
|
|
33
33
|
case "stacked":
|
|
34
|
-
return styles.containerStacked;
|
|
35
34
|
case "full-screen":
|
|
36
35
|
return styles.containerStacked;
|
|
37
36
|
default:
|
|
@@ -45,6 +44,10 @@ const ImageSlideshow = ({ wcmData, imageList, altList, topperStyle }) => {
|
|
|
45
44
|
return styles.imageWrapperStacked;
|
|
46
45
|
case "full-screen":
|
|
47
46
|
return styles.imageWrapperFullscreen;
|
|
47
|
+
case "side-by-side":
|
|
48
|
+
return styles.imageWrapperSideBySide;
|
|
49
|
+
case "side-by-side-portrait":
|
|
50
|
+
return styles.imageWrapperSideBySidePortrait;
|
|
48
51
|
default:
|
|
49
52
|
return "";
|
|
50
53
|
}
|
|
@@ -56,6 +59,18 @@ const ImageSlideshow = ({ wcmData, imageList, altList, topperStyle }) => {
|
|
|
56
59
|
return [imageStyles.cForceAspectRatio];
|
|
57
60
|
case "full-screen":
|
|
58
61
|
return [imageStyles.cImgSlideshowFullscreen];
|
|
62
|
+
case "side-by-side":
|
|
63
|
+
return [imageStyles.cImgSlideshowSideBySide].concat(
|
|
64
|
+
// Add styling for left padding on topper image
|
|
65
|
+
(isLayoutInverted) ? [imageStyles.cLargePaddingLeft] : [imageStyles.cLargePaddingRight]
|
|
66
|
+
);
|
|
67
|
+
case "side-by-side-portrait":
|
|
68
|
+
return [imageStyles.cImgSlideshowSideBySidePortrait].concat(
|
|
69
|
+
[
|
|
70
|
+
// Add styling for left padding on image caption
|
|
71
|
+
(isLayoutInverted) ? [] : [styles.sideBySidePortraitMarginLeft]
|
|
72
|
+
]
|
|
73
|
+
);
|
|
59
74
|
default:
|
|
60
75
|
return [""];
|
|
61
76
|
}
|
package/components/topper2.mjs
CHANGED
|
@@ -10,7 +10,9 @@ import * as imageStyles from "../styles/modules/topperimage.module.less"
|
|
|
10
10
|
const Topper2 = ({ settings, wcmData }) => {
|
|
11
11
|
const {
|
|
12
12
|
Topper_Style, Title, Title_Style, Deck, Image, Image_Alt, Image_Caption, Image_Credits,
|
|
13
|
-
HeaderDek_Vertical_Position, HeaderDek_Vertical_Offset, HeaderDek_Horizontal_Offset,
|
|
13
|
+
HeaderDek_Vertical_Position, HeaderDek_Vertical_Offset, HeaderDek_Horizontal_Offset,
|
|
14
|
+
HeaderDek_Horizontal_Position, Inverted_Colors, Inverted_Layout, Inverted_Text_Color,
|
|
15
|
+
Topper_Background_Color
|
|
14
16
|
} = settings
|
|
15
17
|
|
|
16
18
|
const headerDekStyleList = () => {
|
|
@@ -35,6 +37,19 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
35
37
|
... (Inverted_Colors === "black-text-white-bg") ? [topperStyles.blackTextWhiteBg] : [topperStyles.whiteTextBlackBg]
|
|
36
38
|
];
|
|
37
39
|
case "side-by-side":
|
|
40
|
+
return [
|
|
41
|
+
topperStyles.headerDekSideBySide,
|
|
42
|
+
// Add styling for left padding on header-deck
|
|
43
|
+
... (Inverted_Layout === "headerdek-right-image-left") ? [topperStyles.largePaddingRight] : [topperStyles.largePaddingLeft]
|
|
44
|
+
];
|
|
45
|
+
case "side-by-side-portrait":
|
|
46
|
+
return [
|
|
47
|
+
topperStyles.headerDekSideBySide,
|
|
48
|
+
// Add styling for left padding on header-deck
|
|
49
|
+
... (Inverted_Layout === "headerdek-right-image-left") ? [topperStyles.largePaddingRight] : [topperStyles.largePaddingLeft]
|
|
50
|
+
];
|
|
51
|
+
default:
|
|
52
|
+
console.error(`${Topper_Style} is not a valid topper style!`)
|
|
38
53
|
return [];
|
|
39
54
|
}
|
|
40
55
|
}
|
|
@@ -49,7 +64,7 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
49
64
|
}
|
|
50
65
|
|
|
51
66
|
const headerStyleList = () => {
|
|
52
|
-
let defaultStyles;
|
|
67
|
+
let defaultStyles = [];
|
|
53
68
|
switch (Topper_Style) {
|
|
54
69
|
case "stacked":
|
|
55
70
|
defaultStyles = [];
|
|
@@ -61,7 +76,8 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
61
76
|
defaultStyles = [topperStyles.hedFullScreen, fullScreenTextAlignCss()];
|
|
62
77
|
break;
|
|
63
78
|
case "side-by-side":
|
|
64
|
-
|
|
79
|
+
case "side-by-side-portrait":
|
|
80
|
+
defaultStyles = ["left"];
|
|
65
81
|
break;
|
|
66
82
|
}
|
|
67
83
|
|
|
@@ -83,11 +99,14 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
83
99
|
case "full-screen":
|
|
84
100
|
return ["deck", topperStyles.deckFullScreen, fullScreenTextAlignCss()];
|
|
85
101
|
case "side-by-side":
|
|
86
|
-
|
|
102
|
+
case "side-by-side-portrait":
|
|
103
|
+
return ["deck left"];
|
|
104
|
+
default:
|
|
105
|
+
return [""]
|
|
87
106
|
}
|
|
88
107
|
}
|
|
89
108
|
|
|
90
|
-
/**
|
|
109
|
+
/** Get text alignment based on header-deck position **/
|
|
91
110
|
const fullScreenTextAlignCss = () => {
|
|
92
111
|
switch (HeaderDek_Horizontal_Position) {
|
|
93
112
|
case "left": return topperStyles.textAlignLeft;
|
|
@@ -96,6 +115,27 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
117
|
|
|
118
|
+
/** Add styling for text color on topper slideshow captions. Note that the credits
|
|
119
|
+
* are grey when the caption is black and white when the captions are white. */
|
|
120
|
+
const sideBySideCapCredColorCss = () => {
|
|
121
|
+
return (Inverted_Text_Color === "black") ? topperStyles.captionTextColor : topperStyles.captionTextColorImportant;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Add styling for left padding on topper slideshow captions */
|
|
125
|
+
const sideBySideCapCredPaddingCss = () => {
|
|
126
|
+
return (Inverted_Layout === "headerdek-right-image-left") ? topperStyles.captionLargePaddingLeft : topperStyles.captionLargePaddingRight
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Add styling for left padding on topper slideshow captions */
|
|
130
|
+
const sideBySidePortraitCapCredPaddingCss = () => {
|
|
131
|
+
return (Inverted_Layout === "headerdek-right-image-left") ? topperStyles.captionSmallPaddingLeft : topperStyles.captionSideBySidePortraitPadding;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Add styling for float position for side-by-side-portrait image */
|
|
135
|
+
const sideBySidePortraitFloatCss = () => {
|
|
136
|
+
return (Inverted_Layout === "headerdek-right-image-left") ? topperStyles.floatLeftWhenDesktop : topperStyles.floatRightWhenDesktop;
|
|
137
|
+
}
|
|
138
|
+
|
|
99
139
|
/** Converts wcm string from spreadsheet into a list of WCM ids */
|
|
100
140
|
const getWcmIdList = (listStr) => {
|
|
101
141
|
return listStr.split(";").map((d) => parseInt(d));
|
|
@@ -119,15 +159,52 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
119
159
|
return list;
|
|
120
160
|
}
|
|
121
161
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
162
|
+
/* Returns the corresponding image HTML for each topper style and slideshow status */
|
|
163
|
+
const getImageHTML = (isSlideshow) => {
|
|
164
|
+
if (isSlideshow) return (
|
|
165
|
+
<ImageSlideshow
|
|
166
|
+
wcmData={wcmData}
|
|
167
|
+
imageList={wcmIdList}
|
|
168
|
+
altList={convertStringToList(Image_Alt, wcmIdList.length)}
|
|
169
|
+
topperStyle={Topper_Style}
|
|
170
|
+
isLayoutInverted={(Inverted_Layout === "headerdek-right-image-left")}
|
|
171
|
+
/>
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
switch (Topper_Style) {
|
|
175
|
+
case "stacked":
|
|
176
|
+
return (<TopperImage wcm={Image} alt={Image_Alt} wcmData={wcmData} />)
|
|
177
|
+
case "full-screen":
|
|
178
|
+
return (<TopperImage
|
|
179
|
+
wcm={Image}
|
|
180
|
+
alt={Image_Alt}
|
|
181
|
+
wcmData={wcmData}
|
|
182
|
+
overrideCssList={[imageStyles.cImgFullscreen]}
|
|
183
|
+
/>)
|
|
184
|
+
case "side-by-side":
|
|
185
|
+
return (
|
|
186
|
+
<TopperImage
|
|
187
|
+
wcm={Image}
|
|
188
|
+
alt={Image_Alt}
|
|
189
|
+
wcmData={wcmData}
|
|
190
|
+
containerCssList={[imageStyles.cContainerSideBySide]}
|
|
191
|
+
overrideCssList={[imageStyles.cImgSideBySide]}
|
|
192
|
+
/>)
|
|
193
|
+
case "side-by-side-portrait":
|
|
194
|
+
return (
|
|
195
|
+
<TopperImage
|
|
196
|
+
wcm={Image}
|
|
197
|
+
alt={Image_Alt}
|
|
198
|
+
wcmData={wcmData}
|
|
199
|
+
containerCssList={[imageStyles.cContainerSideBySidePortrait, sideBySidePortraitFloatCss()]}
|
|
200
|
+
overrideCssList={[imageStyles.cImgSideBySidePortrait]}
|
|
201
|
+
/>
|
|
202
|
+
)
|
|
203
|
+
case "no-visual":
|
|
204
|
+
default:
|
|
205
|
+
return null
|
|
206
|
+
}
|
|
207
|
+
}
|
|
131
208
|
|
|
132
209
|
const wcmIdList = getWcmIdList(Image);
|
|
133
210
|
const TopperHtml = () => {
|
|
@@ -138,15 +215,14 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
138
215
|
<>
|
|
139
216
|
<div className={containerCss}>
|
|
140
217
|
<figure className={`topper-image ${topperStyles.imageFullScreen}`} aria-labelledby="topperCaptionText">
|
|
141
|
-
{isSlideshow(wcmIdList)
|
|
142
|
-
{!isSlideshow(wcmIdList) && <FullScreenImageHTML />}
|
|
218
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
143
219
|
|
|
144
220
|
{/* This caption-credit only shows when the screen size is tablet or mobile */}
|
|
145
221
|
{isSlideshow(wcmIdList) &&
|
|
146
222
|
<CaptionCreditSlideshow
|
|
147
223
|
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
148
224
|
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
149
|
-
extraStyles={topperStyles.hideWhenDesktop}
|
|
225
|
+
extraStyles={[topperStyles.hideWhenDesktop]}
|
|
150
226
|
/>
|
|
151
227
|
}
|
|
152
228
|
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={topperStyles.hideWhenDesktop} />}
|
|
@@ -193,8 +269,8 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
193
269
|
/>
|
|
194
270
|
</div>
|
|
195
271
|
<figure className={`mw-xl ml-auto mr-auto ${topperStyles.imageStacked}`}>
|
|
196
|
-
{isSlideshow(wcmIdList)
|
|
197
|
-
|
|
272
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
273
|
+
|
|
198
274
|
{isSlideshow(wcmIdList) &&
|
|
199
275
|
<CaptionCreditSlideshow
|
|
200
276
|
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
@@ -202,7 +278,7 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
202
278
|
extraStyles={[topperStyles.smallPaddingLeftWhenTablet]}
|
|
203
279
|
/>
|
|
204
280
|
}
|
|
205
|
-
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.smallPaddingLeftWhenTablet]}/>}
|
|
281
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.smallPaddingLeftWhenTablet]} />}
|
|
206
282
|
</figure>
|
|
207
283
|
</div>
|
|
208
284
|
</>
|
|
@@ -227,18 +303,90 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
227
303
|
</div>
|
|
228
304
|
</>
|
|
229
305
|
);
|
|
306
|
+
|
|
307
|
+
case "side-by-side":
|
|
308
|
+
let figureCss = isSlideshow(wcmIdList) ? `${topperStyles.imageSideBySideSlideshow}` : `${topperStyles.imageSideBySide}`;
|
|
309
|
+
let sideBySideContainerCss = (Inverted_Layout === "headerdek-right-image-left") ? `${topperStyles.topperContainerSideBySide} ${topperStyles.reverseFlexbox}` : `${topperStyles.topperContainerSideBySide}`;
|
|
310
|
+
setBackgroundAndTextColor();
|
|
311
|
+
return (
|
|
312
|
+
<div className={sideBySideContainerCss}>
|
|
313
|
+
<div className={headerDekStyleList().join(' ')}>
|
|
314
|
+
<Heading
|
|
315
|
+
level={1}
|
|
316
|
+
text={Title}
|
|
317
|
+
className={headerStyleList().join(' ')}
|
|
318
|
+
/>
|
|
319
|
+
<Heading
|
|
320
|
+
level={2}
|
|
321
|
+
text={Deck}
|
|
322
|
+
className={deckStyleList().join(' ')}
|
|
323
|
+
/>
|
|
324
|
+
</div>
|
|
325
|
+
<figure className={figureCss}>
|
|
326
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
327
|
+
|
|
328
|
+
{isSlideshow(wcmIdList) &&
|
|
329
|
+
<CaptionCreditSlideshow
|
|
330
|
+
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
331
|
+
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
332
|
+
extraStyles={[topperStyles.slideshowCaptionSideBySide, sideBySideCapCredColorCss(), sideBySideCapCredPaddingCss()]}
|
|
333
|
+
creditStyles={[sideBySideCapCredColorCss()]}
|
|
334
|
+
/>
|
|
335
|
+
}
|
|
336
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.captionSideBySide, sideBySideCapCredColorCss()]} creditStyles={[sideBySideCapCredColorCss()]} />}
|
|
337
|
+
</figure>
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
case "side-by-side-portrait":
|
|
342
|
+
let portraitFigureCss = isSlideshow(wcmIdList) ? `${topperStyles.imageSideBySidePortraitSlideshow}` : `${topperStyles.imageSideBySidePortrait}`;
|
|
343
|
+
let sideBySidePortraitContainerCss = (Inverted_Layout === "headerdek-right-image-left") ? `${topperStyles.topperContainerSideBySidePortrait} ${topperStyles.reverseFlexbox}` : `${topperStyles.topperContainerSideBySidePortrait}`;
|
|
344
|
+
setBackgroundAndTextColor();
|
|
345
|
+
return (
|
|
346
|
+
<div className={topperStyles.fullWidthContainer}>
|
|
347
|
+
<div className={sideBySidePortraitContainerCss}>
|
|
348
|
+
<div className={headerDekStyleList().join(' ')}>
|
|
349
|
+
<Heading
|
|
350
|
+
level={1}
|
|
351
|
+
text={Title}
|
|
352
|
+
className={headerStyleList().join(' ')}
|
|
353
|
+
/>
|
|
354
|
+
<Heading
|
|
355
|
+
level={2}
|
|
356
|
+
text={Deck}
|
|
357
|
+
className={deckStyleList().join(' ')}
|
|
358
|
+
/>
|
|
359
|
+
</div>
|
|
360
|
+
<figure className={portraitFigureCss}>
|
|
361
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
362
|
+
|
|
363
|
+
{isSlideshow(wcmIdList) &&
|
|
364
|
+
<CaptionCreditSlideshow
|
|
365
|
+
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
366
|
+
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
367
|
+
extraStyles={[topperStyles.slideshowCaptionSideBySidePortrait, sideBySideCapCredColorCss(), sideBySidePortraitCapCredPaddingCss()]}
|
|
368
|
+
creditStyles={[sideBySideCapCredColorCss()]}
|
|
369
|
+
/>
|
|
370
|
+
}
|
|
371
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.captionSideBySidePortrait, sideBySideCapCredColorCss(), sideBySidePortraitFloatCss()]} creditStyles={[sideBySideCapCredColorCss()]} />}
|
|
372
|
+
</figure>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
);
|
|
230
376
|
}
|
|
231
377
|
}
|
|
232
378
|
|
|
233
379
|
/** Calculate offsets for header-deck container based on the spreadsheet, for full-screen toppers only **/
|
|
234
380
|
const calculatefullScreenOffsets = () => {
|
|
235
|
-
|
|
381
|
+
let r = (typeof window != "undefined") ? document.querySelector(':root') : null;
|
|
236
382
|
|
|
237
383
|
let verticalOffset = convertStringToNumber(HeaderDek_Vertical_Offset, (HeaderDek_Vertical_Position === "bottom"));
|
|
238
384
|
let horizontalOffset = convertStringToNumber(HeaderDek_Horizontal_Offset, (HeaderDek_Horizontal_Position === "right"));
|
|
239
385
|
|
|
240
|
-
r
|
|
241
|
-
|
|
386
|
+
if (r) {
|
|
387
|
+
r.style.setProperty('--headerDek-vertical-offset', verticalOffset + "px");
|
|
388
|
+
r.style.setProperty('--headerDek-horizontal-offset', horizontalOffset + "px");
|
|
389
|
+
}
|
|
242
390
|
}
|
|
243
391
|
|
|
244
392
|
/** Convert offset values from the spreadsheet into Number type **/
|
|
@@ -257,6 +405,19 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
257
405
|
return num;
|
|
258
406
|
}
|
|
259
407
|
|
|
408
|
+
/** Sets the background and text color in topper for side-by-side and side-by-side-portrait topper styles **/
|
|
409
|
+
const setBackgroundAndTextColor = () => {
|
|
410
|
+
let r = (typeof window != "undefined") ? document.querySelector(':root') : null;
|
|
411
|
+
|
|
412
|
+
if (r && Topper_Background_Color) {
|
|
413
|
+
r.style.setProperty('--container-background-color', Topper_Background_Color)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (r && Inverted_Text_Color) {
|
|
417
|
+
r.style.setProperty('--side-by-side-text-color', Inverted_Text_Color)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
260
421
|
return (
|
|
261
422
|
<TopperHtml />
|
|
262
423
|
)
|
|
@@ -17,7 +17,7 @@ const ImageHTML = ({ fullPath, imageRez, alt, overrideCssList }) => {
|
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const TopperImage = ({ wcm, alt, ratio, wcmData, overrideCssList }) => {
|
|
20
|
+
const TopperImage = ({ wcm, alt, ratio, wcmData, containerCssList = [], overrideCssList = [] }) => {
|
|
21
21
|
// When the wrapping div is rendered, we're going to figure out the best size for this image to be
|
|
22
22
|
let picRef = useRef(null)
|
|
23
23
|
let [imageRez, setImageRez] = useState(0)
|
|
@@ -61,6 +61,7 @@ const TopperImage = ({ wcm, alt, ratio, wcmData, overrideCssList }) => {
|
|
|
61
61
|
// This calculation is not used for the topper impl, but keeping it here just in case
|
|
62
62
|
// it is needed for the general WCMImage utils migration
|
|
63
63
|
let photoRatio = "56.25%"; // Default to 16/9
|
|
64
|
+
let photoViewport = "56.25vw";
|
|
64
65
|
let fullPath = `https://s.hdnux.com/photos/0/0/0/${wcm}/0/`;
|
|
65
66
|
if (!ratio) {
|
|
66
67
|
let matchedPhoto = wcmData.nodes.find((item) => {
|
|
@@ -72,10 +73,12 @@ const TopperImage = ({ wcm, alt, ratio, wcmData, overrideCssList }) => {
|
|
|
72
73
|
if (matchedPhoto) {
|
|
73
74
|
// Set ratio of the actual photo like a legit hacker
|
|
74
75
|
photoRatio = (matchedPhoto.photo.ratio * 100) + "%";
|
|
76
|
+
photoViewport = (matchedPhoto.photo.ratio * 50) + "vw";
|
|
75
77
|
|
|
76
78
|
// If css :root is available, set the photo ratio
|
|
77
79
|
if (r) {
|
|
78
80
|
r.style.setProperty('--img-bottom-padding-ratio', photoRatio);
|
|
81
|
+
r.style.setProperty('--img-height-viewport', photoViewport);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
fullPath = matchedPhoto.photo.full_path;
|
|
@@ -90,6 +93,7 @@ const TopperImage = ({ wcm, alt, ratio, wcmData, overrideCssList }) => {
|
|
|
90
93
|
// If css :root is available, set the photo ratio
|
|
91
94
|
if (r) {
|
|
92
95
|
r.style.setProperty('--img-bottom-padding-ratio', photoRatio);
|
|
96
|
+
r.style.setProperty('--img-height-viewport', photoViewport);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -99,7 +103,7 @@ const TopperImage = ({ wcm, alt, ratio, wcmData, overrideCssList }) => {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
return (
|
|
102
|
-
<div ref={picRef}>
|
|
106
|
+
<div className={containerCssList.join(' ')} ref={picRef}>
|
|
103
107
|
<ImageHTML fullPath={fullPath} imageRez={imageRez} alt={alt} overrideCssList={overrideCssList} />
|
|
104
108
|
</div>
|
|
105
109
|
)
|
|
@@ -110,6 +114,7 @@ TopperImage.propTypes = {
|
|
|
110
114
|
alt: PropTypes.string.isRequired,
|
|
111
115
|
ratio: PropTypes.string, // This prop is currently not being used, might be ok to delete?
|
|
112
116
|
wcmData: PropTypes.object,
|
|
117
|
+
containerCssList: PropTypes.array,
|
|
113
118
|
overrideCssList: PropTypes.array
|
|
114
119
|
}
|
|
115
120
|
|
package/example/gatsby-node.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* See: https://www.gatsbyjs.org/docs/node-apis/
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
var {requestImage} = require("./tasks/node-helpers");
|
|
7
|
+
var { requestImage } = require("./tasks/node-helpers");
|
|
8
8
|
let topperData = require("./src/data/topper2_settings.sheet.json");
|
|
9
9
|
|
|
10
10
|
// Import all the WCM photos you'd like to use in this project
|
|
11
11
|
// NOTE: Leave this as an empty array if you aren't importing any WCM photos, but you won't be able to use the WCMImage component
|
|
12
|
-
const wcmPhotos = [20374215]
|
|
12
|
+
const wcmPhotos = ["20374215"]
|
|
13
13
|
|
|
14
14
|
const addValidWcmId = (numStr, wcmPhotos) => {
|
|
15
15
|
let isNum = /^\d+$/.test(numStr.trim())
|
|
@@ -23,11 +23,10 @@ if (numStr.includes(";")) {
|
|
|
23
23
|
for (var num of numList) {
|
|
24
24
|
addValidWcmId(num, wcmPhotos);
|
|
25
25
|
}
|
|
26
|
-
} else {
|
|
26
|
+
} else {
|
|
27
27
|
addValidWcmId(numStr, wcmPhotos);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
// Create nodes so GraphQL can access
|
|
32
31
|
exports.sourceNodes = async ({
|
|
33
32
|
actions,
|