Skip to content

Commit

Permalink
feat(components): style Tabs as links
Browse files Browse the repository at this point in the history
  • Loading branch information
Niznikr committed Nov 6, 2024
1 parent 34f1227 commit b6baafb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-lamps-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@launchpad-ui/components": patch
---

Style `Tabs` as links
1 change: 1 addition & 0 deletions packages/components/src/styles/Tabs.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
border-bottom: 2px solid transparent;
position: relative;
outline: none;
text-decoration: none;

&[data-hovered] {
background-color: var(--lp-color-bg-interactive-secondary-hover);
Expand Down
36 changes: 36 additions & 0 deletions packages/components/stories/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react';
import { Tab, TabList, TabPanel, Tabs } from '../src';

import { userEvent, within } from '@storybook/test';
import { Route, Routes, useLocation } from 'react-router-dom';

const meta: Meta<typeof Tabs> = {
component: Tabs,
Expand Down Expand Up @@ -64,3 +65,38 @@ export const States: Story = {
await userEvent.hover(tabs[2]);
},
};

export const Links: Story = {
render: (args) => {
const { pathname } = useLocation();
return (
<Tabs selectedKey={pathname} {...args}>
<TabList aria-label="tabs">
<Tab id="/tab1" href="/tab1">
Tab 1
</Tab>
<Tab id="/tab2" href="/tab2">
Tab 2
</Tab>
<Tab id="/tab3" href="/tab3">
Tab 3
</Tab>
</TabList>
<TabPanel id={pathname}>
<Routes>
<Route path="/tab1" element={<>Tab body 1</>} />
<Route path="/tab2" element={<>Tab body 2</>} />
<Route path="/tab3" element={<>Tab body 3</>} />
</Routes>
</TabPanel>
</Tabs>
);
},
decorators: [
(Story) => (
<Routes>
<Route path="/*" element={<Story />} />
</Routes>
),
],
};

0 comments on commit b6baafb

Please sign in to comment.