generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): Add Video block to storybook based on existing Volto…
… EEA add-on #331 from eea/feature-video-block
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
function Video({ children, align }) { | ||
return <div className={cx('block video align', align)}>{children}</div>; | ||
} | ||
|
||
Video.Body = ({ children, align }) => ( | ||
<div className={cx('video-inner', { 'full-width': align === 'full' })}> | ||
{children} | ||
</div> | ||
); | ||
|
||
Video.Embed = ({ | ||
children, | ||
url, | ||
loop, | ||
autoPlay, | ||
align, | ||
placeholder_image, | ||
required_caption, | ||
}) => { | ||
return ( | ||
<video | ||
src={url} | ||
controls={!autoPlay} | ||
autoPlay={autoPlay} | ||
muted={autoPlay} | ||
loop={loop} | ||
poster={placeholder_image} | ||
type="video/mp4" | ||
> | ||
<track kind="captions" {...required_caption} /> | ||
{children} | ||
</video> | ||
); | ||
}; | ||
|
||
Video.Track = ({ tracks }) => | ||
tracks.map((track, index) => { | ||
return <track {...track} />; | ||
}); | ||
|
||
export default Video; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { Container } from 'semantic-ui-react'; | ||
import Video from './Video'; | ||
import englishTrack from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/video/demo-track-en.vtt'; | ||
import romanianTrack from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/video/demo-track-ro.vtt'; | ||
import greekTrack from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/video/demo-track-el.vtt'; | ||
|
||
export default { | ||
title: 'Components/Video', | ||
component: Video, | ||
argTypes: { | ||
align: { | ||
options: ['center', 'right', 'left'], | ||
control: { | ||
type: 'select', | ||
labels: { | ||
'': 'default', | ||
}, | ||
}, | ||
defaultValue: 'center', | ||
table: { | ||
defaultValue: { summary: 'center' }, | ||
type: { summary: 'string' }, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => ( | ||
<Container> | ||
<Video align={args.align}> | ||
<Video.Body align={args.align}> | ||
<Video.Embed {...args}> | ||
<Video.Track tracks={args.tracks} /> | ||
</Video.Embed> | ||
</Video.Body> | ||
</Video> | ||
</Container> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
url: 'https://cmshare.eea.europa.eu/s/Xw7kH2TJGCibHJf/download', | ||
autoPlay: false, | ||
loop: false, | ||
align: 'center', | ||
placeholder_image: '', | ||
required_caption: { src: englishTrack, srclang: 'en', label: 'English' }, | ||
tracks: [ | ||
{ src: romanianTrack, kind: 'captions', srclang: 'ro', label: 'Română' }, | ||
{ src: greekTrack, kind: 'captions', srclang: 'el', label: 'Ελλήνικά' }, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
WEBVTT | ||
00:00:00.000 --> 00:00:11.999 line:80% | ||
[ΜΟΥΣΙΚΗ] | ||
|
||
00:00:12.000 --> 00:01:35.999 line:80% | ||
Αυτά τα components χρησιμοποιούνται ως παράδειγμα χρήσης. | ||
Αυτοί οι υπότιτλοι έχουν σκοπό την επίδειξη της λειτουργικότητας. | ||
|
||
00:01:36.000 --> 00:01:47.999 line:80% | ||
[ΜΟΥΣΙΚΗ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
WEBVTT | ||
00:00:00.000 --> 00:00:11.999 line:80% | ||
[MUSIC] | ||
|
||
00:00:12.000 --> 00:01:35.999 line:80% | ||
These components are used for demo purposes. | ||
This track is an example to demonstrate the functionality. | ||
|
||
00:01:36.000 --> 00:01:47.999 line:80% | ||
[MUSIC] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
WEBVTT | ||
00:00:00.000 --> 00:00:11.999 line:80% | ||
[MUZICĂ] | ||
|
||
00:00:12.000 --> 00:01:35.999 line:80% | ||
Aceste componente sunt utilizate în scopuri demonstrative. | ||
Această piesă este un exemplu pentru a demonstra funcționalitatea. | ||
|
||
00:01:36.000 --> 00:01:47.999 line:80% | ||
[MUZICĂ] |