Skip to content

Commit

Permalink
TabBar updates + NavigationRail docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejoYarce committed Oct 30, 2024
1 parent 545e349 commit 85c6491
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/components/NavigationRail/NavigationRail.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ const meta = {
title: 'Navigation Rail',
component: NavigationRail,
parameters: {
layout: 'centered',
layout: 'fullscreen',
docs: {
story: {
inline: false,
iframeHeight: 600,
},
},
},
// tags: ['autodocs'],
tags: ['autodocs'],
args: { onTabClick: fn() },
} satisfies Meta<typeof NavigationRail>

Expand All @@ -26,3 +32,15 @@ export const NavigationRailActive: Story = {
defaultActiveTabId: 'label-1',
},
}

export const NavigationRailActiveLeft: Story = {
args: {
tabs: [
{ id: 'label-1', label: 'Label 1', icon: <PlusSquareIcon /> },
{ id: 'label-2', label: 'Label 2', icon: <SettingsIcon /> },
{ id: 'label-3', label: 'Label 3', icon: <AddIcon /> },
],
defaultActiveTabId: 'label-1',
isOnLeft: true,
},
}
4 changes: 3 additions & 1 deletion src/components/TabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const TabBar = ({
defaultActiveTabId,
onTabClick,
}: TabBarProps) => {
const [selectedTab, setSelectedTab] = useState(defaultActiveTabId)
const [selectedTab, setSelectedTab] = useState(
defaultActiveTabId || tabs?.[0]?.id,
)

const handleOnTabClick = (id: string) => {
setSelectedTab(id)
Expand Down

0 comments on commit 85c6491

Please sign in to comment.