Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
93ce5f6
โ™ป๏ธ Refactor: InputField ๊ณตํ†ต ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ ์ •๋ฆฌ ๋ฐ ์Šคํƒ€์ผ ํ†ตํ•ฉ
Greensod-96 Jan 1, 2026
2bb347b
โ™ป๏ธ Refactor: PasswordInput ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ ๋‹จ์ˆœํ™” ๋ฐ ์Šคํƒ€์ผ ํ†ตํ•ฉ
Greensod-96 Jan 1, 2026
cd9be8a
โ™ป๏ธ Refactor: SearchInput ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ ๋‹จ์ˆœํ™” ๋ฐ ์Šคํƒ€์ผ ํ†ตํ•ฉ
Greensod-96 Jan 1, 2026
55b14fd
โ™ป๏ธ Refactor: Input ์ปดํฌ๋„ŒํŠธ ์Šคํƒ€์ผ ํ†ตํ•ฉ ๋ฐ ๊ธฐ๋ณธ UI ๊ฐœ์„ 
Greensod-96 Jan 1, 2026
d8608da
โ™ป๏ธ Refactor: InputField ๊ตฌ์กฐ ๋‹จ์ˆœํ™” ๋ฐ children ๊ธฐ๋ฐ˜ ๋ Œ๋”๋ง ๊ฐœ์„ 
Greensod-96 Jan 1, 2026
19a6003
โ™ป๏ธ Refactor: PasswordInput ์Šคํƒ€์ผ ๋‹จ์ˆœํ™” ๋ฐ Input ์ฑ…์ž„ ๋ถ„๋ฆฌ
Greensod-96 Jan 1, 2026
2acbb69
โ™ป๏ธ Refactor: SearchInput ์Šคํƒ€์ผ ๋‹จ์ˆœํ™” ๋ฐ ๊ณตํ†ต Input ํ™œ์šฉ
Greensod-96 Jan 1, 2026
1794f38
โ™ป๏ธ Refactor: Input ์ปดํฌ๋„ŒํŠธ์— forwardRef ์ ์šฉ
Greensod-96 Jan 1, 2026
4d9aa6a
โ™ป๏ธ Refactor: InputField์— label ์—ฐ๊ฒฐ ๋ฐ ์ ‘๊ทผ์„ฑ ๊ฐœ์„ 
Greensod-96 Jan 1, 2026
18eebb0
โ™ป๏ธ Refactor: Input ์ปดํฌ๋„ŒํŠธ์—์„œ forwardRef ์ œ๊ฑฐ
Greensod-96 Jan 2, 2026
35e9641
โ™ป๏ธ Refactor: InputField์—์„œ inputProps ์ œ๊ฑฐ ๋ฐ props ๊ตฌ์กฐ ๋‹จ์ˆœํ™”
Greensod-96 Jan 2, 2026
1699df1
โ™ป๏ธ Refactor: PasswordInput ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ ๊ฐœ์„  ๋ฐ ์ ‘๊ทผ์„ฑ ๋ณด์™„
Greensod-96 Jan 2, 2026
7ea8180
โ™ป๏ธ Refactor: SearchInput props ๊ตฌ์กฐ ๊ฐœ์„ 
Greensod-96 Jan 2, 2026
5a66ca6
๐ŸŽจ Style: PasswordInput ์•„์ด์ฝ˜ ์ด๋ฏธ์ง€ alt ์†์„ฑ ์ œ๊ฑฐ
Greensod-96 Jan 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions components/input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { ComponentProps } from "react";
import clsx from "clsx";

export function Input({ className, ...props }: ComponentProps<"input">) {
type InputProps = ComponentProps<"input"> & {
inputRef?: React.Ref<HTMLInputElement>;
};

export function Input({ className, inputRef, ...props }: InputProps) {
return (
<input {...props} className={clsx("border rounded px-3 py-2", className)} />
<input
ref={inputRef}
{...props}
className={clsx(
"h-[54px] w-full rounded-[16px] border px-[20px] text-sm outline-none",
className
)}
/>
);
}
Comment on lines +4 to 19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

inputRef prop์„ ์‚ฌ์šฉํ•˜๋Š” ๋Œ€์‹  React.forwardRef๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ref๋ฅผ ์ง์ ‘ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์ด ๋” ์ผ๋ฐ˜์ ์ธ React ํŒจํ„ด์ด๋ฉฐ, ์ปดํฌ๋„ŒํŠธ์˜ ์žฌ์‚ฌ์šฉ์„ฑ๊ณผ ๊ฐ€๋…์„ฑ์„ ๋†’์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์—์„œ useRef๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋” ์ง๊ด€์ ์œผ๋กœ ref๋ฅผ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. import { ComponentProps, forwardRef } from "react";์™€ ๊ฐ™์ด forwardRef๋ฅผ importํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Suggested change
type InputProps = ComponentProps<"input"> & {
inputRef?: React.Ref<HTMLInputElement>;
};
export function Input({ className, inputRef, ...props }: InputProps) {
return (
<input {...props} className={clsx("border rounded px-3 py-2", className)} />
<input
ref={inputRef}
{...props}
className={clsx(
"h-[54px] w-full rounded-[16px] border px-[20px] text-sm outline-none",
className
)}
/>
);
}
export const Input = forwardRef<HTMLInputElement, ComponentProps<"input">>(
({ className, ...props }, ref) => {
return (
<input
ref={ref}
{...props}
className={clsx(
"h-[54px] w-full rounded-[16px] border px-[20px] text-sm outline-none",
className
)}
/>
);
}
);
Input.displayName = "Input";

33 changes: 24 additions & 9 deletions components/input/inputfield.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
import { ReactNode } from "react";
import { Input } from "./Input";
import { useId, ReactNode } from "react";
import clsx from "clsx";
import { Input } from "./Input";

interface InputFieldProps {
interface InputFieldProps extends React.ComponentProps<typeof Input> {
label?: string;
error?: string;
helperText?: string;
inputProps?: React.ComponentProps<typeof Input>;
children?: ReactNode;
className?: string;
}

export function InputField({
label,
error,
helperText,
inputProps,
children,
className,
...props
}: InputFieldProps) {
const id = useId();

return (
<div className={clsx("flex flex-col gap-1", className)}>
{label && <label className="text-sm font-medium">{label}</label>}
<div className="flex w-full flex-col gap-[10px]">
{label && (
<label htmlFor={id} className="text-[16px] font-medium text-gray-900">
{label}
</label>
)}

{children ?? <Input {...inputProps} />}
{children ?? (
<Input
id={id}
{...props}
className={clsx(
error
? "border-red-500 focus:ring-red-500"
: "border-gray-200 focus:ring-primary-500",
className
)}
/>
)}
Comment on lines +30 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

children prop์„ ์‚ฌ์šฉํ•  ๋•Œ, id, ...props ๋ฐ ์—๋Ÿฌ ์ƒํƒœ์— ๋”ฐ๋ฅธ className์ด children์œผ๋กœ ์ „๋‹ฌ๋˜์ง€ ์•Š์•„ label๊ณผ input์˜ ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง€๊ณ  ์—๋Ÿฌ ์Šคํƒ€์ผ๋ง ๋ฐ react-hook-form ์—ฐ๋™์ด ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ ‘๊ทผ์„ฑ๊ณผ ์ปดํฌ๋„ŒํŠธ์˜ ํ•ต์‹ฌ ๊ธฐ๋Šฅ์„ ์ €ํ•ดํ•˜๋Š” ์‹ฌ๊ฐํ•œ ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. React.cloneElement๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ children์—๊ฒŒ ํ•„์š”ํ•œ props๋ฅผ ์ฃผ์ž…ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ import { useId, ReactNode, cloneElement } from "react";์™€ ๊ฐ™์ด cloneElement๋ฅผ importํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

      {children ? (
        cloneElement(children as React.ReactElement, {
          id,
          ...props,
          className: clsx(
            error
              ? "border-red-500 focus:ring-red-500"
              : "border-gray-200 focus:ring-primary-500",
            (children as React.ReactElement).props.className,
            className
          ),
        })
      ) : (
        <Input
          id={id}
          {...props}
          className={clsx(
            error
              ? "border-red-500 focus:ring-red-500"
              : "border-gray-200 focus:ring-primary-500",
            className
          )}
        />
      )}


{error ? (
<p className="text-xs text-red-500">{error}</p>
Expand Down
15 changes: 8 additions & 7 deletions components/input/passwordinput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@ import { useState } from "react";
import Image from "next/image";
import { Input } from "./Input";
import type { ComponentProps } from "react";
import clsx from "clsx";

interface PasswordInputProps extends Omit<ComponentProps<"input">, "type"> {
className?: string;
}
type PasswordInputProps = ComponentProps<typeof Input>;

export function PasswordInput({ className, ...props }: PasswordInputProps) {
const [visible, setVisible] = useState(false);

return (
<div className="relative">
<div className="relative w-full">
<Input
{...props}
type={visible ? "text" : "password"}
className={`pr-10 ${className ?? ""}`}
className={clsx("pr-12", className)}
/>

<button
type="button"
aria-label={visible ? "๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆจ๊ธฐ๊ธฐ" : "๋น„๋ฐ€๋ฒˆํ˜ธ ํ‘œ์‹œ"}
aria-pressed={visible}
onClick={() => setVisible((v) => !v)}
className="absolute right-3 top-1/2 -translate-y-1/2"
className="absolute right-4 top-1/2 -translate-y-1/2 focus:outline-none focus:ring-2 focus:ring-primary-500"
>
<Image
src={visible ? "/icon_active_on.svg" : "/icon_active_off.svg"}
alt={visible ? "๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆจ๊ธฐ๊ธฐ" : "๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณด๊ธฐ"}
alt={visible ? "๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆจ๊ธฐ๊ธฐ ์•„์ด์ฝ˜" : "๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณด๊ธฐ ์•„์ด์ฝ˜"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

๋ฒ„ํŠผ์— aria-label์ด ์ด๋ฏธ "๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆจ๊ธฐ๊ธฐ" / "๋น„๋ฐ€๋ฒˆํ˜ธ ํ‘œ์‹œ"๋กœ ๋ช…ํ™•ํ•˜๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ์œผ๋ฏ€๋กœ, ๋‚ด๋ถ€์— ์žˆ๋Š” ์•„์ด์ฝ˜์€ ์Šคํฌ๋ฆฐ ๋ฆฌ๋” ์‚ฌ์šฉ์ž์—๊ฒŒ ์ค‘๋ณต๋œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๊ฒฝ์šฐ, ์žฅ์‹์šฉ ์ด๋ฏธ์ง€๋กœ ์ทจ๊ธ‰ํ•˜์—ฌ alt ์†์„ฑ์„ ๋นˆ ๋ฌธ์ž์—ด("")๋กœ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์ ‘๊ทผ์„ฑ ๋ชจ๋ฒ” ์‚ฌ๋ก€์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์Šคํฌ๋ฆฐ ๋ฆฌ๋”๊ฐ€ ์•„์ด์ฝ˜์„ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ์ฝ์ง€ ์•Š๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

Suggested change
alt={visible ? "๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆจ๊ธฐ๊ธฐ ์•„์ด์ฝ˜" : "๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณด๊ธฐ ์•„์ด์ฝ˜"}
alt=""

width={20}
height={20}
/>
Expand Down
17 changes: 8 additions & 9 deletions components/input/searchinput.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Image from "next/image";
import { Input } from "./Input";
import type { ComponentProps } from "react";
import clsx from "clsx";

interface SearchInputProps extends ComponentProps<"input"> {
className?: string;
}

export function SearchInput({ className, ...props }: SearchInputProps) {
export function SearchInput({
className,
...props
}: ComponentProps<typeof Input>) {
return (
<div className="relative">
<Input {...props} className={`pl-10 ${className ?? ""}`} />

<span className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2">
<div className="relative w-full">
<Input {...props} className={clsx("pl-[44px]", className)} />
<span className="pointer-events-none absolute left-4 top-1/2 -translate-y-1/2">
<Image src="/icon_search.svg" alt="๊ฒ€์ƒ‰" width={20} height={20} />
</span>
</div>
Expand Down