-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Toast 컴포넌트 추가 #21
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
7b1e890
e2fb54c
f342de4
91d55e5
786e9f6
a6c79d2
9afdf15
efa6a9a
268d1cb
8625d97
f79d9a1
d11720e
d796b0a
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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Button } from "#/components/button"; | ||
| import { toast } from "#/utils/toast"; | ||
|
|
||
| export const ToastTest = () => { | ||
| return ( | ||
| <Button | ||
| onClick={() => | ||
| toast.warning("이미 선택되었어요. 다른 메뉴를 골라주세요!") | ||
| } | ||
| > | ||
| Toast 테스트 | ||
| </Button> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { BackwardButton } from "#/components/backwardButton"; | |
| import { Layout } from "#/components/layout"; | ||
| import { StepHeader } from "#/components/stepHeader"; | ||
| import { colors } from "#/constants/color"; | ||
| import { ToastTest } from "./_test/ToastTest"; | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
|
|
@@ -54,8 +55,8 @@ export default function Home() { | |
| </div> | ||
| </Layout.Content> | ||
| <Layout.Footer> | ||
| <div className="ygi:flex ygi:h-layout-footer-height ygi:w-full ygi:items-center ygi:justify-center ygi:bg-surface-gray"> | ||
| Footer | ||
| <div className="ygi:flex ygi:h-layout-footer-height ygi:w-full ygi:items-center ygi:justify-center ygi:gap-md ygi:bg-surface-gray"> | ||
| <ToastTest /> | ||
|
||
| </div> | ||
| </Layout.Footer> | ||
| </Layout.Root> | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| "use client"; | ||
|
|
||
| import { | ||
| Toaster as SonnerToaster, | ||
| type ToasterProps as SonnerToasterProps, | ||
| } from "sonner"; | ||
|
|
||
| export type ToasterProps = Pick< | ||
| SonnerToasterProps, | ||
| "offset" | "mobileOffset" | "gap" | "toastOptions" | ||
| >; | ||
|
|
||
| export const Toaster = ({ offset, mobileOffset, gap, toastOptions = { duration: 3000 } }: ToasterProps) => { | ||
| return ( | ||
| <SonnerToaster | ||
| position="bottom-center" | ||
| offset={offset} | ||
| mobileOffset={mobileOffset} | ||
| gap={gap} | ||
| toastOptions={toastOptions} | ||
| /> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { Toaster, type ToasterProps } from "./Toaster"; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||||||||||
| import { IconBase, type IconBaseProps } from "../iconBase"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export type AlertCircleIconProps = Omit<IconBaseProps, "children">; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const AlertCircleIcon = ({ | ||||||||||||||||||||||
| size = 20, | ||||||||||||||||||||||
| ...props | ||||||||||||||||||||||
| }: AlertCircleIconProps) => { | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <IconBase size={size} viewBox="-1 -1 20 20" {...props}> | ||||||||||||||||||||||
|
Contributor
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.
Suggested change
|
||||||||||||||||||||||
| <path | ||||||||||||||||||||||
| d="M0 9C0 4.02944 4.02944 0 9 0C13.9706 0 18 4.02944 18 9C18 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9Z" | ||||||||||||||||||||||
| fill="currentColor" | ||||||||||||||||||||||
| /> | ||||||||||||||||||||||
| <path | ||||||||||||||||||||||
| d="M9 5V9" | ||||||||||||||||||||||
| stroke="#E5E7EB" | ||||||||||||||||||||||
| strokeWidth="2" | ||||||||||||||||||||||
| strokeLinecap="round" | ||||||||||||||||||||||
| /> | ||||||||||||||||||||||
| <circle cx="9" cy="13" r="1.5" fill="#E5E7EB" /> | ||||||||||||||||||||||
|
Comment on lines
+17
to
+21
Contributor
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. 아이콘 내부 요소(path의 stroke와 circle의 fill)에
Suggested change
|
||||||||||||||||||||||
| </IconBase> | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { AlertCircleIcon, type AlertCircleIconProps } from "./AlertCircleIcon"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { toast as sonnerToast } from "sonner"; | ||
| import { AlertCircleIcon } from "#/icons/alertCircleIcon"; | ||
|
|
||
| interface ToastOptions { | ||
| duration?: number; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const toast = { | ||
| warning: (message: string, options?: ToastOptions) => { | ||
| sonnerToast(message, { | ||
| icon: AlertCircleIcon({ | ||
| size: 20, | ||
| className: "ygi:text-palette-primary-500 ygi:mx-auto!", | ||
| }), | ||
| classNames: { | ||
| toast: "ygi:bg-button-primary! ygi:text-text-inverse! ygi:body-14-md! ygi:rounded-sm! ygi:py-3! ygi:pl-4! ygi:pr-5! ygi:gap-2! ygi:flex! ygi:items-center! ygi:border-none!", | ||
|
Comment on lines
+16
to
+17
Contributor
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.
|
||
| }, | ||
| duration: options?.duration, | ||
| }); | ||
| }, | ||
| }; | ||
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.
ToastTest컴포넌트는 테스트 목적으로 보이며,app/page.tsx에 직접 import 되어 있습니다. 프로덕션 코드에 테스트용 코드가 포함되는 것은 불필요한 코드와 잠재적인 부작용을 일으킬 수 있으므로, 프로덕션 병합 전에 이 import 문을 제거하는 것이 좋습니다. 개발 환경에서만 필요한 경우, 환경 변수를 사용하여 조건부로 import 하거나 별도의 테스트 페이지에서만 사용하도록 분리하는 것을 고려해볼 수 있습니다.