Revert "Allow <Story/> to reference the first story"

This reverts commit 3b68d7acc51766b06626c8237c52182bc2b13efc.
This commit is contained in:
Tom Coleman 2023-01-24 21:38:43 +11:00
parent 3b68d7acc5
commit 7c4dcd1d23
2 changed files with 8 additions and 18 deletions

View File

@ -16,8 +16,6 @@ export default meta;
type Story = StoryObj<typeof meta>; type Story = StoryObj<typeof meta>;
export const DefaultAttached: Story = {};
export const Of: Story = { export const Of: Story = {
args: { args: {
of: ButtonStories.Primary, of: ButtonStories.Primary,
@ -31,14 +29,6 @@ export const OfWithMeta: Story = {
}, },
}; };
export const OfWithMetaUnattached: Story = {
parameters: { attached: false },
args: {
of: ButtonStories.Secondary,
meta: ButtonStories.default,
},
};
const blocksAwareId = `${ const blocksAwareId = `${
import.meta.env.STORYBOOK_BLOCKS_ONLY === 'true' ? '' : 'storybook-blocks-' import.meta.env.STORYBOOK_BLOCKS_ONLY === 'true' ? '' : 'storybook-blocks-'
}example-button--primary`; }example-button--primary`;

View File

@ -89,11 +89,6 @@ export type StoryProps = (StoryDefProps | StoryRefProps) & StoryParameters;
export const getStoryId = (props: StoryProps, context: DocsContextProps): StoryId => { export const getStoryId = (props: StoryProps, context: DocsContextProps): StoryId => {
const { id, of, meta, story } = props as StoryRefProps; const { id, of, meta, story } = props as StoryRefProps;
if (id) return id;
const { name } = props as StoryDefProps;
if (name) return context.storyIdByName(name);
// The `story={moduleExports}` prop is a legacy prop for stories defined in CSF files, but // The `story={moduleExports}` prop is a legacy prop for stories defined in CSF files, but
// "declared" in MDX files (the CSF file has no meta export or doesn't match the stories glob). // "declared" in MDX files (the CSF file has no meta export or doesn't match the stories glob).
// In this case, the `.stories.mdx` file will have actually ended up declaring the story // In this case, the `.stories.mdx` file will have actually ended up declaring the story
@ -105,9 +100,14 @@ export const getStoryId = (props: StoryProps, context: DocsContextProps): StoryI
); );
} }
if (meta) context.referenceMeta(meta, false); if (of || story) {
const resolved = context.resolveOf(of || story || 'story', ['story']); if (meta) context.referenceMeta(meta, false);
return resolved.story.id; const resolved = context.resolveOf(of || story, ['story']);
return resolved.story.id;
}
const { name } = props as StoryDefProps;
return id || context.storyIdByName(name);
}; };
// Find the first option that isn't undefined // Find the first option that isn't undefined