@@ -5,7 +5,7 @@ import { logger } from 'storybook/internal/client-logger';
55import { Bar , Button , ToggleButton , Zoom } from 'storybook/internal/components' ;
66import type { ActionItem } from 'storybook/internal/components' ;
77
8- import { CopyIcon , MarkupIcon } from '@storybook/icons' ;
8+ import { CopyIcon , MarkupIcon , UndoIcon } from '@storybook/icons' ;
99
1010import { useId } from '@react-aria/utils' ;
1111import { darken } from 'polished' ;
@@ -31,6 +31,7 @@ export type PreviewProps = PropsWithChildren<{
3131 withToolbar ?: boolean ;
3232 className ?: string ;
3333 additionalActions ?: ActionItem [ ] ;
34+ onResetStory ?: ( ) => void ;
3435} > ;
3536
3637export type Layout = 'padded' | 'fullscreen' | 'centered' ;
@@ -150,6 +151,7 @@ export const Preview: FC<PreviewProps> = ({
150151 className,
151152 layout = 'padded' ,
152153 inline = false ,
154+ onResetStory,
153155 ...props
154156} ) => {
155157 const [ expanded , setExpanded ] = useState ( isExpanded ) ;
@@ -225,7 +227,7 @@ export const Preview: FC<PreviewProps> = ({
225227 </ div >
226228 ) }
227229 </ PreviewContainer >
228- { ( withSource || additionalActionItems . length > 0 ) && (
230+ { ( withSource || onResetStory || additionalActionItems . length > 0 ) && (
229231 < ActionBar className = "sbdocs sbdocs-preview-actions" innerStyle = { { paddingInline : 0 } } >
230232 { hasSourceError && (
231233 < Button
@@ -255,6 +257,16 @@ export const Preview: FC<PreviewProps> = ({
255257 </ Button >
256258 </ >
257259 ) }
260+ { onResetStory && (
261+ < Button
262+ ariaLabel = { false }
263+ variant = "ghost"
264+ onClick = { onResetStory }
265+ className = "docblock-reset-story"
266+ >
267+ < UndoIcon /> Reset story
268+ </ Button >
269+ ) }
258270 { additionalActionItems . map ( ( { title, className, onClick, disabled } , index : number ) => (
259271 < Button
260272 key = { index }
0 commit comments