Skip to content

Commit

Permalink
feat: add storybook for switch component (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: Hoang, Vu <[email protected]>
  • Loading branch information
HoangVNH and hoagvnh committed May 11, 2024
1 parent 33dfbf3 commit 730fa3d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/ui/src/stories/switch.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';
import { Switch } from '../switch';
import { Label } from '../label';

const meta = {
title: 'Coderum/Switch',
component: Switch,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {},
args: {
disabled: false,
onChange: fn(),
},
} satisfies Meta<typeof Switch>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Checked: Story = {};

export const WithLabel: Story = {
render: (args) => (
<div className='flex items-center space-x-2'>
<Switch
{...args}
id='airplane-mode'
/>
<Label htmlFor='airplane-mode'>Airplane Mode</Label>
</div>
),
};

export const Disabled: Story = {
args: {
disabled: true,
},
};
6 changes: 6 additions & 0 deletions packages/ui/src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,12 @@ body {
margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));
}

.space-x-2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(0.5rem * var(--tw-space-x-reverse));
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}

.overflow-hidden {
overflow: hidden;
}
Expand Down

0 comments on commit 730fa3d

Please sign in to comment.