support deprecated API unattached

This commit is contained in:
Jeppe Reinhold 2023-01-22 23:31:50 +01:00
parent 0984503694
commit d23bed8074
2 changed files with 14 additions and 3 deletions

View File

@ -128,10 +128,17 @@ export const Canvas: FC<CanvasProps & DeprecatedCanvasProps> = (props) => {
const docsContext = useContext(DocsContext);
const sourceContext = useContext(SourceContext);
const { children, of, source } = props;
const sourceProps = useSourceProps({ ...source, of }, docsContext, sourceContext);
const { isLoading, previewProps } = useDeprecatedPreviewProps(props, docsContext, sourceContext);
const { story } = useOf(of || 'story', ['story']);
let story;
let sourceProps;
try {
({ story } = useOf(of || 'story', ['story']));
sourceProps = useSourceProps({ ...source, of }, docsContext, sourceContext);
} catch (error) {
if (!children) {
throw error;
}
}
if (props.withSource) {
deprecate(dedent`Setting source state with \`withSource\` is deprecated, please use \`sourceState\` with 'hidden', 'shown' or 'none' instead.

View File

@ -46,6 +46,10 @@ const expectAmountOfStoriesInSource =
export const BasicStoryChild: Story = {};
export const BasicStoryChildUnattached: Story = {
parameters: { attached: false },
};
export const WithSourceOpen: Story = {
args: {
withSource: SourceState.OPEN,