- Toast Message ->
role="alert"
- 'warn' & 'error' ->
aria-live="assertive"
- 'normal' & 'success' & 'not-defined' ->
aria-live="polite"
aria-live Will be 'off'
When Toast be hide- Close Button
- reference: https://sheribyrnehaber.medium.com/designing-toast-messages-for-accessibility-fb610ac364be
0.1.7
- Be
1.0.0
When This Todo will Be Done.
$ yarn add @jaewoong2/toast
$ npm i @jaewoong2/toast
import { ToastProvider, useToast } from '@jaewoong2/toast'
import { ToastProvider } from '@jaewoong2/toast'
const App = () => {
return (
<ToastProvider>
<RootComponent />
</ToastProvider>
)
}
import { useToast, ToastOptionType } from '@jaewoong2/toast'
const ChildrenComponent = ({ toastOptions }: { toastOptions: ToastOptionType }) => {
const { show, hide } = useToast('Toast Message', { ...toastOptions });
return (
<div>
<button onClick={() => show()}>Show</button>
<button onClick={() => show().success()}>success</button>
<button onClick={() => show().error()}>error</button>
<button onClick={() => show().warn()}>warn</button>
<button onClick={() => show().normal()}>normal</button>
<button onClick={hide}>Hide Button</button>
</div>
)
}
type ToastOptionType = {
// ToastMessage Duration (dfault: 2000ms)
duration?: number
// ToastMessage position (default: bottom)
position?: 'top' | 'bottom'
// ToastMessage subPosition (default: center)
subPosition?: 'center' | 'left' | 'right'
// ToastMessage background-color (default: #71A8EC)
backgroundColor?: string
// ToastMessage distance (px) from position (default: 32px)
distance?: number
// ToastMessage width (default: 200px)
width?: number
// ToastMessage color ["black(default)" || "white"]
color?: 'black' | 'white'
// ToastMessage className
className?: string
// ToastMessage border-radius
borderRadius?: number
// ToastMessage Type
type?: 'success' | 'error' | 'warn' | 'normal'
}
- aria-live = "polite"
- background-color = Defined BackgroundColor / Default BackgroundColor
- aria-live = "polite"
- background-color = "#2bbbad"
- aria-live = "polite"
- background-color = "#777777"
- aria-live = "assertive"
- background-color = "#d9534f"
- aria-live = "assertive"
- background-color = "#f0ad4e"
- Deployment / Publish
- StroyBook Hosting
Document Writing- Options (By Priority)
- DarkMode
- Animation Direction: "left to center" | "right to center"
- FadeIn, FadeOut: 'slide' | 'fadein'
Type: "Error" | "Normal" | "Warn" | "Loading"- TimeOut Bar