-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30041 from storybookjs/version-non-patch-from-8.5…
….0-alpha.21 Release: Prerelease 8.5.0-alpha.22
- Loading branch information
Showing
82 changed files
with
1,339 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
|
||
import { AddonPanel, type SyntaxHighlighterFormatTypes } from 'storybook/internal/components'; | ||
import { ADDON_ID, PANEL_ID, PARAM_KEY, SNIPPET_RENDERED } from 'storybook/internal/docs-tools'; | ||
import { addons, types, useAddonState, useChannel } from 'storybook/internal/manager-api'; | ||
|
||
import { Source } from '@storybook/blocks'; | ||
|
||
addons.register(ADDON_ID, (api) => { | ||
addons.add(PANEL_ID, { | ||
title: 'Code', | ||
type: types.PANEL, | ||
paramKey: PARAM_KEY, | ||
/** | ||
* This code panel can be disabled by the user by adding this parameter: | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* parameters: { | ||
* docs: { | ||
* codePanel: false, | ||
* }, | ||
* }, | ||
* ``` | ||
*/ | ||
disabled: (parameters) => { | ||
return ( | ||
!!parameters && | ||
typeof parameters[PARAM_KEY] === 'object' && | ||
parameters[PARAM_KEY].codePanel === false | ||
); | ||
}, | ||
match: ({ viewMode }) => viewMode === 'story', | ||
render: ({ active }) => { | ||
const [codeSnippet, setSourceCode] = useAddonState<{ | ||
source: string; | ||
format: SyntaxHighlighterFormatTypes; | ||
}>(ADDON_ID, { | ||
source: '', | ||
format: 'html', | ||
}); | ||
|
||
useChannel({ | ||
[SNIPPET_RENDERED]: ({ source, format }) => { | ||
setSourceCode({ source, format }); | ||
}, | ||
}); | ||
|
||
return ( | ||
<AddonPanel active={!!active}> | ||
<Source code={codeSnippet.source} format={codeSnippet.format} dark /> | ||
</AddonPanel> | ||
); | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
code/addons/docs/template/stories/sourcePanel/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export default { | ||
component: globalThis.Components.Button, | ||
tags: ['autodocs'], | ||
parameters: { | ||
chromatic: { disable: true }, | ||
docs: { | ||
codePanel: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const One = { args: { label: 'One' } }; | ||
|
||
export const Two = { args: { label: 'Two' } }; | ||
|
||
export const WithSource = { | ||
args: { label: 'Three' }, | ||
parameters: { | ||
docs: { | ||
codePanel: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @ts-expect-error (no types needed for this) | ||
export * from '@storybook/addon-docs/manager'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.