Skip to content

Commit

Permalink
react|docs: creates Switch component and story
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellmiranda committed Sep 20, 2023
1 parent 35ab166 commit 34d01c1
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 5 deletions.
12 changes: 12 additions & 0 deletions packages/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @wolves-league-ui/docs

## 0.2.0

### Minor Changes

- Creates `Switch` component story

## 0.1.2

### Patch Changes

- Improves `Checkbox` story

## 0.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wolves-league-ui/docs",
"version": "0.1.1",
"version": "0.2.0",
"main": "index.js",
"license": "MIT",
"private": true,
Expand Down
32 changes: 32 additions & 0 deletions packages/docs/src/stories/Switch.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, StoryObj } from '@storybook/react';
import { Switch } from '@wolves-league-ui/react';

const meta: Meta<typeof Switch> = {
component: Switch,
title: 'Form/Switch',
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
id: { control: 'text' },
},
};

export default meta;

type Story = StoryObj<typeof Switch>;

export const Default: Story = {
render: (args) => (
<div className="flex items-center gap-4">
<label htmlFor="switch-id" className="text-gray-100">
Label
</label>
<Switch {...args} />
</div>
),
args: {
id: 'switch-id',
},
};
9 changes: 7 additions & 2 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# @wolves-league-ui/react

## 0.2.0

### Minor Changes

- Creates `Switch` component

## 0.1.3

### Patch Changes

- - Updates `Checkbox` style
- Improves `Checkbox` story
- Updates `Checkbox` style

## 0.1.2

Expand Down
3 changes: 2 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wolves-league-ui/react",
"version": "0.1.1",
"version": "0.2.0",
"main": "./dist/index.js",
"module": "dist/index.mjs",
"types": "./dist/index.d.ts",
Expand All @@ -17,6 +17,7 @@
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.6",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/react/src/components/Switch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as SwitchPrimitive from '@radix-ui/react-switch';

export const Switch = ({ id }: { id?: string }) => (
<SwitchPrimitive.Root
id={id}
className="w-10 h-6 bg-gray-900 rounded-full relative shadow-md border border-gray-700 focus:shadow-sm data-[state=checked]:border-wl-700 outline-none cursor-default"
>
<SwitchPrimitive.Thumb className="block w-5 h-5 bg-gray-100 data-[state=checked]:bg-wl-700 rounded-full shadow-md transition-transform duration-100 translate-x-[0.063rem] will-change-transform data-[state=checked]:translate-x-[17px]" />
</SwitchPrimitive.Root>
);
Switch.displayName = 'Switch';
5 changes: 4 additions & 1 deletion packages/react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import '../index.css';
// Form
export * from './components/Button';
export * from './components/Checkbox';
export * from './components/Switch';
// Overlay
export * from './components/Tooltip';
export * from './components/Dialog';
export * from './components/Checkbox';
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34d01c1

Please sign in to comment.