mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
feat: add showSettingsPage api for proper routing
This commit is contained in:
parent
1131f5d978
commit
1c2ff95046
@ -8,7 +8,7 @@ type Direction = -1 | 1;
|
|||||||
type StoryId = string;
|
type StoryId = string;
|
||||||
type ParameterName = string;
|
type ParameterName = string;
|
||||||
|
|
||||||
type ViewMode = 'story' | 'info' | undefined;
|
type ViewMode = 'story' | 'info' | 'settings' | undefined;
|
||||||
|
|
||||||
export interface SubState {
|
export interface SubState {
|
||||||
storiesHash: StoriesHash;
|
storiesHash: StoriesHash;
|
||||||
@ -306,6 +306,19 @@ Did you create a path that uses the separator char accidentally, such as 'Vue <d
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Navigate to settings page by changing the viewMode state and route
|
||||||
|
// to the specific settings page.
|
||||||
|
const showSettingsPage = (storyId: string) => {
|
||||||
|
store.setState(
|
||||||
|
{
|
||||||
|
viewMode: 'settings',
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
navigate(`/settings/${storyId}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
api: {
|
api: {
|
||||||
storyId: toId,
|
storyId: toId,
|
||||||
@ -317,6 +330,7 @@ Did you create a path that uses the separator char accidentally, such as 'Vue <d
|
|||||||
getData,
|
getData,
|
||||||
getParameters,
|
getParameters,
|
||||||
getCurrentParameter,
|
getCurrentParameter,
|
||||||
|
showSettingsPage,
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
storiesHash: {},
|
storiesHash: {},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user