-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] Checkbox 공통 컴포넌트 구현 #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
39e966b
feat(ui): Checkbox 공통 컴포넌트 구현 (#53)
jjangminii c3cc6e8
fix(ui): Checkbox 스타일 수정 및 Storybook 인터랙션 오류 수정 (#53)
jjangminii c98a503
fix(ui): Checkbox disabled 체크마크 색상 수정 (#53)
jjangminii e10e194
feat(ui): Checkbox 접근성 개선 — htmlFor/id 연결 및 키보드 포커스 표시 (#53)
jjangminii 7c3d810
Merge remote-tracking branch 'origin/develop' into feat/ui/53-checkbo…
jjangminii d9f2b60
style(ui): Checkbox 스토리 autodocs 태그 제거 (#53)
jjangminii 2d6638a
style(ui): Checkbox 크기 클래스를 Tailwind 스케일 값으로 변경 (#53)
jjangminii 18fc2f1
Merge remote-tracking branch 'origin/develop' into feat/ui/53-checkbo…
jjangminii 55effd2
refactor(ui): Checkbox cn import를 절대경로로 전환 (#53)
jjangminii 336b6ce
style(ui): Checkbox.tsx 중복 빈 줄 제거 (#53)
jjangminii 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
50 changes: 50 additions & 0 deletions
50
packages/timo-design-system/src/components/checkbox/Checkbox.stories.tsx
This file contains hidden or 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,50 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| import { Checkbox } from "./Checkbox"; | ||
|
|
||
| import type { Meta, StoryObj } from "@storybook/react"; | ||
|
|
||
| const meta: Meta<typeof Checkbox> = { | ||
| title: "Components/Checkbox", | ||
| component: Checkbox, | ||
| argTypes: { | ||
| checked: { control: "boolean" }, | ||
| disabled: { control: "boolean" }, | ||
| }, | ||
| args: { | ||
| checked: false, | ||
| disabled: false, | ||
| onChange: () => {}, | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof Checkbox>; | ||
|
|
||
| const PlaygroundCheckbox = (args: React.ComponentProps<typeof Checkbox>) => { | ||
| const [checked, setChecked] = useState(args.checked); | ||
| return <Checkbox {...args} checked={checked} onChange={setChecked} />; | ||
| }; | ||
|
|
||
| export const Playground: Story = { | ||
| render: (args) => <PlaygroundCheckbox {...args} />, | ||
| }; | ||
|
|
||
| export const AllStates: Story = { | ||
| render: () => ( | ||
| <div className="flex items-center gap-6"> | ||
| <div className="flex flex-col items-center gap-2"> | ||
| <Checkbox checked={false} onChange={() => {}} /> | ||
| <p className="text-xs">Unchecked</p> | ||
| </div> | ||
| <div className="flex flex-col items-center gap-2"> | ||
| <Checkbox checked={true} onChange={() => {}} /> | ||
| <p className="text-xs">Checked</p> | ||
| </div> | ||
| <div className="flex flex-col items-center gap-2"> | ||
| <Checkbox checked={true} disabled onChange={() => {}} /> | ||
| <p className="text-xs">Disabled</p> | ||
| </div> | ||
| </div> | ||
| ), | ||
| }; | ||
65 changes: 65 additions & 0 deletions
65
packages/timo-design-system/src/components/checkbox/Checkbox.tsx
This file contains hidden or 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,65 @@ | ||
| import { cn } from "@lib"; | ||
| import { useId } from "react"; | ||
|
|
||
| export interface CheckboxProps { | ||
| checked: boolean; | ||
| onChange: (checked: boolean) => void; | ||
| disabled?: boolean; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const Checkbox = ({ | ||
| checked, | ||
| onChange, | ||
| disabled = false, | ||
| className, | ||
| }: CheckboxProps) => { | ||
| const id = useId(); | ||
| return ( | ||
| <label | ||
| htmlFor={id} | ||
| className={cn( | ||
| "relative inline-flex h-6 w-6 shrink-0 items-center justify-center", | ||
| disabled ? "cursor-not-allowed" : "cursor-pointer", | ||
| className, | ||
| )} | ||
| > | ||
| <input | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| id={id} | ||
| type="checkbox" | ||
| checked={checked} | ||
| onChange={(e) => onChange(e.target.checked)} | ||
| disabled={disabled} | ||
| className="peer sr-only" | ||
| /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| <span | ||
| className={cn( | ||
| "peer-focus-visible:ring-timo-blue-300 flex h-4.5 w-4.5 items-center justify-center rounded-[4px] border transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-offset-1", | ||
| !checked && "border-timo-gray-500", | ||
| checked && !disabled && "border-timo-blue-300 bg-timo-blue-300", | ||
| checked && disabled && "bg-timo-blue-100 border-timo-blue-100", | ||
| )} | ||
| > | ||
| {(checked || disabled) && ( | ||
| <svg | ||
| width="10" | ||
| height="7" | ||
| viewBox="0 0 10 7" | ||
| overflow="visible" | ||
| fill="none" | ||
| aria-hidden="true" | ||
| className="text-timo-yellow-300" | ||
| > | ||
| <path | ||
| d="M0.75 3.5L3.5 6.25L9.25 0.75" | ||
| stroke="currentColor" | ||
| strokeWidth="1" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| </svg> | ||
| )} | ||
|
jjangminii marked this conversation as resolved.
|
||
| </span> | ||
| </label> | ||
| ); | ||
| }; | ||
This file contains hidden or 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
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Team-Timo/Timo-client
Length of output: 159
🏁 Script executed:
Repository: Team-Timo/Timo-client
Length of output: 3332
🏁 Script executed:
Repository: Team-Timo/Timo-client
Length of output: 2649
🏁 Script executed:
Repository: Team-Timo/Timo-client
Length of output: 1914
🏁 Script executed:
Repository: Team-Timo/Timo-client
Length of output: 2175
ComponentProps는react에서 타입 import로 바꿔주세요.이 파일은 이미 import가 있는 모듈이라
ReactUMD 네임스페이스가 보장되지 않고, 현재 설정에도 이를 허용하는 옵션이 없어 타입 에러로 이어질 수 있어요.import type { ComponentProps } from "react";로 바꾸면 깔끔합니다.TypeScript의 UMD globals 문서도 참고하면 좋아요: https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html#umd-globals
🤖 Prompt for AI Agents