-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storybook: Add TabbedSidebar stories and improve docs (#68118)
* Add stories and improve TabbedSidebar docs * Refactor TabbedSidebar story * Make TabbedSidebar story props controllable Co-authored-by: Sukhendu2002 <[email protected]> Co-authored-by: t-hamano <[email protected]>
- Loading branch information
1 parent
67cc9d5
commit 0f2a584
Showing
3 changed files
with
166 additions
and
13 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
104 changes: 104 additions & 0 deletions
104
packages/block-editor/src/components/tabbed-sidebar/stories/index.story.js
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,104 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import TabbedSidebar from '../'; | ||
|
||
const meta = { | ||
title: 'BlockEditor/TabbedSidebar', | ||
component: TabbedSidebar, | ||
tags: [ 'status-private' ], | ||
parameters: { | ||
docs: { | ||
canvas: { sourceState: 'shown' }, | ||
description: { | ||
component: | ||
'A component that creates a tabbed sidebar with a close button.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
defaultTabId: { | ||
control: { type: null }, | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
description: | ||
'The ID of the tab to be selected by default when the component renders.', | ||
}, | ||
onClose: { | ||
action: 'onClose', | ||
control: { type: null }, | ||
table: { | ||
type: { summary: 'function' }, | ||
}, | ||
description: 'Function called when the close button is clicked.', | ||
}, | ||
onSelect: { | ||
action: 'onSelect', | ||
control: { type: null }, | ||
table: { | ||
type: { summary: 'function' }, | ||
}, | ||
description: | ||
"Function called when a tab is selected. Receives the selected tab's ID as an argument.", | ||
}, | ||
selectedTab: { | ||
control: { type: null }, | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
description: 'The ID of the currently selected tab.', | ||
}, | ||
tabs: { | ||
control: { type: 'array' }, | ||
table: { | ||
type: { summary: 'array' }, | ||
}, | ||
description: | ||
'Array of tab objects. Each tab should have: name (string), title (string), panel (React.Node), and optionally panelRef (React.Ref).', | ||
}, | ||
closeButtonLabel: { | ||
control: { type: 'text' }, | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
description: 'Accessibility label for the close button.', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const DEMO_TABS = [ | ||
{ name: 'tab1', title: 'Settings' }, | ||
{ name: 'tab2', title: 'Styles' }, | ||
{ name: 'tab3', title: 'Advanced' }, | ||
]; | ||
|
||
export const Default = { | ||
render: function Template( { onSelect, onClose, ...args } ) { | ||
const [ selectedTab, setSelectedTab ] = useState(); | ||
|
||
return ( | ||
<TabbedSidebar | ||
{ ...args } | ||
selectedTab={ selectedTab } | ||
onSelect={ ( ...changeArgs ) => { | ||
onSelect( ...changeArgs ); | ||
setSelectedTab( ...changeArgs ); | ||
} } | ||
onClose={ onClose } | ||
/> | ||
); | ||
}, | ||
args: { | ||
tabs: DEMO_TABS, | ||
defaultTabId: 'tab1', | ||
closeButtonLabel: 'Close Sidebar', | ||
}, | ||
}; |
0f2a584
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 0f2a584.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12596397323
📝 Reported issues:
/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js
/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js