mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 02:31:49 +08:00
Revert "Allow <Story/>
to reference the first story"
This reverts commit 3b68d7acc51766b06626c8237c52182bc2b13efc.
This commit is contained in:
parent
3b68d7acc5
commit
7c4dcd1d23
@ -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`;
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user