Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rary into df_191_more_props_Checkbox_for_styling
  • Loading branch information
michael-odonovan committed Jan 31, 2025
2 parents 77a10b6 + f1bc8f8 commit 9f1fcfd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:

# Test run video was always captured, so this action uses "always()" condition
- name: Upload videos
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
Expand Down
56 changes: 29 additions & 27 deletions src/components/Molecules/SingleMessage/SingleMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SingleMessage = ({
}) => {
const hasImage = imageSet || false;
const doubleImage = (imageSet || image) && (imageSet2 || image2);
const hasVideo = !!(videoID !== null && videoID !== '');
const hasVideo = Boolean(videoID !== null && videoID !== '');

// States to track video status
const [isInitialised, setIsInitialised] = useState(false);
Expand All @@ -54,26 +54,36 @@ const SingleMessage = ({
&& /iPad|iPhone|iPod/.test(navigator.platform)
: false;

// Break-out video markup into its own function
const renderVideoPlayers = thisRowID => {
// Store the dynamically-created UUID (from the main render func) in our state
// so useEffect can access it
const thisVideoID = `${thisRowID}__video`;

setUniqueID(thisVideoID);

return (
<VideoWrapper
isPlaying={isPlaying}
isBuffering={isBuffering}
key={thisVideoID}
landscapeVideo={landscapeVideo}
>
<div id={thisVideoID} />
</VideoWrapper>
);
/* Dynamically retrieve ID that Gatsby has already baked into the page,
need to null check for initial render */
const getID = refWithID => {
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;

return thisID;
};

// Create the id string for the youtube video
useEffect(() => {
if (thisRef.current) {
const thisID = getID(thisRef.current);
if (thisID) {
setUniqueID(`${thisID}__video`);
}
}
}, [thisRef]);

// Break-out video markup into its own function
const renderVideoPlayers = () => (
<VideoWrapper
isPlaying={isPlaying}
isBuffering={isBuffering}
key={uniqueID}
landscapeVideo={landscapeVideo}
>
<div id={uniqueID} />
</VideoWrapper>
);

/* Waiting on a usable ref from render before setting our flag used in other functions */
useEffect(() => {
setHasParentID(true);
Expand Down Expand Up @@ -115,14 +125,6 @@ const SingleMessage = ({
setIsBuffering(true);
};

/* Dynamically retrieve ID that Gatsby has already baked into the page,
need to null check for initial render */
const getID = refWithID => {
const thisID = refWithID !== null ? refWithID.getAttribute('id') : null;

return thisID;
};

return (
// Creates namespaced UUIDs for each row
<UID name={id => `single-msg__${id}`}>
Expand Down
26 changes: 19 additions & 7 deletions src/components/Molecules/SingleMessage/SingleMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ import Text from '../../Atoms/Text/Text';
</SingleMessage>;
```

Single Message with no Image - no top and bottom padding
Single Message with no Image - no top and bottom padding

```js
import Text from '../../Atoms/Text/Text';
Expand Down Expand Up @@ -184,13 +184,15 @@ Single Message with 16:9 video
```js
import Text from '../../Atoms/Text/Text';
const defaultData = require('../../../styleguide/data/data').defaultData;
import exampleYoutubeIds from './_ExampleYoutubeIds.js';

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={true}
videoID="WUgvvPRH7Oc"
videoID={exampleYoutubeIds[0]}
landscapeVideo
>
<Text tag="p" color="black" size="xxl">
Expand All @@ -202,13 +204,15 @@ const defaultData = require('../../../styleguide/data/data').defaultData;
```js
import Text from '../../Atoms/Text/Text';
const defaultData = require('../../../styleguide/data/data').defaultData;
import exampleYoutubeIds from './_ExampleYoutubeIds.js';

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={false}
videoID="WUgvvPRH7Oc"
videoID={exampleYoutubeIds[1]}
landscapeVideo
>
<Text tag="p" color="black" size="xxl">
Expand All @@ -222,13 +226,15 @@ Single Message with portrait video
```js
import Text from '../../Atoms/Text/Text';
const defaultData = require('../../../styleguide/data/data').defaultData;
import exampleYoutubeIds from './_ExampleYoutubeIds.js';

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={true}
videoID="FoMlSB6ftQg"
videoID={exampleYoutubeIds[2]}
>
<Text tag="p" color="black" size="xxl">
Single Message with portrait video
Expand All @@ -240,14 +246,16 @@ Single Message with portrait video, 100VH

```js
import Text from '../../Atoms/Text/Text';
import exampleYoutubeIds from './_ExampleYoutubeIds.js';
const defaultData = require('../../../styleguide/data/data').defaultData;

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={true}
videoID="fwCQRMlKBnA"
videoID={exampleYoutubeIds[3]}
vhFull
>
<Text tag="p" color="black" size="xxl">
Expand All @@ -261,13 +269,15 @@ Single Message with landscape video, 100VH, fullwidth image
```js
import Text from '../../Atoms/Text/Text';
const defaultData = require('../../../styleguide/data/data').defaultData;
import exampleYoutubeIds from './_ExampleYoutubeIds.js';

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={true}
videoID="WUgvvPRH7Oc"
videoID={exampleYoutubeIds[4]}
vhFull
fullImage={true}
>
Expand All @@ -283,13 +293,15 @@ Single Message with landscape video, 50VH, fullwidth image
```js
import Text from '../../Atoms/Text/Text';
const defaultData = require('../../../styleguide/data/data').defaultData;
import exampleYoutubeIds from './_ExampleYoutubeIds.js';

<SingleMessage
backgroundColor="purple"
imageSet={defaultData.images}
image={defaultData.image}
imageAltText=""
copyFirst={true}
videoID="WUgvvPRH7Oc"
videoID={exampleYoutubeIds[5]}
fullImage={true}
>
<Text tag="p" color="black" size="xxl">
Expand Down
10 changes: 10 additions & 0 deletions src/components/Molecules/SingleMessage/_ExampleYoutubeIds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const exampleYoutubeIds = [
'fwCQRMlKBnA',
'ZlGgFEDYKlY',
'yKADOGvq1Hs',
'Il9jhN2-PMA',
'So-GyrcQtK8',
'DjTmbU9nZNk'
];

export default exampleYoutubeIds;

0 comments on commit 9f1fcfd

Please sign in to comment.