diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98b2f7255..0e1c881b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/src/components/Molecules/SingleMessage/SingleMessage.js b/src/components/Molecules/SingleMessage/SingleMessage.js index eb1b88200..c24ef83e0 100644 --- a/src/components/Molecules/SingleMessage/SingleMessage.js +++ b/src/components/Molecules/SingleMessage/SingleMessage.js @@ -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); @@ -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 ( - -
- - ); + /* 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 = () => ( + +
+ + ); + /* Waiting on a usable ref from render before setting our flag used in other functions */ useEffect(() => { setHasParentID(true); @@ -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 `single-msg__${id}`}> diff --git a/src/components/Molecules/SingleMessage/SingleMessage.md b/src/components/Molecules/SingleMessage/SingleMessage.md index 694aedd53..fe9857b4b 100644 --- a/src/components/Molecules/SingleMessage/SingleMessage.md +++ b/src/components/Molecules/SingleMessage/SingleMessage.md @@ -124,7 +124,7 @@ import Text from '../../Atoms/Text/Text'; ; ``` -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'; @@ -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'; + @@ -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'; + @@ -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'; + Single Message with portrait video @@ -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; + @@ -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'; + @@ -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'; + diff --git a/src/components/Molecules/SingleMessage/_ExampleYoutubeIds.js b/src/components/Molecules/SingleMessage/_ExampleYoutubeIds.js new file mode 100644 index 000000000..a6352e693 --- /dev/null +++ b/src/components/Molecules/SingleMessage/_ExampleYoutubeIds.js @@ -0,0 +1,10 @@ +const exampleYoutubeIds = [ + 'fwCQRMlKBnA', + 'ZlGgFEDYKlY', + 'yKADOGvq1Hs', + 'Il9jhN2-PMA', + 'So-GyrcQtK8', + 'DjTmbU9nZNk' +]; + +export default exampleYoutubeIds;