Reviving a 12K+ Star Abandoned Library: toastr-next v3
Описание и применение
toastr-next v3 — легковесная, современная и доступная библиотека уведомлений, заменившая устаревший toastr. Она не требует jQuery, поддерживает TypeScript, темную тему, Promise API и React‑обёртку, уменьшая размер пакета до ~4 KB gzipped.
Задача
The original toastr library was abandoned in 2016, required jQuery, had no TypeScript, dark mode, accessibility, or modern build tools, making it unusable in modern projects.
Результат
toastr-next v3 delivers a lightweight, modern, accessible notification library that can be dropped into any project without jQuery, with full TypeScript support, dark mode, Promise API, and built‑in React integration, reducing bundle size from ~87 KB to ~4 KB gzipped.
Рабочий процесс
- 1. Analyzed original source to identify core API surface (success, error, info, warning).
- 2. Designed TypeScript interfaces for options, response, and events, adding a dismissed Promise to each toast.
- 3. Implemented CSS‑first theming with auto dark mode via prefers‑color‑scheme and manual override via data‑theme attribute.
- 4. Added WCAG 2.1 AA compliant ARIA roles: alert for error/warning, status for success/info.
- 5. Created a Vite generateBundle plugin to self‑inject CSS into every JS chunk, guarded against duplicate injection and SSR.
- 6. Built a live demo page with theme toggle, animation showcase, and before/after comparison.
- 7. Used GitHub Copilot throughout to suggest patterns, catch bugs, and audit the codebase for anti‑patterns.
Доказательства
toastr was the go-to notification library for millions of developers. But time wasn't kind to it.
~4 KB gzipped. No jQuery. No bloat. Just toasts.
Copilot flagged that role="alert" is assertive and suggested role="status" for success/info.
- Дата записи: 2026-09-06T14:36:25.574Z