sfc-utils 1.3.66 → 1.3.68
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 +189 -24
- package/components/topperimage.mjs +7 -2
- package/example/gatsby-node.js +12 -9
- 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 +34 -8
- 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,12 +76,13 @@ 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
|
|
|
68
84
|
// Apply extra custom styling if it exists in the spreadsheet
|
|
69
|
-
if (Title_Style !== "") {
|
|
85
|
+
if (Title_Style && Title_Style !== "") {
|
|
70
86
|
let extraStyles = Title_Style.split(", ");
|
|
71
87
|
defaultStyles = defaultStyles.concat(extraStyles);
|
|
72
88
|
}
|
|
@@ -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,8 +115,31 @@ 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) => {
|
|
141
|
+
if (!listStr) return [];
|
|
142
|
+
|
|
101
143
|
return listStr.split(";").map((d) => parseInt(d));
|
|
102
144
|
}
|
|
103
145
|
|
|
@@ -119,15 +161,54 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
119
161
|
return list;
|
|
120
162
|
}
|
|
121
163
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
164
|
+
/* Returns the corresponding image HTML for each topper style and slideshow status */
|
|
165
|
+
const getImageHTML = (isSlideshow) => {
|
|
166
|
+
if (isSlideshow) return (
|
|
167
|
+
<ImageSlideshow
|
|
168
|
+
wcmData={wcmData}
|
|
169
|
+
imageList={wcmIdList}
|
|
170
|
+
altList={convertStringToList(Image_Alt, wcmIdList.length)}
|
|
171
|
+
topperStyle={Topper_Style}
|
|
172
|
+
isLayoutInverted={(Inverted_Layout === "headerdek-right-image-left")}
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
switch (Topper_Style) {
|
|
177
|
+
case "stacked":
|
|
178
|
+
return (<TopperImage wcm={Image} alt={Image_Alt} wcmData={wcmData} />)
|
|
179
|
+
case "full-screen":
|
|
180
|
+
return (
|
|
181
|
+
<TopperImage
|
|
182
|
+
wcm={Image}
|
|
183
|
+
alt={Image_Alt}
|
|
184
|
+
wcmData={wcmData}
|
|
185
|
+
overrideCssList={[imageStyles.cImgFullscreen]}
|
|
186
|
+
/>
|
|
187
|
+
)
|
|
188
|
+
case "side-by-side":
|
|
189
|
+
return (
|
|
190
|
+
<TopperImage
|
|
191
|
+
wcm={Image}
|
|
192
|
+
alt={Image_Alt}
|
|
193
|
+
wcmData={wcmData}
|
|
194
|
+
containerCssList={[imageStyles.cContainerSideBySide]}
|
|
195
|
+
overrideCssList={[imageStyles.cImgSideBySide]}
|
|
196
|
+
/>)
|
|
197
|
+
case "side-by-side-portrait":
|
|
198
|
+
return (
|
|
199
|
+
<TopperImage
|
|
200
|
+
wcm={Image}
|
|
201
|
+
alt={Image_Alt}
|
|
202
|
+
wcmData={wcmData}
|
|
203
|
+
containerCssList={[imageStyles.cContainerSideBySidePortrait, sideBySidePortraitFloatCss()]}
|
|
204
|
+
overrideCssList={[imageStyles.cImgSideBySidePortrait]}
|
|
205
|
+
/>
|
|
206
|
+
)
|
|
207
|
+
case "no-visual":
|
|
208
|
+
default:
|
|
209
|
+
return null
|
|
210
|
+
}
|
|
211
|
+
}
|
|
131
212
|
|
|
132
213
|
const wcmIdList = getWcmIdList(Image);
|
|
133
214
|
const TopperHtml = () => {
|
|
@@ -138,15 +219,14 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
138
219
|
<>
|
|
139
220
|
<div className={containerCss}>
|
|
140
221
|
<figure className={`topper-image ${topperStyles.imageFullScreen}`} aria-labelledby="topperCaptionText">
|
|
141
|
-
{isSlideshow(wcmIdList)
|
|
142
|
-
{!isSlideshow(wcmIdList) && <FullScreenImageHTML />}
|
|
222
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
143
223
|
|
|
144
224
|
{/* This caption-credit only shows when the screen size is tablet or mobile */}
|
|
145
225
|
{isSlideshow(wcmIdList) &&
|
|
146
226
|
<CaptionCreditSlideshow
|
|
147
227
|
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
148
228
|
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
149
|
-
extraStyles={topperStyles.hideWhenDesktop}
|
|
229
|
+
extraStyles={[topperStyles.hideWhenDesktop]}
|
|
150
230
|
/>
|
|
151
231
|
}
|
|
152
232
|
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={topperStyles.hideWhenDesktop} />}
|
|
@@ -193,8 +273,8 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
193
273
|
/>
|
|
194
274
|
</div>
|
|
195
275
|
<figure className={`mw-xl ml-auto mr-auto ${topperStyles.imageStacked}`}>
|
|
196
|
-
{isSlideshow(wcmIdList)
|
|
197
|
-
|
|
276
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
277
|
+
|
|
198
278
|
{isSlideshow(wcmIdList) &&
|
|
199
279
|
<CaptionCreditSlideshow
|
|
200
280
|
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
@@ -202,7 +282,7 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
202
282
|
extraStyles={[topperStyles.smallPaddingLeftWhenTablet]}
|
|
203
283
|
/>
|
|
204
284
|
}
|
|
205
|
-
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.smallPaddingLeftWhenTablet]}/>}
|
|
285
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.smallPaddingLeftWhenTablet]} />}
|
|
206
286
|
</figure>
|
|
207
287
|
</div>
|
|
208
288
|
</>
|
|
@@ -227,18 +307,90 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
227
307
|
</div>
|
|
228
308
|
</>
|
|
229
309
|
);
|
|
310
|
+
|
|
311
|
+
case "side-by-side":
|
|
312
|
+
let figureCss = isSlideshow(wcmIdList) ? `${topperStyles.imageSideBySideSlideshow}` : `${topperStyles.imageSideBySide}`;
|
|
313
|
+
let sideBySideContainerCss = (Inverted_Layout === "headerdek-right-image-left") ? `${topperStyles.topperContainerSideBySide} ${topperStyles.reverseFlexbox}` : `${topperStyles.topperContainerSideBySide}`;
|
|
314
|
+
setBackgroundAndTextColor();
|
|
315
|
+
return (
|
|
316
|
+
<div className={sideBySideContainerCss}>
|
|
317
|
+
<div className={headerDekStyleList().join(' ')}>
|
|
318
|
+
<Heading
|
|
319
|
+
level={1}
|
|
320
|
+
text={Title}
|
|
321
|
+
className={headerStyleList().join(' ')}
|
|
322
|
+
/>
|
|
323
|
+
<Heading
|
|
324
|
+
level={2}
|
|
325
|
+
text={Deck}
|
|
326
|
+
className={deckStyleList().join(' ')}
|
|
327
|
+
/>
|
|
328
|
+
</div>
|
|
329
|
+
<figure className={figureCss}>
|
|
330
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
331
|
+
|
|
332
|
+
{isSlideshow(wcmIdList) &&
|
|
333
|
+
<CaptionCreditSlideshow
|
|
334
|
+
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
335
|
+
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
336
|
+
extraStyles={[topperStyles.slideshowCaptionSideBySide, sideBySideCapCredColorCss(), sideBySideCapCredPaddingCss()]}
|
|
337
|
+
creditStyles={[sideBySideCapCredColorCss()]}
|
|
338
|
+
/>
|
|
339
|
+
}
|
|
340
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.captionSideBySide, sideBySideCapCredColorCss()]} creditStyles={[sideBySideCapCredColorCss()]} />}
|
|
341
|
+
</figure>
|
|
342
|
+
</div>
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
case "side-by-side-portrait":
|
|
346
|
+
let portraitFigureCss = isSlideshow(wcmIdList) ? `${topperStyles.imageSideBySidePortraitSlideshow}` : `${topperStyles.imageSideBySidePortrait}`;
|
|
347
|
+
let sideBySidePortraitContainerCss = (Inverted_Layout === "headerdek-right-image-left") ? `${topperStyles.topperContainerSideBySidePortrait} ${topperStyles.reverseFlexbox}` : `${topperStyles.topperContainerSideBySidePortrait}`;
|
|
348
|
+
setBackgroundAndTextColor();
|
|
349
|
+
return (
|
|
350
|
+
<div className={topperStyles.fullWidthContainer}>
|
|
351
|
+
<div className={sideBySidePortraitContainerCss}>
|
|
352
|
+
<div className={headerDekStyleList().join(' ')}>
|
|
353
|
+
<Heading
|
|
354
|
+
level={1}
|
|
355
|
+
text={Title}
|
|
356
|
+
className={headerStyleList().join(' ')}
|
|
357
|
+
/>
|
|
358
|
+
<Heading
|
|
359
|
+
level={2}
|
|
360
|
+
text={Deck}
|
|
361
|
+
className={deckStyleList().join(' ')}
|
|
362
|
+
/>
|
|
363
|
+
</div>
|
|
364
|
+
<figure className={portraitFigureCss}>
|
|
365
|
+
{getImageHTML(isSlideshow(wcmIdList))}
|
|
366
|
+
|
|
367
|
+
{isSlideshow(wcmIdList) &&
|
|
368
|
+
<CaptionCreditSlideshow
|
|
369
|
+
captionList={convertStringToList(Image_Caption, wcmIdList.length)}
|
|
370
|
+
creditList={convertStringToList(Image_Credits, wcmIdList.length)}
|
|
371
|
+
extraStyles={[topperStyles.slideshowCaptionSideBySidePortrait, sideBySideCapCredColorCss(), sideBySidePortraitCapCredPaddingCss()]}
|
|
372
|
+
creditStyles={[sideBySideCapCredColorCss()]}
|
|
373
|
+
/>
|
|
374
|
+
}
|
|
375
|
+
{!isSlideshow(wcmIdList) && <CaptionCredit caption={Image_Caption} credit={Image_Credits} extraStyles={[topperStyles.captionSideBySidePortrait, sideBySideCapCredColorCss(), sideBySidePortraitFloatCss()]} creditStyles={[sideBySideCapCredColorCss()]} />}
|
|
376
|
+
</figure>
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
230
380
|
}
|
|
231
381
|
}
|
|
232
382
|
|
|
233
383
|
/** Calculate offsets for header-deck container based on the spreadsheet, for full-screen toppers only **/
|
|
234
384
|
const calculatefullScreenOffsets = () => {
|
|
235
|
-
|
|
385
|
+
let r = (typeof window != "undefined") ? document.querySelector(':root') : null;
|
|
236
386
|
|
|
237
387
|
let verticalOffset = convertStringToNumber(HeaderDek_Vertical_Offset, (HeaderDek_Vertical_Position === "bottom"));
|
|
238
388
|
let horizontalOffset = convertStringToNumber(HeaderDek_Horizontal_Offset, (HeaderDek_Horizontal_Position === "right"));
|
|
239
389
|
|
|
240
|
-
r
|
|
241
|
-
|
|
390
|
+
if (r) {
|
|
391
|
+
r.style.setProperty('--headerDek-vertical-offset', verticalOffset + "px");
|
|
392
|
+
r.style.setProperty('--headerDek-horizontal-offset', horizontalOffset + "px");
|
|
393
|
+
}
|
|
242
394
|
}
|
|
243
395
|
|
|
244
396
|
/** Convert offset values from the spreadsheet into Number type **/
|
|
@@ -257,6 +409,19 @@ const Topper2 = ({ settings, wcmData }) => {
|
|
|
257
409
|
return num;
|
|
258
410
|
}
|
|
259
411
|
|
|
412
|
+
/** Sets the background and text color in topper for side-by-side and side-by-side-portrait topper styles **/
|
|
413
|
+
const setBackgroundAndTextColor = () => {
|
|
414
|
+
let r = (typeof window != "undefined") ? document.querySelector(':root') : null;
|
|
415
|
+
|
|
416
|
+
if (r && Topper_Background_Color) {
|
|
417
|
+
r.style.setProperty('--container-background-color', Topper_Background_Color)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (r && Inverted_Text_Color) {
|
|
421
|
+
r.style.setProperty('--side-by-side-text-color', Inverted_Text_Color)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
260
425
|
return (
|
|
261
426
|
<TopperHtml />
|
|
262
427
|
)
|
|
@@ -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())
|
|
@@ -17,14 +17,17 @@ const addValidWcmId = (numStr, wcmPhotos) => {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Add topper image(s) to wcmPhotos list
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (topperData[0].Image) {
|
|
21
|
+
let numStr = (topperData[0].Image).toString();
|
|
22
|
+
|
|
23
|
+
if (numStr.includes(";")) {
|
|
24
|
+
let numList = numStr.split(";");
|
|
25
|
+
for (var num of numList) {
|
|
26
|
+
addValidWcmId(num, wcmPhotos);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
addValidWcmId(numStr, wcmPhotos);
|
|
25
30
|
}
|
|
26
|
-
} else {
|
|
27
|
-
addValidWcmId(numStr, wcmPhotos);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
|