-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/CDP-157-AuthInputField #39
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
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 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 |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| import { makePageMetadata } from "@/seo/metadata"; | ||
|
|
||
| export const metadata = makePageMetadata({ | ||
| title: "PlanMate โ ๋ก๊ทธ์ธ/ํ์๊ฐ์ ", | ||
| description: "PlanMate ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธํ๊ฑฐ๋ ํ์๊ฐ์ ํ์ธ์.", | ||
| canonical: "/login", | ||
| }); | ||
|
|
||
| export default function AuthLayout({ children }: { children: React.ReactNode }) { | ||
| return <>{children}</>; | ||
| } |
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 |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| import { makePageMetadata } from "@/seo/metadata"; | ||
|
|
||
| export const metadata = makePageMetadata({ | ||
| title: "PlanMate โ ๋ง์ถคํ ๋ฐ์ผ๋ฆฌ ํ๋๋", | ||
| description: "์ํ๋ ๋ชจ๋์ ์กฐํฉํด ๋๋ง์ ํ๋๋๋ฅผ ๋ง๋๋ PlanMate ๋๋ฉ ํ์ด์ง", | ||
| canonical: "/", | ||
| }); | ||
|
|
||
| export default function MarketingLayout({ children }: { children: React.ReactNode }) { | ||
| return <>{children}</>; | ||
| } |
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
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 |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| import { makePageMetadata } from "@/seo/metadata"; | ||
|
|
||
| export const metadata = makePageMetadata({ | ||
| title: "์ด๊ธฐ ์ค์ โ MyPlanMate", | ||
| description: "๋ชจ๋์ ์ ํํ๊ณ ๋ฐฐ์นํด ๋๋ง์ ํ๋๋๋ฅผ ์์ํ์ธ์.", | ||
| canonical: "/setup", | ||
| }); | ||
|
|
||
| export default function SetupLayout({ children }: { children: React.ReactNode }) { | ||
| return <>{children}</>; | ||
| } |
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 |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| import { makePageMetadata } from "@/seo/metadata"; | ||
|
|
||
| export const metadata = { | ||
| ...makePageMetadata({ | ||
| title: "ํ๋๋", | ||
| description: "PlanMate ํ๋๋ ๋์๋ณด๋", | ||
| canonical: "/planner", | ||
| }), | ||
| robots: { index: false, follow: false }, // ๋ณดํธ ๊ตฌ์ญ์ ๊ฒ์ ์ ์ธ | ||
| }; | ||
|
|
||
| export default function PlannerLayout({ children }: { children: React.ReactNode }) { | ||
| return <>{children}</>; | ||
| } |
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 |
|---|---|---|
| @@ -1,14 +1,3 @@ | ||
| import { makePageMetadata } from "@/seo/metadata"; | ||
|
|
||
| export const metadata = { | ||
| ...makePageMetadata({ | ||
| title: "ํ๋๋", | ||
| description: "PlanMate ํ๋๋ ๋์๋ณด๋", | ||
| canonical: "/planner", | ||
| }), | ||
| robots: { index: false, follow: false }, // ๋ณดํธ ๊ตฌ์ญ์ ๊ฒ์ ์ ์ธ | ||
| }; | ||
|
|
||
| export default function PlannerPage() { | ||
| return <div>ํ๋๋ ๋์๋ณด๋</div>; | ||
| } |
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,47 @@ | ||
| // src/lib/variants/input.auth.ts | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
|
|
||
| /** | ||
| * ๋ก๊ทธ์ธ ์ธํ ์ปดํฌ๋ํธ์ ์คํ์ผ variant | ||
| * - ๊ธฐ๋ณธ: 1px + gray-300 | ||
| * - ํฌ์ปค์ค: 1.5px + gray-900 | ||
| * - ์๋ฌ: 1.5px + danger-600 | ||
| * - ์๋ฌ ์ํ์์ ํฌ์ปค์ค ์: ํฌ์ปค์ค ๊ท์น(gray-900)๋ก ๋ณต๊ท | ||
| */ | ||
| export const authInputVariants = cva( | ||
| [ | ||
| // === ๊ธฐ๋ณธ ๋ ์ด์์ === | ||
| "w-[36.6rem] h-[4.6rem] px-6 rounded-lg bg-white t-14-m outline-none", | ||
|
|
||
| // === ํ๋ ์ด์คํ๋ === | ||
| "placeholder:text-[var(--color-gray-500)]", | ||
|
|
||
| // === ๊ธฐ๋ณธ ํ ๋๋ฆฌ (1px + gray-300) === | ||
| "border-[1.5px] border-[color:var(--color-gray-300)]", | ||
|
|
||
| // === ํฌ์ปค์ค (1.5px + gray-900) === | ||
| "focus:border-[2px] focus:border-[color:var(--color-gray-900)]", | ||
|
|
||
| // === ์ ํ ํจ๊ณผ === | ||
| "transition-colors duration-150", | ||
| ].join(" "), | ||
| { | ||
| variants: { | ||
| status: { | ||
| default: "", | ||
|
|
||
| error: [ | ||
| "border-[2px]", | ||
| "border-[color:var(--color-danger-600)]", | ||
| "focus:border-[2px]", | ||
| "focus:border-[color:var(--color-gray-900)]", | ||
| ].join(" "), | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| status: "default", | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| export type AuthInputVariants = VariantProps<typeof authInputVariants>; |
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 |
|---|---|---|
| @@ -1,33 +1,47 @@ | ||
| "use client"; | ||
|
|
||
| import { cn } from "@/lib/utils"; | ||
| import { authInputVariants } from "@/lib/variants/input.auth"; | ||
| import type { InputProps } from "@/types/input"; | ||
| import * as React from "react"; | ||
|
|
||
| function Input({ className, type, ...props }: React.ComponentProps<"input">) { | ||
| /** | ||
| * AuthInput โ ๊ธฐ๋ณธ/ํฌ์ปค์ค/์๋ฌ ์ํ | ||
| * - status: "default" | "error" | ||
| * - ์๋ฌ ์ํ์์ ํฌ์ปค์ค ์ ์๋์ผ๋ก ๊ธฐ๋ณธ ์ํ๋ก ๋ณต๊ท | ||
| */ | ||
| export const Input = React.forwardRef< | ||
| HTMLInputElement, | ||
| React.ComponentPropsWithoutRef<"input"> & InputProps | ||
| >(({ className, status = "default", ...rest }, ref) => { | ||
| const [currentStatus, setCurrentStatus] = React.useState<InputProps["status"]>(status); | ||
|
|
||
| // ์ธ๋ถ์์ status๊ฐ ๋ฐ๋๋ฉด ๋๊ธฐํ | ||
| React.useEffect(() => { | ||
| setCurrentStatus(status); | ||
| }, [status]); | ||
|
|
||
| // ํฌ์ปค์ค ์ ์๋ฌ ์ํ๋ฉด ๊ธฐ๋ณธ์ผ๋ก ๋ณต๊ท | ||
| const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => { | ||
| if (currentStatus === "error") setCurrentStatus("default"); | ||
| rest.onFocus?.(e); | ||
| }; | ||
|
|
||
| const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => { | ||
| rest.onBlur?.(e); | ||
| }; | ||
|
|
||
| return ( | ||
| <input | ||
| type={type} | ||
| data-slot="input" | ||
| className={cn( | ||
| // ํฌ๊ธฐ/๋ ์ด์์ | ||
| "h-12 w-full min-w-0 rounded-md px-3 py-2 text-sm outline-none transition-colors", | ||
| // ๊ธฐ๋ณธ ํ ์คํธ/๋ฐฐ๊ฒฝ | ||
| "bg-white text-[#111827]", | ||
| // ๊ธฐ๋ณธ ํ ๋๋ฆฌ(1px, ํ์) | ||
| "border border-[var(--color-gray-300)]", | ||
| // ํ๋ ์ด์คํ๋ | ||
| "placeholder:text-[#737373]", | ||
| // โ ํฌ์ปค์ค(ํ์ฑํ): ํ ๋๋ฆฌ ๋๊ปโ(2px) + ์์ #111827 | ||
| "focus-visible:border-2 focus-visible:border-[#111827]", | ||
| // ์๋ฌ(์ ๊ทผ์ฑ): aria-invalid=true โ ํ ๋๋ฆฌ #dc2626 | ||
| "aria-invalid:border-[#dc2626]", | ||
| // ๋นํ์ฑ | ||
| "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", | ||
| // file input ๊ธฐ๋ณธ๊ฐ(ํ์ ์) | ||
| "file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground", | ||
| className, | ||
| )} | ||
| {...props} | ||
| ref={ref} | ||
| onFocus={handleFocus} | ||
| onBlur={handleBlur} | ||
| className={cn(authInputVariants({ status: currentStatus }), className)} | ||
| aria-invalid={currentStatus === "error" ? "true" : "false"} | ||
| data-invalid={currentStatus === "error" ? "true" : "false"} | ||
| {...rest} | ||
| /> | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| export { Input }; | ||
| Input.displayName = "Input"; | ||
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,10 @@ | ||
| export type InputStatus = "default" | "error"; | ||
|
|
||
| /** ์คํ์ผ ์ํ Props */ | ||
| export interface InputStateProps { | ||
| /** ์ธํ ์ํ โ ๊ธฐ๋ณธ(default) ๋๋ ์๋ฌ(error) */ | ||
| status?: InputStatus; | ||
| } | ||
|
|
||
| /** ์ต์ข ์ปดํฌ๋ํธ Props */ | ||
| export type InputProps = InputStateProps; |
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.
The new auth input clears its error state in
handleFocus/handleBlur, but the JSX spreads...restafter wiring those handlers. Any consumer that passes its ownonFocusoronBlurprop will overwrite the internal handlers, so the input never resets its status and the wrapped callbacks (rest.onFocus/rest.onBlur) are never invoked. This makes the error-clearing behaviour unreliable in typical form usage where custom focus handlers are common. Consider spreadingrestbefore attaching the internal handlers or composing the handlers so both run.Useful? React with ๐ย / ๐.