-
-
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 branch 'next' into revert-28479-revert/26884
- Loading branch information
Showing
193 changed files
with
2,545 additions
and
924 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
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,15 @@ | ||
import type { PostinstallOptions } from '@storybook/cli/src/add'; | ||
|
||
// eslint-disable-next-line depend/ban-dependencies | ||
import { execa } from 'execa'; | ||
|
||
const $ = execa({ | ||
preferLocal: true, | ||
stdio: 'inherit', | ||
// we stream the stderr to the console | ||
reject: false, | ||
}); | ||
|
||
export default async function postinstall(options: PostinstallOptions) { | ||
await $`storybook automigrate addonA11yAddonTest ${options.yes ? '--yes' : ''}`; | ||
} |
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 |
---|---|---|
@@ -1,25 +1,17 @@ | ||
export function getIsVitestStandaloneRun() { | ||
try { | ||
return process.env.VITEST_STORYBOOK === 'false'; | ||
} catch { | ||
try { | ||
// @ts-expect-error Suppress TypeScript warning about wrong setting. Doesn't matter, because we don't use tsc for bundling. | ||
return import.meta.env.VITEST_STORYBOOK === 'false'; | ||
} catch (e) { | ||
return false; | ||
} | ||
// @ts-expect-error Suppress TypeScript warning about wrong setting. Doesn't matter, because we don't use tsc for bundling. | ||
return import.meta.env.VITEST_STORYBOOK === 'false'; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
export function getIsVitestRunning() { | ||
try { | ||
return process?.env.MODE === 'test'; | ||
} catch { | ||
try { | ||
// @ts-expect-error Suppress TypeScript warning about wrong setting. Doesn't matter, because we don't use tsc for bundling. | ||
return import.meta.env.MODE === 'test'; | ||
} catch (e) { | ||
return false; | ||
} | ||
// @ts-expect-error Suppress TypeScript warning about wrong setting. Doesn't matter, because we don't use tsc for bundling. | ||
return import.meta.env.MODE === 'test'; | ||
} catch (e) { | ||
return false; | ||
} | ||
} |
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
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, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.