This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a YoutubeAtom, a subset of the CAPI MediaAtom. As part of this some tooling changes have been introduced to support the @guardian/types library.
- Loading branch information
Showing
17 changed files
with
600 additions
and
42 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 |
---|---|---|
@@ -1,4 +1,36 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
stories: ['../**/*.stories.tsx'], | ||
addons: ['@storybook/preset-typescript'], | ||
webpackFinal: async (config, { configType }) => { | ||
config.module.rules.push({ | ||
test: /\.tsx?$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
'@babel/preset-env', | ||
'@babel/preset-typescript', | ||
'@babel/preset-react', | ||
], | ||
plugins: [ | ||
'const-enum', | ||
[ | ||
'emotion', | ||
{ | ||
sourceMap: false, | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
], | ||
include: path.resolve(__dirname, '../'), | ||
}); | ||
|
||
// Return the altered config | ||
return config; | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1 +1,157 @@ | ||
|
||
<style type="text/css"> | ||
/*http://meyerweb.com/eric/tools/css/reset/v5.0.1|20191019License:none(publicdomain)*/ | ||
html, | ||
body, | ||
div, | ||
span, | ||
applet, | ||
object, | ||
iframe, | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6, | ||
p, | ||
blockquote, | ||
pre, | ||
a, | ||
abbr, | ||
acronym, | ||
address, | ||
big, | ||
cite, | ||
code, | ||
del, | ||
dfn, | ||
em, | ||
img, | ||
ins, | ||
kbd, | ||
q, | ||
s, | ||
samp, | ||
small, | ||
strike, | ||
strong, | ||
sub, | ||
sup, | ||
tt, | ||
var, | ||
b, | ||
u, | ||
i, | ||
center, | ||
dl, | ||
dt, | ||
dd, | ||
menu, | ||
ol, | ||
ul, | ||
li, | ||
fieldset, | ||
form, | ||
label, | ||
legend, | ||
table, | ||
caption, | ||
tbody, | ||
tfoot, | ||
thead, | ||
tr, | ||
th, | ||
td, | ||
article, | ||
aside, | ||
canvas, | ||
details, | ||
embed, | ||
figure, | ||
figcaption, | ||
footer, | ||
header, | ||
hgroup, | ||
main, | ||
menu, | ||
nav, | ||
output, | ||
ruby, | ||
section, | ||
summary, | ||
time, | ||
mark, | ||
audio, | ||
video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} /*HTML5display-roleresetforolderbrowsers*/ | ||
article, | ||
aside, | ||
details, | ||
figcaption, | ||
figure, | ||
footer, | ||
header, | ||
hgroup, | ||
main, | ||
menu, | ||
nav, | ||
section { | ||
display: block; | ||
} /*HTML5hidden-attributefixfornewerbrowsers*/ | ||
*[hidden] { | ||
display: none; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
menu, | ||
ol, | ||
ul { | ||
list-style: none; | ||
} | ||
blockquote, | ||
q { | ||
quotes: none; | ||
} | ||
blockquote:before, | ||
blockquote:after, | ||
q:before, | ||
q:after { | ||
content: ''; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} | ||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
html { | ||
box-sizing: border-box; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-font-smoothing: antialiased; | ||
} | ||
html, | ||
body { | ||
text-rendering: optimizeLegibility; | ||
font-feature-settings: 'kern'; | ||
font-kerning: normal; /*Safari7+,Firefox24+,Chrome33(?)+,Opera21*/ | ||
font-variant-ligatures: common-ligatures; | ||
} | ||
body { | ||
background-color: white; | ||
color: #121212; | ||
} | ||
em { | ||
font-style: italic; | ||
} | ||
</style> |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ module.exports = { | |
'@babel/preset-react', | ||
], | ||
plugins: [ | ||
'const-enum', | ||
[ | ||
'emotion', | ||
{ | ||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
import React from 'react'; | ||
import { css } from 'emotion'; | ||
|
||
type Props = { | ||
height: number; | ||
width: number; | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const MaintainAspectRatio = ({ | ||
height, | ||
width, | ||
children, | ||
}: Props): JSX.Element => ( | ||
/* https://css-tricks.com/aspect-ratio-boxes/ */ | ||
<div | ||
className={css` | ||
/* position relative to contain the absolutely positioned iframe plus any Overlay image */ | ||
position: relative; | ||
padding-bottom: ${(height / width) * 100}%; | ||
iframe { | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
} | ||
`} | ||
> | ||
{children} | ||
</div> | ||
); |
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,26 @@ | ||
import React from 'react'; | ||
|
||
import { YoutubeAtom } from './YoutubeAtom'; | ||
import { Pillar, Display, Design } from '@guardian/types/Format'; | ||
|
||
export default { | ||
title: 'YoutubeAtom', | ||
component: YoutubeAtom, | ||
}; | ||
|
||
export const DefaultStory = (): JSX.Element => { | ||
return ( | ||
<YoutubeAtom | ||
format={{ | ||
pillar: Pillar.News, | ||
design: Design.Article, | ||
display: Display.Standard, | ||
}} | ||
videoMeta={{ | ||
assetId: '-ZCvZmYlQD8', | ||
mediaTitle: | ||
"Rayshard Brooks says US justice system treats people 'like animals' in interview before his death", | ||
}} | ||
/> | ||
); | ||
}; |
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,27 @@ | ||
import React from 'react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { render } from '@testing-library/react'; | ||
import { Pillar, Display, Design } from '@guardian/types/Format'; | ||
import { YoutubeAtom } from './YoutubeAtom'; | ||
|
||
describe('YoutubeAtom', () => { | ||
it('should render', () => { | ||
const atom = ( | ||
<YoutubeAtom | ||
title="My Youtube video!" | ||
format={{ | ||
pillar: Pillar.News, | ||
design: Design.Article, | ||
display: Display.Standard, | ||
}} | ||
videoMeta={{ | ||
assetId: '-ZCvZmYlQD8', | ||
mediaTitle: 'YoutubeAtom', | ||
}} | ||
/> | ||
); | ||
const { getByTitle } = render(atom); | ||
|
||
expect(getByTitle('My Youtube video!')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.