Skip to content

Commit 30507e6

Browse files
authored
feat:#52 add tabs story (#73)
1 parent 7795843 commit 30507e6

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { Meta, StoryObj } from '@storybook/react';
2+
import { Button } from '../button';
3+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../card';
4+
import { Input } from '../input';
5+
import { Label } from '../label';
6+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../tabs';
7+
function TabsDemo() {
8+
return (
9+
<Tabs
10+
defaultValue='account'
11+
className='w-[400px]'
12+
>
13+
<TabsList className='grid w-full grid-cols-2'>
14+
<TabsTrigger value='account'>Account</TabsTrigger>
15+
<TabsTrigger value='password'>Password</TabsTrigger>
16+
</TabsList>
17+
<TabsContent value='account'>
18+
<Card>
19+
<CardHeader>
20+
<CardTitle>Account</CardTitle>
21+
<CardDescription>Make changes to your account here. Click save when you're done.</CardDescription>
22+
</CardHeader>
23+
<CardContent className='space-y-2'>
24+
<div className='space-y-1'>
25+
<Label htmlFor='name'>Name</Label>
26+
<Input
27+
id='name'
28+
defaultValue='Pedro Duarte'
29+
/>
30+
</div>
31+
<div className='space-y-1'>
32+
<Label htmlFor='username'>Username</Label>
33+
<Input
34+
id='username'
35+
defaultValue='@peduarte'
36+
/>
37+
</div>
38+
</CardContent>
39+
<CardFooter>
40+
<Button>Save changes</Button>
41+
</CardFooter>
42+
</Card>
43+
</TabsContent>
44+
<TabsContent value='password'>
45+
<Card>
46+
<CardHeader>
47+
<CardTitle>Password</CardTitle>
48+
<CardDescription>Change your password here. After saving, you'll be logged out.</CardDescription>
49+
</CardHeader>
50+
<CardContent className='space-y-2'>
51+
<div className='space-y-1'>
52+
<Label htmlFor='current'>Current password</Label>
53+
<Input
54+
id='current'
55+
type='password'
56+
/>
57+
</div>
58+
<div className='space-y-1'>
59+
<Label htmlFor='new'>New password</Label>
60+
<Input
61+
id='new'
62+
type='password'
63+
/>
64+
</div>
65+
</CardContent>
66+
<CardFooter>
67+
<Button>Save password</Button>
68+
</CardFooter>
69+
</Card>
70+
</TabsContent>
71+
</Tabs>
72+
);
73+
}
74+
const meta = {
75+
title: 'CODERUM/Tabs',
76+
component: TabsDemo,
77+
78+
parameters: {
79+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
80+
layout: 'centered',
81+
},
82+
} satisfies Meta<typeof TabsDemo>;
83+
export default meta;
84+
type Story = StoryObj<typeof meta>;
85+
export const TabsExample: Story = {};

packages/ui/src/styles/tailwind.css

+34
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ body {
638638
margin-bottom: 0.5rem;
639639
}
640640

641+
.mr-2 {
642+
margin-right: 0.5rem;
643+
}
644+
641645
.mt-2 {
642646
margin-top: 0.5rem;
643647
}
@@ -714,6 +718,10 @@ body {
714718
width: 16rem;
715719
}
716720

721+
.w-80 {
722+
width: 20rem;
723+
}
724+
717725
.w-9 {
718726
width: 2.25rem;
719727
}
@@ -730,6 +738,10 @@ body {
730738
width: 360px;
731739
}
732740

741+
.w-\[400px\] {
742+
width: 400px;
743+
}
744+
733745
.w-full {
734746
width: 100%;
735747
}
@@ -766,6 +778,10 @@ body {
766778
cursor: pointer;
767779
}
768780

781+
.grid-cols-2 {
782+
grid-template-columns: repeat(2, minmax(0, 1fr));
783+
}
784+
769785
.flex-col {
770786
flex-direction: column;
771787
}
@@ -786,6 +802,10 @@ body {
786802
justify-content: center;
787803
}
788804

805+
.justify-between {
806+
justify-content: space-between;
807+
}
808+
789809
.gap-1 {
790810
gap: 0.25rem;
791811
}
@@ -808,6 +828,12 @@ body {
808828
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
809829
}
810830

831+
.space-x-4 > :not([hidden]) ~ :not([hidden]) {
832+
--tw-space-x-reverse: 0;
833+
margin-right: calc(1rem * var(--tw-space-x-reverse));
834+
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
835+
}
836+
811837
.space-y-1 > :not([hidden]) ~ :not([hidden]) {
812838
--tw-space-y-reverse: 0;
813839
margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
@@ -990,6 +1016,10 @@ body {
9901016
padding-top: 0px;
9911017
}
9921018

1019+
.pt-2 {
1020+
padding-top: 0.5rem;
1021+
}
1022+
9931023
.text-center {
9941024
text-align: center;
9951025
}
@@ -1087,6 +1117,10 @@ body {
10871117
text-underline-offset: 4px;
10881118
}
10891119

1120+
.opacity-70 {
1121+
opacity: 0.7;
1122+
}
1123+
10901124
.shadow-\[0_2px_10px\] {
10911125
--tw-shadow: 0 2px 10px;
10921126
--tw-shadow-colored: 0 2px 10px var(--tw-shadow-color);

0 commit comments

Comments
 (0)