-
-
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 #7 from storybookjs/rerun-tool
"Rerun story" tool
- Loading branch information
Showing
2 changed files
with
6 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
import React, { useCallback } from 'react'; | ||
import { useGlobals } from '@storybook/api'; | ||
import React from 'react'; | ||
import { useChannel } from '@storybook/api'; | ||
import { Icons, IconButton } from '@storybook/components'; | ||
import { TOOL_ID } from './constants'; | ||
import { EVENTS, TOOL_ID } from './constants'; | ||
|
||
export const Tool = () => { | ||
const [{ myAddon }, updateGlobals] = useGlobals(); | ||
|
||
const toggleMyTool = useCallback( | ||
() => | ||
updateGlobals({ | ||
myAddon: myAddon ? undefined : true, | ||
}), | ||
[myAddon] | ||
); | ||
|
||
const emit = useChannel({}); | ||
return ( | ||
<IconButton key={TOOL_ID} title="Play" onClick={toggleMyTool}> | ||
<Icons icon="play" /> | ||
<IconButton key={TOOL_ID} title="Rerun story" onClick={() => emit(EVENTS.RELOAD)}> | ||
<Icons icon="sync" /> | ||
</IconButton> | ||
); | ||
}; |
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