Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components): style Tabs as links #1473

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
),
],
};
Loading