Skip to content

Commit

Permalink
InputSearch rounded prop 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
baegofda committed Apr 21, 2024
1 parent 9b6a85a commit baccb1d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Default = () => {
formSubmitHandler = {onSubmitHandler}
onChange = {onChangeHandler}
value = {currentValue}
rounded = "rounded-8"
placeholder = "검색하기"
/>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/core/components/Input/InputSearch/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { RoundedType } from "../types";

export const ROUNDED = {
FULL: "rounded-full",
ROUNDED_12: "rounded-12",
ROUNDED_8: "rounded-8",
ROUNDED_4: "rounded-4",
} as const;

export const INPUT_SEARCH_ROUNDED: Record<RoundedType, string> = {
[ROUNDED["FULL"]]: "rounded-full",
[ROUNDED["ROUNDED_12"]]: "rounded-xl",
[ROUNDED["ROUNDED_8"]]: "rounded-lg",
[ROUNDED["ROUNDED_4"]]: "rounded",
};
7 changes: 6 additions & 1 deletion src/core/components/Input/InputSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { forwardRef, useId, useRef } from "react";
import { useInput } from "@/core/components/Input/hooks/useInput";
import { MagnifyingGlass } from "@phosphor-icons/react";
import InputBase from "../InputBase";
import { INPUT_SEARCH_ROUNDED } from "./constants";
import { InputSearchProps } from "./types";

const InputSearch = forwardRef((
{
formSubmitHandler,
regCallback,
feedback,
rounded,
...props
}: InputSearchProps,
ref: React.ComponentPropsWithRef<"input">["ref"],
Expand Down Expand Up @@ -41,7 +43,10 @@ const InputSearch = forwardRef((
readOnly = {readOnly}
disabled = {disabled}
rootClassName = {rootClassName}
inputRootClassName = {"flex items-center px-6 py-2 text-body-02-medium bg-white rounded-full overflow-hidden border border-gray-02"}
inputRootClassName = {clsx(
"flex items-center py-2 text-body-02-medium bg-white overflow-hidden border border-gray-02",
INPUT_SEARCH_ROUNDED[rounded],
)}
onSubmit = {onSubmitHandler}
inputComponent = {
<input
Expand Down
6 changes: 5 additions & 1 deletion src/core/components/Input/InputSearch/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { InputBaseProps } from "../../InputBase/types";
import { UseInputProps } from "../../hooks/useInput";
import { ROUNDED } from "../constants";

export interface InputSearchProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "readOnly" | "disabled">,
Pick<InputBaseProps<"div">, "feedback" | "rootClassName" | "error" | "readOnly" | "disabled">,
Pick<UseInputProps, "regCallback"> {
formSubmitHandler?: (e: React.FormEvent<HTMLFormElement>) => void;
rounded: RoundedType;
formSubmitHandler?: (e: React.FormEvent<HTMLFormElement>) => void;
}

export type RoundedType = typeof ROUNDED[keyof typeof ROUNDED];

0 comments on commit baccb1d

Please sign in to comment.