Repository navigation
[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
Changes from 3 commits
39e966b
c3cc6e8
c98a503
e10e194
7c3d810
d9f2b60
2d6638a
18fc2f1
55effd2
336b6ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| 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, | ||
| tags: ["autodocs"], | ||
| 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>) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# React 네임스페이스가 전역으로 선언되어 있는지 확인
rg -n "declare global" -g '*.d.ts' packages/timo-design-system
rg -n "\"types\"" packages/timo-design-system/tsconfig.jsonRepository: Team-Timo/Timo-client Length of output: 159 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 파일 구조와 해당 스토리 파일, tsconfig, 그리고 React 타입 선언 여부를 확인
git ls-files packages/timo-design-system | sed -n '1,200p'
printf '\n--- Checkbox.stories.tsx ---\n'
cat -n packages/timo-design-system/src/components/checkbox/Checkbox.stories.tsx
printf '\n--- tsconfig files ---\n'
git ls-files 'packages/timo-design-system/*tsconfig*' 'packages/*/*tsconfig*' | sed -n '1,200p'
printf '\n--- React typings search ---\n'
rg -n "declare (global|namespace React)|namespace React|type ComponentProps|import type \{[^}]*ComponentProps" packages/timo-design-system . -g '*.d.ts' -g '*.ts' -g '*.tsx' -g 'tsconfig*.json'Repository: Team-Timo/Timo-client Length of output: 3332 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n--- packages/timo-design-system/tsconfig.json ---\n'
cat -n packages/timo-design-system/tsconfig.json
printf '\n--- packages/timo-design-system/package.json ---\n'
cat -n packages/timo-design-system/package.json
printf '\n--- React-related imports/usages in design-system ---\n'
rg -n "React\.ComponentProps|from \"react\"|from 'react'|namespace React|declare global" packages/timo-design-system/src packages/timo-design-system/.storybook -g '*.ts' -g '*.tsx' -g '*.d.ts'Repository: Team-Timo/Timo-client Length of output: 2649 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n--- react-library tsconfig ---\n'
rg -n "allowUmdGlobalAccess|jsx|types|moduleResolution|esModuleInterop|verbatimModuleSyntax" \
-g 'react-library.json' -g '*.json' packages node_modules 2>/dev/null || true
printf '\n--- likely shared tsconfig files ---\n'
git ls-files | rg 'typescript-config/.+json$|tsconfig.*json$'
printf '\n--- React type definition clues in `@types/react` if vendored in repo ---\n'
rg -n "export as namespace React|declare namespace React|ComponentProps" \
-g '*.d.ts' -g '*.ts' -g '*.tsx' .Repository: Team-Timo/Timo-client Length of output: 1914 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n--- packages/typescript-config/react-library.json ---\n'
cat -n packages/typescript-config/react-library.json
printf '\n--- packages/typescript-config/base.json ---\n'
cat -n packages/typescript-config/base.json
printf '\n--- checkbox story exact lines ---\n'
sed -n '1,40p' packages/timo-design-system/src/components/checkbox/Checkbox.stories.tsxRepository: Team-Timo/Timo-client Length of output: 2175
🤖 Prompt for AI Agents |
||
| 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> | ||
| ), | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { cn } from "../../lib/cn"; | ||
|
jjangminii marked this conversation as resolved.
Outdated
|
||
|
|
||
| export interface CheckboxProps { | ||
| checked: boolean; | ||
| onChange: (checked: boolean) => void; | ||
| disabled?: boolean; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const Checkbox = ({ | ||
| checked, | ||
| onChange, | ||
| disabled = false, | ||
| className, | ||
| }: CheckboxProps) => { | ||
| return ( | ||
| <label | ||
| 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.
|
||
| type="checkbox" | ||
| checked={checked} | ||
| onChange={(e) => onChange(e.target.checked)} | ||
| disabled={disabled} | ||
| className="sr-only" | ||
| /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| <span | ||
| className={cn( | ||
| "flex h-[18px] w-[18px] items-center justify-center rounded-[4px] border transition-colors", | ||
| !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> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export { Checkbox } from "./checkbox/Checkbox"; | ||
| export { Color } from "./color/Color"; | ||
| export { Typography } from "./typography/Typography"; |
Uh oh!
There was an error while loading. Please reload this page.