Skip to content

Commit

Permalink
fix: revert includePrimaryStory back to includePrimary
Browse files Browse the repository at this point in the history
Co-authored-by: Inês Ye Ji <inesji@tecnico.ulisboa.pt>
  • Loading branch information
jorge-ji committed May 25, 2024
1 parent 1e3558e commit da80e8d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions code/ui/blocks/src/blocks/Stories.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Default: Story = {
},
};
export const WithoutPrimaryStory: Story = {
args: { includePrimaryStory: false },
args: { includePrimary: false },
parameters: {
relativeCsfPaths: ['../examples/Button.stories'],
},
Expand Down Expand Up @@ -64,7 +64,7 @@ export const DefaultWithOf: Story = {
export const WithoutPrimaryStoryWithOf: Story = {
name: 'Without Primary Story with Of',
args: {
includePrimaryStory: false,
includePrimary: false,
of: DefaultButtonStories,
},
parameters: {
Expand Down
12 changes: 5 additions & 7 deletions code/ui/blocks/src/blocks/Stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useOf } from './useOf';

interface StoriesProps {
title?: ReactElement | string;
includePrimaryStory?: boolean;
includePrimary?: boolean;
/**
* Specify where to get the stories from.
*/
Expand All @@ -32,9 +32,7 @@ const StyledHeading: typeof Heading = styled(Heading)(({ theme }) => ({
},
}));

export const Stories: FC<StoriesProps> = (
props = { title: 'Stories', includePrimaryStory: true }
) => {
export const Stories: FC<StoriesProps> = (props = { title: 'Stories', includePrimary: true }) => {
const { of } = props;

if ('of' in props && of === undefined) {
Expand Down Expand Up @@ -62,10 +60,10 @@ export const Stories: FC<StoriesProps> = (
const { preparedMeta } = useOf(of || 'meta', ['meta']);

const title = props.title ?? preparedMeta.parameters.docs?.stories?.title;
const includePrimaryStory =
props.includePrimaryStory ?? preparedMeta.parameters.docs?.stories?.includePrimaryStory;
const includePrimary =
props.includePrimary ?? preparedMeta.parameters.docs?.stories?.includePrimary;

if (!includePrimaryStory) stories = stories.slice(1);
if (!includePrimary) stories = stories.slice(1);

if (!stories || stories.length === 0) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion code/ui/blocks/src/examples/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const meta = {
docs: {
stories: {
title: 'Stories',
includePrimaryStory: true,
includePrimary: true,
},
subtitle: 'This is the subtitle for the Button stories',
},
Expand Down
2 changes: 1 addition & 1 deletion code/ui/blocks/src/examples/ButtonNoAutodocs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const meta = {
docs: {
stories: {
title: 'Stories',
includePrimaryStory: true,
includePrimary: true,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion code/ui/blocks/src/examples/ButtonSomeAutodocs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const meta = {
docs: {
stories: {
title: 'Stories',
includePrimaryStory: true,
includePrimary: true,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion code/ui/blocks/src/examples/StoriesParameters.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const meta = {
docs: {
stories: {
title: 'Title Parameter',
includePrimaryStory: true,
includePrimary: true,
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions docs/api/doc-block-stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ import { Stories } from '@storybook/blocks';

`Stories` is configured with the following props:

### `includePrimaryStory`
### `includePrimary`

Type: `boolean`

Default: `parameters.docs.stories.includePrimaryStory`
Default: `parameters.docs.stories.includePrimary`

Determines if the collection of stories includes the primary (first) story.

<Callout variant="info" icon="💡">

If a stories file contains only one story and `includePrimaryStory={true}`, the `Stories` block will render nothing to avoid a potentially confusing situation.
If a stories file contains only one story and `includePrimary={true}`, the `Stories` block will render nothing to avoid a potentially confusing situation.

</Callout>

Expand Down

0 comments on commit da80e8d

Please sign in to comment.