-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 토스트 컴포넌트 구현 * feat: 토스트 컴포넌트 스토리북 작성 * chore: package.json 및 rollup 추가 * chore: displayName 추가 및 export 형식 변경 * design: 두 줄인 경우 줄바꿈 * fix: type 옵셔널로 처리 * feat: 토스트 컴포넌트를 사라지게 하는 효과 추가 * feat: 아이콘 클릭 시 호출할 함수 추가, 배경 추가 * feat: 아이콘 클릭 함수 스토리 추가, state 활용 추가 * feat: 토스트 위치조정 및 배경 스타일 prop 추가 * feat: toast 함수로 렌더링 가능하도록 로직 추가 * fix: 토스트가 여러개일 때 레이아웃 조정 * chore: useToast 빌드 포함 * fix: color contrast 검사 통과 * feat: 토스트 duration 받을 수 있도록 추가 * feat: overlay zIndex 토큰 추가 * refactor: zIndex 토큰 사용하도록 변경 * feat: 공통 타입 파일 내보내도록 스크립트 수정 * refactor: TypeIconComponent 네이밍 변경 및 공통 prop 빼기 * fix: 토스트 트리거 존재하는 경우 스토리 추가, 토스트가 없을 때 오버레이 공간 차지하지 않도록 조건부 렌더링 * docs: ToastProvider 내용 안내 * docs: 스토리북 radio 옵션 추가 및 기본 컴포넌트 변경 * feat: 토스트 컴포넌트 제거 이후 실행되는 함수 추가 * feat: docs에도overlay 토큰 추가 * fix: type -> rightIcon 네이밍 변경 * docs: 스토리북 설명 및 타이틀 변경 * fix: 스크립트 content 변수 네이밍 변경 * fix: icon prop 불리언으로 수정 * refactor: 현재 시각 대신 uuid로 토스트 id 지정 * feat: 정규식 입력 시 해당 정규식을 만족하는 아이디를 가진 토스트만 보여주기 * chore: changeset 작성
- Loading branch information
Showing
22 changed files
with
483 additions
and
281 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
--- | ||
"wowds-tokens": patch | ||
"wowds-theme": patch | ||
--- | ||
|
||
zIndex 토큰을 추가합니다. |
This file contains 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,5 @@ | ||
--- | ||
"wowds-icons": patch | ||
--- | ||
|
||
Icon 공통 타입을 내보내기합니다. |
This file contains 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,5 @@ | ||
--- | ||
"wowds-ui": patch | ||
--- | ||
|
||
Toast 컴포넌트를 추가합니다. |
This file contains 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 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 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 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 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 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 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 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 +1,2 @@ | ||
export const dropdown = 10; | ||
export const overlay = 9999; |
This file contains 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 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 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,173 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { useEffect } from "react"; | ||
import { Warn } from "wowds-icons"; | ||
|
||
import Button from "@/components/Button"; | ||
|
||
import Toast from "."; | ||
import ToastProvider from "./ToastProvider"; | ||
import useToast from "./useToast"; | ||
|
||
const meta: Meta<typeof Toast> = { | ||
title: "UI/Toast", | ||
component: Toast, | ||
tags: ["autodocs"], | ||
parameters: { | ||
componentSubtitle: "Toast 컴포넌트", | ||
a11y: { | ||
config: { | ||
rules: [{ id: "color-contrast", enabled: false }], | ||
}, | ||
}, | ||
docs: { | ||
description: { | ||
component: | ||
"토스트가 필요한 레이아웃에서 children을 ToastProvider로 감싸 사용합니다.", | ||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<ToastProvider> | ||
<Story /> | ||
</ToastProvider> | ||
), | ||
], | ||
argTypes: { | ||
text: { | ||
description: "Toast에 들어갈 메인 텍스트를 나타냅니다.", | ||
control: { type: "text" }, | ||
}, | ||
subText: { | ||
description: "Toast에 들어갈 보조 텍스트를 나타냅니다.", | ||
control: { type: "text" }, | ||
}, | ||
rightIcon: { | ||
description: "Toast의 우측에 들어갈 아이콘을 나타냅니다.", | ||
table: { | ||
type: { summary: "none | close | arrow" }, | ||
defaultValue: { summary: "none" }, | ||
}, | ||
control: "radio", | ||
options: ["none", "close", "arrow"], | ||
}, | ||
id: { | ||
description: "Toast 컴포넌트의 id를 나타냅니다.", | ||
control: false, | ||
}, | ||
onClickArrowIcon: { | ||
description: | ||
"Toast 컴포넌트의 화살표 아이콘을 클릭했을 때 호출되는 함수를 나타냅니다.", | ||
control: false, | ||
}, | ||
onRemove: { | ||
description: "Toast 컴포넌트가 닫힌 이후 호출되는 함수를 나타냅니다.", | ||
control: false, | ||
}, | ||
showLeftIcon: { | ||
description: "Toast 좌측에 들어갈 아이콘의 노출 여부를 나타냅니다.", | ||
control: "boolean", | ||
}, | ||
toastDuration: { | ||
description: "Toast가 보여지는 시간(ms)을 나타냅니다.", | ||
control: { type: "number" }, | ||
}, | ||
style: { | ||
description: "Toast에 커스텀 스타일을 적용하기 위한 객체를 나타냅니다.", | ||
control: false, | ||
}, | ||
className: { | ||
description: "Toast에 커스텀 클래스를 적용하기 위한 문자열을 나타냅니다.", | ||
control: false, | ||
}, | ||
}, | ||
} satisfies Meta<typeof Toast>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
id: "1", | ||
text: "Text", | ||
subText: "subtext", | ||
toastDuration: 60 * 60 * 1000, | ||
}, | ||
}; | ||
|
||
export const WithTrigger = () => { | ||
const { toast } = useToast(); | ||
|
||
return ( | ||
<Button onClick={() => toast({ text: "Text", subText: "subtext" })}> | ||
토스트 열기 | ||
</Button> | ||
); | ||
}; | ||
|
||
export const WithCloseIcon = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
text: "Text", | ||
subText: "subtext", | ||
rightIcon: "close", | ||
}); | ||
}, []); | ||
}; | ||
|
||
export const WithArrowIcon = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
text: "Text", | ||
subText: "subtext", | ||
rightIcon: "arrow", | ||
}); | ||
}, []); | ||
}; | ||
|
||
export const WithLeftIcon = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
text: "Text", | ||
subText: "subtext", | ||
showLeftIcon: true, | ||
}); | ||
}, []); | ||
}; | ||
|
||
export const WithLeftAndArrowIcons = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
text: "Text", | ||
subText: "subtext", | ||
showLeftIcon: true, | ||
rightIcon: "arrow", | ||
}); | ||
}, []); | ||
}; | ||
|
||
export const TwoLines = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
showLeftIcon: true, | ||
text: "TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText", | ||
}); | ||
}, []); | ||
}; | ||
|
||
export const Slow = () => { | ||
const { toast } = useToast(); | ||
useEffect(() => { | ||
toast({ | ||
text: "Text", | ||
subText: "subtext", | ||
toastDuration: 5000, | ||
}); | ||
}, []); | ||
}; |
This file contains 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,22 @@ | ||
import { createContext } from "react"; | ||
|
||
import useSafeContext from "@/hooks/useSafeContext"; | ||
|
||
import type { ToastProps } from "."; | ||
|
||
interface ToastContextProps { | ||
toasts: ToastProps[]; | ||
addToast: ( | ||
toast: Omit<ToastProps, "id"> & Partial<Pick<ToastProps, "id">> | ||
) => void; | ||
removeToast: (id: string) => void; | ||
} | ||
|
||
export const ToastContext = createContext<ToastContextProps | undefined>( | ||
undefined | ||
); | ||
|
||
export const useToastContext = () => { | ||
const context = useSafeContext(ToastContext); | ||
return context; | ||
}; |
Oops, something went wrong.