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

Update storybook documentation inconsistencies #183

Merged
merged 7 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"jsx-a11y/anchor-has-content": 0,
"jsx-a11y/alt-text": 0,
"jsx-a11y/heading-has-content": 0,
"react-hooks/exhaustive-deps": 0
}
"react-hooks/exhaustive-deps": 0,
},
"overrides": [{
"files": ["*.stories.tsx"],
"rules": {"@typescript-eslint/no-unused-vars":"off"}
}]
}
3 changes: 3 additions & 0 deletions stories/Components/Breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const meta: Meta<typeof Breadcrumb> = {
export default meta;
type Story = StoryObj<typeof Breadcrumb>;

Breadcrumb.Item.displayName = 'Breadcrumb.Item';
Breadcrumb.Back.displayName = 'Breadcrumb.Back';

export const Standard: Story = {};

export const OverrideAriaLabel: Story = {
Expand Down
10 changes: 9 additions & 1 deletion stories/Components/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ const meta: Meta<typeof Card> = {
export default meta;
type Story = StoryObj<typeof Card>;

Card.Content.displayName = 'Card.Content';
Card.Heading.displayName = 'Card.Heading';
Card.Description.displayName = 'Card.Description';
Card.Link.displayName = 'Card.Link';
Card.Image.displayName = 'Card.Image';
Card.Group.displayName = 'Card.Group';
Card.GroupItem.displayName = 'Card.GroupItem';

export const Standard: Story = {
render: () => (
render: (args) => (
<Card>
<Card.Content>
<Card.Heading>If you need help now but it&apos;s not an emergency</Card.Heading>
Expand Down
33 changes: 23 additions & 10 deletions stories/Components/CareCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ const meta: Meta<typeof CareCard> = {
component: CareCard,
};
export default meta;

CareCard.Heading.displayName = 'CareCard.Heading';
CareCard.Content.displayName = 'CareCard.Content';

type Story = StoryObj<typeof CareCard>;
export const NonUrgent: Story = {
render: (): JSX.Element => (
<CareCard type="non-urgent">
args: { type: 'non-urgent' },
render: (args): JSX.Element => (
<CareCard type={args.type}>
<CareCard.Heading>Speak to a GP if:</CareCard.Heading>
<CareCard.Content>
<ul>
Expand All @@ -69,8 +74,9 @@ export const NonUrgent: Story = {
};

export const Urgent: Story = {
render: () => (
<CareCard type="urgent">
args: { type: 'urgent' },
render: (args) => (
<CareCard type={args.type}>
<CareCard.Heading>Ask for an urgent GP appointment if:</CareCard.Heading>
<CareCard.Content>
<ul>
Expand All @@ -94,8 +100,9 @@ export const Urgent: Story = {
};

export const Immediate: Story = {
render: () => (
<CareCard type="immediate">
args: { type: 'immediate' },
render: (args) => (
<CareCard type={args.type}>
<CareCard.Heading>Call 999 if you have sudden chest pain that:</CareCard.Heading>
<CareCard.Content>
<ul>
Expand All @@ -113,8 +120,11 @@ export const Immediate: Story = {
};

export const WithoutVisuallyHiddenText: Story = {
render: () => (
<CareCard type="non-urgent">
args: {
type: 'non-urgent',
},
render: (args) => (
<CareCard type={args.type}>
<CareCard.Heading visuallyHiddenText={false}>Speak to a GP if:</CareCard.Heading>
<CareCard.Content>
<ul>
Expand All @@ -135,8 +145,11 @@ export const WithoutVisuallyHiddenText: Story = {
};

export const WithCustomVisuallyHiddenText: Story = {
render: () => (
<CareCard type="non-urgent">
args: {
type: 'non-urgent',
},
render: (args) => (
<CareCard type={args.type}>
<CareCard.Heading visuallyHiddenText="Custom Hidden Text">Speak to a GP if:</CareCard.Heading>
<CareCard.Content>
<ul>
Expand Down
20 changes: 12 additions & 8 deletions stories/Components/Checkboxes.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ const meta: Meta<typeof Checkboxes> = {
export default meta;
type Story = StoryObj<typeof Checkboxes>;

Checkboxes.Box.displayName = 'Checkboxes.Box';

export const Standard: Story = {
render: () => (
render: (args) => (
<Fieldset aria-describedby="nationality--hint">
<Fieldset.Legend>What is your nationality?</Fieldset.Legend>
<Checkboxes
idPrefix={args.idPrefix}
name="nationality"
id="nationality"
hint="If you have more than 1 nationality, select all options that are relevant to you."
Expand All @@ -55,7 +58,7 @@ export const Standard: Story = {
};

export const WithHintText: Story = {
render: () => (
render: (args) => (
<Fieldset>
<Fieldset.Legend isPageHeading>How do you want to sign in?</Fieldset.Legend>
<Checkboxes>
Expand All @@ -82,7 +85,7 @@ export const WithHintText: Story = {
};

export const WithDisabledItem: Story = {
render: () => (
render: (args) => (
<Checkboxes id="colours" name="colours">
<Checkboxes.Box value="red">Red</Checkboxes.Box>
<Checkboxes.Box value="green">Green</Checkboxes.Box>
Expand All @@ -94,7 +97,7 @@ export const WithDisabledItem: Story = {
};

export const WithConditionalContent: Story = {
render: () => (
render: (args) => (
<Fieldset aria-describedby="waste--hint">
<Fieldset.Legend isPageHeading>
Which types of waste do you transport regularly?
Expand All @@ -109,7 +112,7 @@ export const WithConditionalContent: Story = {
};

export const WithLegendAsPageHeading: Story = {
render: () => (
render: (args) => (
<Fieldset aria-describedby="waste--hint">
<Fieldset.Legend isPageHeading>
Which types of waste do you transport regularly?
Expand All @@ -124,7 +127,8 @@ export const WithLegendAsPageHeading: Story = {
};

export const WithErrorBoolean: Story = {
render: function WithErrorBooleanRender() {
render: (args) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [errorToggle, setErrorToggle] = React.useState(true);
return (
<>
Expand Down Expand Up @@ -154,7 +158,8 @@ export const WithErrorBoolean: Story = {
};

export const WithErrorString: Story = {
render: function WithErrorStringRender() {
render: (args) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [error, setError] = React.useState('Please select an option');
return (
<>
Expand All @@ -176,6 +181,5 @@ export const WithErrorString: Story = {
</>
);
},

name: 'With Error (String)',
};
4 changes: 3 additions & 1 deletion stories/Components/ContentsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ const meta: Meta<typeof ContentsList> = {
export default meta;
type Story = StoryObj<typeof ContentsList>;

ContentsList.Item.displayName = 'ContentsList.Item';

export const Standard: Story = {
render: () => (
render: (args) => (
<ContentsList aria-label="Pages in this guide">
<ContentsList.Item current aria-current="page">
What is AMD?
Expand Down
6 changes: 5 additions & 1 deletion stories/Components/Details.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const meta: Meta<typeof Details> = {
export default meta;
type Story = StoryObj<typeof Details>;

Details.Summary.displayName = 'Details.Summary';
Details.Text.displayName = 'Details.Text';
Details.ExpanderGroup.displayName = 'Details.ExpanderGroup';

export const Standard: Story = {
argTypes: { expander: { table: { disable: true } } },
render: ({ expander }) => (
Expand Down Expand Up @@ -125,7 +129,7 @@ export const Expander: Story = {
};

export const ExpanderGroup: Story = {
render: () => (
render: (args) => (
<Details.ExpanderGroup>
<Details expander>
<Details.Summary>How to measure your blood glucose levels</Details.Summary>
Expand Down
6 changes: 4 additions & 2 deletions stories/Components/DoDontList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ const meta: Meta<typeof DoDontList> = {
export default meta;
type Story = StoryObj<typeof DoDontList>;

DoDontList.Item.displayName = 'DoDontList.Item';

export const Do: Story = {
render: () => (
render: (args) => (
<DoDontList listType="do">
<DoDontList.Item>
cover blisters that are likely to burst with a soft plaster or dressing
Expand All @@ -60,7 +62,7 @@ export const Do: Story = {
};

export const Dont: Story = {
render: () => (
render: (args) => (
<DoDontList listType="dont">
<DoDontList.Item>burst a blister yourself</DoDontList.Item>
<DoDontList.Item>peel the skin off a burst blister</DoDontList.Item>
Expand Down
4 changes: 3 additions & 1 deletion stories/Components/ErrorMessage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const meta: Meta<typeof ErrorMessage> = {
export default meta;
type Story = StoryObj<typeof ErrorMessage>;

export const Standard: Story = { argTypes: { visuallyHiddenText: { control: false } } };
export const Standard: Story = {
argTypes: { visuallyHiddenText: { control: false } },
};
export const NoVisuallyHiddenText: Story = {
args: { visuallyHiddenText: false },
argTypes: { visuallyHiddenText: { control: false } },
Expand Down
7 changes: 6 additions & 1 deletion stories/Components/ErrorSummary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ const meta: Meta<typeof ErrorSummary> = {
export default meta;
type Story = StoryObj<typeof ErrorSummary>;

ErrorSummary.Title.displayName = 'ErrorSummary.Title';
ErrorSummary.Body.displayName = 'ErrorSummary.Body';
ErrorSummary.List.displayName = 'ErrorSummary.List';
ErrorSummary.Item.displayName = 'ErrorSummary.Item';

export const Standard: Story = {
render: () => (
render: (args) => (
<ErrorSummary aria-labelledby="error-summary-title" role="alert" tabIndex={-1}>
<ErrorSummary.Title id="error-summary-title">There is a problem</ErrorSummary.Title>
<ErrorSummary.Body>
Expand Down
6 changes: 4 additions & 2 deletions stories/Components/Fieldset.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ const meta: Meta<typeof Fieldset> = {
export default meta;
type Story = StoryObj<typeof Fieldset>;

Fieldset.Legend.displayName = 'Fieldset.Legend';

export const Standard: Story = {};

export const AsAPageHeading: Story = {
render: () => (
render: (args) => (
<Fieldset>
<Fieldset.Legend isPageHeading>What is your address?</Fieldset.Legend>
</Fieldset>
),
};

export const WithCustomLegendSize: Story = {
render: () => (
render: (args) => (
<Fieldset>
<Fieldset.Legend size="m">What is your address?</Fieldset.Legend>
</Fieldset>
Expand Down
6 changes: 5 additions & 1 deletion stories/Components/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ const meta: Meta<typeof Footer> = {
export default meta;
type Story = StoryObj<typeof Footer>;

Footer.List.displayName = 'Footer.List';
Footer.ListItem.displayName = 'Footer.ListItem';
Footer.Copyright.displayName = 'Footer.Copyright';

export const Standard: Story = {
render: () => (
render: (args) => (
<>
<div id="restOfThePage" style={{ height: '60vh' }} />
<Footer>
Expand Down
2 changes: 1 addition & 1 deletion stories/Components/Grid.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const meta: Meta = {
export default meta;

export const Grid: StoryObj = {
render: () => (
render: (args) => (
<Container>
<Row>
<Col width="full">
Expand Down
Loading