-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
6,211 additions
and
6,448 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
apps-rendering/src/components/KeyEvents/KeyEvents.stories.tsx
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,124 @@ | ||
// ----- Imports ----- // | ||
|
||
import { css } from '@emotion/react'; | ||
import type { ArticleFormat, ArticleTheme } from '@guardian/libs'; | ||
import { | ||
ArticleDesign, | ||
ArticleDisplay, | ||
ArticlePillar, | ||
ArticleSpecial, | ||
} from '@guardian/libs'; | ||
import type { ReactElement } from 'react'; | ||
import type { KeyEvent } from '.'; | ||
import KeyEvents from '.'; | ||
|
||
// ----- Stories ----- // | ||
|
||
const events: KeyEvent[] = [ | ||
{ | ||
date: new Date(1 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(2 * 60 * 1000), | ||
text: 'Ben Maher goes into the gold medal sport in the equestrian jumps', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(3 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(5 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(9 * 60 * 1000), | ||
text: 'Jodie Williams qualifies for the 400m final', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(15 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(20 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
{ | ||
date: new Date(35 * 60 * 1000), | ||
text: 'Gold for Uganda', | ||
url: 'https://www.theguardian.com/environment/2021/sep/01/opec-member-urges-oil-producers-to-focus-more-on-renewable-energy', | ||
}, | ||
]; | ||
|
||
const KeyEventComp = ( | ||
dark: boolean, | ||
format: ArticleFormat, | ||
title: string, | ||
): ReactElement => ( | ||
<div | ||
css={css` | ||
flex-grow: 1; | ||
`} | ||
> | ||
<div>{title}</div> | ||
<KeyEvents keyEvents={events} format={format} supportsDarkMode={dark} /> | ||
</div> | ||
); | ||
|
||
const getFormat = (theme: ArticleTheme): ArticleFormat => { | ||
return { | ||
design: ArticleDesign.Standard, | ||
display: ArticleDisplay.Standard, | ||
theme: theme, | ||
}; | ||
}; | ||
|
||
const keyEventWithTheme = (dark: boolean): (() => ReactElement) => { | ||
const KeyEvent = (): ReactElement => ( | ||
<div | ||
css={css` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
flex-wrap: wrap; | ||
`} | ||
> | ||
{KeyEventComp(dark, getFormat(ArticlePillar.News), 'News')} | ||
{KeyEventComp(dark, getFormat(ArticlePillar.Culture), 'Culture')} | ||
{KeyEventComp( | ||
dark, | ||
getFormat(ArticlePillar.Lifestyle), | ||
'Lifestyle', | ||
)} | ||
{KeyEventComp(dark, getFormat(ArticlePillar.Opinion), 'Opinion')} | ||
{KeyEventComp(dark, getFormat(ArticlePillar.Sport), 'Sport')} | ||
{KeyEventComp(dark, getFormat(ArticleSpecial.Labs), 'Labs')} | ||
{KeyEventComp( | ||
dark, | ||
getFormat(ArticleSpecial.SpecialReport), | ||
'SpecialReport', | ||
)} | ||
</div> | ||
); | ||
|
||
return KeyEvent; | ||
}; | ||
|
||
const Default = keyEventWithTheme(false); | ||
const Dark = keyEventWithTheme(true); | ||
|
||
// ----- Exports ----- // | ||
|
||
export default { | ||
component: KeyEvents, | ||
title: 'AR/KeyEvents', | ||
}; | ||
|
||
export { Default, Dark }; |
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
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
Oops, something went wrong.