-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(723): Standfirst Storybook Enhancement #881
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5531254
docs(723): standfirst enhancements
c66132d
docs(723): refined theme and typograpghy presets
d0ee626
docs(723): removed themeing typograoghy
ab15409
docs(723): removed react fragements
05c44e9
docs(723): removed themeing
436140d
docs(723): removed themeing
bfe3ee8
docs(723): default story update
4fa8b37
docs(723): removed typograpghy
7f5e226
docs(723): removed typograpghy
4e093ab
docs(725): refinement
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,105 +1,154 @@ | ||||||
import * as React from 'react'; | ||||||
import {Standfirst} from '..'; | ||||||
import {createTheme, ThemeProvider} from '../../theme'; | ||||||
import {StorybookSubHeading} from '../../test/storybook-comps'; | ||||||
import {ThemeProvider, CreateThemeArgs} from '../../theme'; | ||||||
import {Story as StoryType} from '@storybook/react'; | ||||||
import {createCustomThemeWithBaseThemeSwitch} from '../../test/theme-select-object'; | ||||||
import {StorybookCase, StorybookPage} from '../../test/storybook-comps'; | ||||||
import {getColorCssFromTheme, styled} from '../../utils/style'; | ||||||
|
||||||
const myCustomTheme = createTheme({ | ||||||
const standfirstCustomThemeObject: CreateThemeArgs = { | ||||||
name: 'my-custom-standfirst-theme', | ||||||
overrides: { | ||||||
stylePresets: { | ||||||
standfirstCustom: { | ||||||
base: { | ||||||
color: '{{colors.blue060}}', | ||||||
}, | ||||||
}, | ||||||
}, | ||||||
typographyPresets: { | ||||||
standfirstCustom: { | ||||||
fontFamily: '{{fonts.fontFamily1.fontFamily}}', | ||||||
fontSize: '{{fonts.fontSize060}}', | ||||||
lineHeight: '{{fonts.fontLineHeight030}}', | ||||||
fontWeight: '{{fonts.fontWeight020}}', | ||||||
letterSpacing: '{{fonts.fontLetterSpacing030}}', | ||||||
}, | ||||||
standfirstCustom: {base: {color: '{{colors.inkBrand010}}'}}, | ||||||
}, | ||||||
}, | ||||||
}); | ||||||
}; | ||||||
|
||||||
const bodyString = | ||||||
'Telling the stories that matter, seeding ideas and stirring emotion. Capturing moments, meaning and magic. Making sense of the world. On the shoulders of giants, in the thick of it, behind the scenes and fighting the good fight.'; | ||||||
|
||||||
export default { | ||||||
title: 'Components/standfirst', | ||||||
component: () => 'None', | ||||||
}; | ||||||
'NewsKit provides components, guidelines and standards to enable digital product teams to create high-quality, consistent products quickly. NewsKit is built on modular design principles and backed by best practice guidance for design and development.'; | ||||||
|
||||||
export const StoryDefault = () => ( | ||||||
<> | ||||||
<StorybookSubHeading>Standfirst - default</StorybookSubHeading> | ||||||
<Standfirst>{bodyString}</Standfirst> | ||||||
</> | ||||||
); | ||||||
StoryDefault.storyName = 'default'; | ||||||
|
||||||
export const StoryWithAsProp = () => ( | ||||||
<> | ||||||
<StorybookSubHeading>Standfirst - as h3</StorybookSubHeading> | ||||||
<Standfirst as="h3">{bodyString}</Standfirst> | ||||||
|
||||||
<StorybookSubHeading>Standfirst - as span</StorybookSubHeading> | ||||||
<Standfirst as="span">{bodyString}</Standfirst> | ||||||
</> | ||||||
); | ||||||
StoryWithAsProp.storyName = 'with-as-prop'; | ||||||
|
||||||
export const StoryWithOverrides = () => ( | ||||||
<> | ||||||
<ThemeProvider theme={myCustomTheme}> | ||||||
<StorybookSubHeading> | ||||||
Standfirst - with style-preset override | ||||||
</StorybookSubHeading> | ||||||
<StorybookPage columns="1fr"> | ||||||
<StorybookCase> | ||||||
<Standfirst | ||||||
as="h2" | ||||||
overrides={{ | ||||||
styledText: { | ||||||
stylePreset: 'standfirstCustom', | ||||||
typographyPreset: 'utilitySubheading020', | ||||||
}, | ||||||
}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
<StorybookSubHeading> | ||||||
Standfirst - with typography-preset override | ||||||
</StorybookSubHeading> | ||||||
</StorybookCase> | ||||||
</StorybookPage> | ||||||
); | ||||||
StoryDefault.storyName = 'Default'; | ||||||
|
||||||
export const StoryWithAsSpan = () => ( | ||||||
<StorybookPage columns="1fr"> | ||||||
<StorybookCase> | ||||||
<Standfirst | ||||||
as="span" | ||||||
overrides={{ | ||||||
styledText: { | ||||||
typographyPreset: 'editorialSubheadline020', | ||||||
typographyPreset: 'utilitySubheading020', | ||||||
}, | ||||||
}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
</ThemeProvider> | ||||||
</> | ||||||
</StorybookCase> | ||||||
</StorybookPage> | ||||||
); | ||||||
StoryWithOverrides.storyName = 'with-overrides'; | ||||||
StoryWithAsSpan.storyName = 'Standfirst as span'; | ||||||
|
||||||
export const StoryLogicalProps = () => ( | ||||||
<> | ||||||
<StorybookSubHeading> | ||||||
Standfirst - logical padding props | ||||||
</StorybookSubHeading> | ||||||
<Standfirst | ||||||
overrides={{styledText: {paddingInline: '20px', paddingBlock: '10px'}}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
<StorybookSubHeading>Standfirst - logical margin props</StorybookSubHeading> | ||||||
<Standfirst | ||||||
overrides={{styledText: {marginInline: '20px', marginBlock: '10px'}}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
<StorybookPage columns="1fr"> | ||||||
<StorybookCase> | ||||||
<MarginOverridesWrapper> | ||||||
<Standfirst | ||||||
as="span" | ||||||
overrides={{ | ||||||
styledText: { | ||||||
typographyPreset: 'utilitySubheading020', | ||||||
paddingInline: '20px', | ||||||
paddingBlock: '10px', | ||||||
}, | ||||||
}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
</MarginOverridesWrapper> | ||||||
</StorybookCase> | ||||||
</StorybookPage> | ||||||
</> | ||||||
); | ||||||
StoryLogicalProps.storyName = 'Logical props'; | ||||||
|
||||||
export const StoryWithStylingOverrides = () => ( | ||||||
<> | ||||||
<StorybookPage columns="1fr"> | ||||||
<StorybookCase> | ||||||
<Standfirst | ||||||
as="span" | ||||||
overrides={{ | ||||||
styledText: { | ||||||
typographyPreset: 'utilitySubheading020', | ||||||
stylePreset: 'standfirstCustom', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use directly
Suggested change
|
||||||
}, | ||||||
}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
</StorybookCase> | ||||||
</StorybookPage> | ||||||
</> | ||||||
); | ||||||
StoryWithStylingOverrides.storyName = 'Styling overrides'; | ||||||
|
||||||
export const StoryWithOverrides = () => ( | ||||||
<> | ||||||
<StorybookPage columns="1fr"> | ||||||
<StorybookCase title="Typography preset override"> | ||||||
<Standfirst | ||||||
as="span" | ||||||
overrides={{ | ||||||
styledText: { | ||||||
typographyPreset: 'utilitySubheading050', | ||||||
}, | ||||||
}} | ||||||
> | ||||||
{bodyString} | ||||||
</Standfirst> | ||||||
</StorybookCase> | ||||||
</StorybookPage> | ||||||
</> | ||||||
); | ||||||
StoryLogicalProps.storyName = 'logical-props'; | ||||||
StoryWithOverrides.storyName = 'Overrides'; | ||||||
|
||||||
const MarginOverridesWrapper = styled.div` | ||||||
border: 1px dashed; | ||||||
${getColorCssFromTheme('borderColor', 'red060')} | ||||||
`; | ||||||
|
||||||
export default { | ||||||
title: 'Components/Standfirst', | ||||||
component: () => 'None', | ||||||
parameters: { | ||||||
nkDocs: { | ||||||
title: 'Standfirst', | ||||||
url: 'https://www.newskit.co.uk/components/standfirst/', | ||||||
description: | ||||||
'Standfirst is an introductory paragraph in an article, which summarises the articles content.', | ||||||
}, | ||||||
}, | ||||||
decorators: [ | ||||||
( | ||||||
Story: StoryType, | ||||||
context: {name: string; globals: {backgrounds: {value: string}}}, | ||||||
) => ( | ||||||
<ThemeProvider | ||||||
theme={createCustomThemeWithBaseThemeSwitch( | ||||||
context?.globals?.backgrounds?.value, | ||||||
standfirstCustomThemeObject, | ||||||
context?.name, | ||||||
)} | ||||||
> | ||||||
<Story /> | ||||||
</ThemeProvider> | ||||||
), | ||||||
], | ||||||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is default I am expecting it not to have any overrides