mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Fix source stories
This commit is contained in:
parent
2ae53e972d
commit
9e85162b87
@ -4,18 +4,22 @@ import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import { Source } from './Source';
|
||||
import * as ParametersStories from '../examples/SourceParameters.stories';
|
||||
import { SourceContext } from './SourceContainer';
|
||||
import { argsHash, SourceContext } from './SourceContainer';
|
||||
|
||||
const meta: Meta<typeof Source> = {
|
||||
component: Source,
|
||||
parameters: {
|
||||
relativeCsfPaths: ['../examples/SourceParameters.stories'],
|
||||
snippets: {
|
||||
'storybook-blocks-example-sourceparameters--no-parameters': {
|
||||
code: `const emitted = 'source';`,
|
||||
'storybook-blocks-examples-stories-for-the-source-block--no-parameters': {
|
||||
[argsHash({})]: {
|
||||
code: `const emitted = 'source';`,
|
||||
},
|
||||
},
|
||||
'storybook-blocks-example-sourceparameters--type-dynamic': {
|
||||
code: `const emitted = 'source';`,
|
||||
'storybook-blocks-examples-stories-for-the-source-block--type-dynamic': {
|
||||
[argsHash({})]: {
|
||||
code: `const emitted = 'source';`,
|
||||
},
|
||||
},
|
||||
},
|
||||
docsStyles: true,
|
||||
|
@ -74,6 +74,7 @@ const getStorySource = (
|
||||
sourceContext: SourceContextProps
|
||||
): SourceItem => {
|
||||
const { sources } = sourceContext;
|
||||
console.log(storyId, sources, argsHash(args));
|
||||
// source rendering is async so source is unavailable at the start of the render cycle,
|
||||
// so we fail gracefully here without warning
|
||||
return sources?.[storyId]?.[argsHash(args)] || { code: '' };
|
||||
|
Loading…
x
Reference in New Issue
Block a user