-
Notifications
You must be signed in to change notification settings - Fork 0
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] Switch 컴포넌트, 스토리북 제작 #20
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c9a7253
feat: radix switch 설치
yougyung 155cbd5
feat: switch 컴포넌트 생성
yougyung 3514e6a
Merge branch 'main' of https://github.com/COW-dev/ddingdong2.0 into f…
yougyung 98938b6
feat: color 속성 추가
yougyung 0960cfb
fix: 모듈화 export 설정
yougyung 4f49357
fix: 불필요한 style 제거
yougyung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
*storybook.log | ||
storybook-static |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { COLORS } from '@/shared/lib/colors'; | ||
|
||
import { Switch } from '.'; | ||
|
||
const meta = { | ||
title: 'components/common/Switch', | ||
component: Switch, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Switch>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Switch>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
color: 'primary', | ||
}, | ||
argTypes: { | ||
color: { | ||
control: { type: 'select' }, | ||
table: { | ||
type: { summary: 'SwitchColor' }, | ||
defaultValue: { summary: 'primary' }, | ||
}, | ||
options: Object.keys(COLORS), | ||
}, | ||
}, | ||
render: (args) => <Switch {...args} />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as SwitchPrimitives from '@radix-ui/react-switch'; | ||
|
||
import { COLORS, SwitchColor } from '@/shared/lib/colors'; | ||
|
||
type Props = React.ComponentProps<typeof SwitchPrimitives.Root> & { | ||
/** | ||
* color of the switch. | ||
* @default 'primary' | ||
*/ | ||
color?: SwitchColor; | ||
}; | ||
|
||
export function Switch({ color = 'primary', ...props }: Props) { | ||
return ( | ||
<SwitchPrimitives.Root | ||
{...props} | ||
className="group relative flex h-3.5 w-7 items-center rounded-full shadow-lg data-[state=checked]:bg-[var(--switch-color)] data-[state=unchecked]:bg-gray-500" | ||
keemsebin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
style={color && ({ '--switch-color': COLORS[color] } as React.CSSProperties)} | ||
> | ||
<SwitchPrimitives.Thumb className="h-5 w-5 -translate-x-1.5 rounded-full bg-white shadow-inner duration-100 group-data-[state=checked]:translate-x-3.5" /> | ||
</SwitchPrimitives.Root> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Switch } from './Switch'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
피그마 상에는 다른 색상은 사용되고 있지 않은 것으로 확인했는데, 다른 색상의 사용 활용에 대해 전달받으신 부분이 있는지 궁금합니다 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR에도 남긴 부분인데, 디자인팀과는 primary 단일 색상으로 의견을 맞췄어요.
하지만 다른 색상을 적용해야하는 경우가 존재할 수 있다고 판단했고, 이 경우에 대응이 쉽도록
color 속성 + defualt
처리했어요 :)