From cadb4141ca6e9da2eb0e0a80ea6c686acd80348c Mon Sep 17 00:00:00 2001 From: Abbey Hart Date: Mon, 26 Aug 2019 07:26:54 -0500 Subject: [PATCH] refactor: updates button to div, adds event handlers, and adds video example to gallery (#365) * refactor: updates button to div and adds video example to gallery * chore: prevents default on space bar key down --- .../src/pages/components/ImageGallery.mdx | 7 ++ .../src/components/Video/Video.js | 67 +++++++++++++++++-- .../src/components/Video/Video.module.scss | 18 +++-- 3 files changed, 77 insertions(+), 15 deletions(-) diff --git a/packages/example/src/pages/components/ImageGallery.mdx b/packages/example/src/pages/components/ImageGallery.mdx index 9c5df2a90..6ffc487e2 100644 --- a/packages/example/src/pages/components/ImageGallery.mdx +++ b/packages/example/src/pages/components/ImageGallery.mdx @@ -60,6 +60,13 @@ Click on an image to open the gallery. ![IBM Cloud Server](/images/IBM_Cloud_Server.png) + + + + + ![IBM Cloud Think](/images/IBM_Cloud_Think_Keynote.jpg) diff --git a/packages/gatsby-theme-carbon/src/components/Video/Video.js b/packages/gatsby-theme-carbon/src/components/Video/Video.js index 6ed8be46e..145bbf010 100644 --- a/packages/gatsby-theme-carbon/src/components/Video/Video.js +++ b/packages/gatsby-theme-carbon/src/components/Video/Video.js @@ -63,22 +63,53 @@ const Video = ({ vimeoId, title, ...props }) => { }); } + function onVimeoKeyDown(event) { + const player = getVimeoPlayer(); + + event.preventDefault(); + + if (event.key === 'Enter' || event.key === ' ') { + if (isPlaying) { + player + .pause() + .then(() => { + setIsPlaying(false); + }) + .catch(error => { + console.error(error); + }); + return; + } + player + .play() + .then(() => { + setIsPlaying(true); + }) + .catch(error => { + console.error(error); + }); + } + } + if (vimeoId) { return (
- +