Skip to content
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 10 commits into from
May 16, 2023
137 changes: 55 additions & 82 deletions src/standfirst/__tests__/standfirst.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,22 @@ 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 {TextBlock} from '../../text-block';
import {getColorCssFromTheme, styled} from '../../utils/style';

const standfirstCustomThemeObject: CreateThemeArgs = {
name: 'my-custom-standfirst-theme',
overrides: {
stylePresets: {
standfirstCustom: {base: {color: '{{colors.inkBrand010}}'}},
},
},
};

const bodyString =
'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.';
const CONTENT = (
<TextBlock typographyPreset="utilitySubheading020">
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.
</TextBlock>
);
Copy link
Contributor

@mutebg mutebg May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use text-block with typographyPreset to pass it down to the standfirst component?
Is that required by design? if so this needs to change, that's not how we suggest this component to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mutebg as per design its typographyPreset="utilitySubheading020" by default we have

typographyPreset: {
        xs: 'editorialSubheadline010',
        lg: 'editorialSubheadline020',
},

So I have added text-block component to update the typographyPreset

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the designs are wrong, the default version is without any props and overrides

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mutebg @jannuk59 The standfirst already has typography presets in the defaults, so there shouldn't be any need to add these to a content text block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nathanparris this exactly what I meant. thanks for clarifying it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @mutebg @nathanparris. By default will be having

typographyPreset: {
        xs: 'editorialSubheadline010',
        lg: 'editorialSubheadline020',
},


export const StoryDefault = () => (
<StorybookPage columns="1fr">
<StorybookCase>
<Standfirst
as="h2"
overrides={{
styledText: {
typographyPreset: 'utilitySubheading020',
},
}}
>
{bodyString}
</Standfirst>
<Standfirst as="h2">{CONTENT}</Standfirst>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is default story, I would remove as="h2" prop

</StorybookCase>
</StorybookPage>
);
Expand All @@ -39,83 +28,67 @@ StoryDefault.storyName = 'Default';
export const StoryWithAsSpan = () => (
<StorybookPage columns="1fr">
<StorybookCase>
<Standfirst
as="span"
overrides={{
styledText: {
typographyPreset: 'utilitySubheading020',
},
}}
>
{bodyString}
</Standfirst>
<Standfirst as="span">{CONTENT}</Standfirst>
</StorybookCase>
</StorybookPage>
);
StoryWithAsSpan.storyName = 'Standfirst as span';

export const StoryLogicalProps = () => (
<>
<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>
<StorybookPage columns="1fr">
<StorybookCase>
<MarginOverridesWrapper>
<Standfirst
as="span"
overrides={{
styledText: {
typographyPreset: 'utilitySubheading020',
stylePreset: 'standfirstCustom',
paddingInline: '20px',
paddingBlock: '10px',
},
}}
>
{bodyString}
{CONTENT}
</Standfirst>
</StorybookCase>
</StorybookPage>
</>
</MarginOverridesWrapper>
</StorybookCase>
</StorybookPage>
);
StoryLogicalProps.storyName = 'Logical props';

export const StoryWithStylingOverrides = () => (
<StorybookPage columns="1fr">
<StorybookCase>
<Standfirst
overrides={{
styledText: {
stylePreset: 'inkBrand010',
},
}}
>
{CONTENT}
</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>
</>
<StorybookPage columns="1fr">
<StorybookCase title="Typography preset override">
<Standfirst
as="span"
overrides={{
styledText: {
typographyPreset: 'utilitySubheading050',
},
}}
>
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.
</Standfirst>
</StorybookCase>
</StorybookPage>
);
StoryWithOverrides.storyName = 'Overrides';

Expand Down Expand Up @@ -143,7 +116,7 @@ export default {
<ThemeProvider
theme={createCustomThemeWithBaseThemeSwitch(
context?.globals?.backgrounds?.value,
standfirstCustomThemeObject,
{},
context?.name,
)}
>
Expand Down