Package Exports
- cy-toast
 - cy-toast/dist/index.js
 
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cy-toast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
π cy-toast
μ½λμ μ€κΈ νλ‘μ νΈμ© toast/snackbar λΌμ΄λΈλ¬λ¦¬ ν¨ν€μ§μ λλ€.
β¨ Features
- headless uiλ‘ μμ λ‘μ΄ μ»€μ€ν°λ§μ΄μ§ μ 곡
 - React κΈ°λ° lightweight toast μμ€ν 
 open/closeμ λλ©μ΄μ μ μν μν κ° μ 곡- κ° Toastμ μμλ₯Ό κΈ°λ°μΌλ‘ μ λλ©μ΄μ  컀μ€ν°λ§μ΄μ§ κ°λ₯
 - μλ/μλ λ«κΈ° μ§μ (
duration=0μΌλ‘ 무ν μ§μ κ°λ₯) 
π‘ Install
npm install cy-toastπ¨ Usage
1. ToastRender λ£¨νΈ μ»΄ν¬λνΈ λ±λ‘
// RootLayout.tsx or toast μ¬μ©ν  μ»΄ν¬λνΈμ ToastRender μ»΄ν¬λνΈ λ±λ‘
import { ToastRender } from 'cy-toast';
const TestComponent = () => {
  return (
    <ToastRender/> {/*ToastRender μ»΄ν¬λνΈ μΆκ°*/}
    <Page/>
  )
}
2. ν μ€νΈ μ¬μ© (κΈ°λ³Έ ν μ€νΈ)
import { toast } from 'cy-toast';
toast.run(
  ({ close }) => (
    <div className="toast">
      μ μ₯λμμ΅λλ€! <button onClick={close}>λ«κΈ°</button>
    </div>
  ),
  { duration: 3000 }
);3. ν μ€νΈ μ¬μ© (μ¬μ©μ μ μ μ»΄ν¬λνΈ)
import { toast } from 'cy-toast';
import clsx from 'clsx';
toast.run(
  ({ close, isClosing, isOpening, index }) => (
    <div
      className={clsx(
        'toast-base',
        isClosing &&
          index < 3 &&
          'animation-slide-down-out pointer-events-none',
        isOpening && 'animation-slide-down-in',
        index === 1 && 'translate-y-[10px] scale-90',
        index === 2 && 'translate-y-[15px] scale-80',
        index >= 3 && 'translate-y-[20px] scale-70 opacity-0'
      )}
    >
      <Icon />λ΄ μν€ λ§ν¬κ° 볡μ¬λμμ΅λλ€.
      <button onClick={close}>λ«κΈ°</button>
    </div>
  ),
  { duration: 10000 }
);π API
| λ§€κ°λ³μ | νμ | μ€λͺ | 
|---|---|---|
content | 
(context: ToastContext) => React.ReactNode | 
νμν ν μ€νΈ JSXλ₯Ό λ°ννλ ν¨μ | 
options | 
{ duration?: number; closeDuration?: number; openDuration?: number } | 
μ λλ©μ΄μ
 λ° μ μ§ μκ° μ΅μ
 (0 μ§μ  μ μλ μ’
λ£ μμ) | 
π§© ToastContext νμ
ν μ€νΈ 컨ν
μΈ μ μ λ¬λλ κ°μ²΄λ λ€μκ³Ό κ°μ ꡬ쑰μ
λλ€.
interface ToastContext {
  close: () => void; // μλ λ«κΈ° ν¨μ
  isClosing: boolean; // λ«νλ μ€ μ¬λΆ (trueλ©΄ λ«νλ μ λλ©μ΄μ
)
  isOpening: boolean; // μ΄λ¦¬λ μ€ μ¬λΆ (trueλ©΄ μ΄λ¦¬λ μ λλ©μ΄μ
)
  index: number; // ν μ€νΈ νμ μμ (μ΅μ μ΄ 0)
}π§ͺ μμ 
toast.run(({ close, isOpening, isClosing, index }) => (
  <div
    className={clsx(
      'toast-base',
      isOpening && 'fade-in',
      isClosing && 'fade-out',
      index === 1 && 'translate-y-[10px]',
      index >= 2 && 'translate-y-[20px] opacity-80'
    )}
  >
    ν μ€νΈ λ©μμ§μ
λλ€!
    <button onClick={close}>λ«κΈ°</button>
  </div>
));