Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ npm install react-compact-toast
Mount the container once, near the root of your app, then call `toast()` from anywhere.

```jsx
'use client'; // only needed in the Next.js App Router
import { ToastContainer, toast } from 'react-compact-toast';

export default function App() {
Expand Down Expand Up @@ -391,9 +390,11 @@ Nothing about `toast('…')` and `<ToastContainer />` changes. The rest:
- **Toasts are focusable** when they respond to clicks, so they join the tab
order.
- **The text is a `<div>`, not a `<p>`,** because it now accepts any node.
- **`eventManager`, `ToastEvent`, `EventManager`, `EventCallbacks` and
`TimeoutId` are gone.** They were unusable from TypeScript. Use
`toast.update` / `toast.dismiss` / `useToastContainer` instead.
- **`eventManager` stays, and is finally usable.** `ToastEvent` was exported
as a type, so `eventManager.on(ToastEvent.Add, …)` did not compile; it is
now a value. `activeToastCount` became read-only — it is derived from the
toasts on screen instead of being counted separately. A `Dismiss` event
joins `Add`, `Delete` and `Update`.
- **Deprecated, still working:** `highlightText` and `highlightColor` (put a
node in `text`), per-toast `offset` and `containerStyle` (use the container
props), `useToast(id, autoClose, closeOnClick)` (pass an options object),
Expand Down
73 changes: 18 additions & 55 deletions playground/src/app/components/Features.tsx
Original file line number Diff line number Diff line change
@@ -1,87 +1,50 @@
import { motion, useInView, Variants } from 'motion/react';
import { useRef } from 'react';

export default function Features() {
const ref = useRef(null);
const isInView = useInView(ref, { once: true, margin: "-50px" });

const containerVariants: Variants = {
hidden: { opacity: 0, y: 30 },
visible: {
opacity: 1,
y: 0,
transition: {
duration: 0.6,
staggerChildren: 0.08,
delayChildren: 0.2
}
}
};

const itemVariants: Variants = {
hidden: { opacity: 0, y: 20 },
visible: {
opacity: 1,
y: 0,
transition: {
duration: 0.5,
ease: [0.21, 1.11, 0.81, 0.99]
}
}
};

const features = [
'Announced to screen readers, operable by keyboard',
'Pauses on hover, focus and hidden tabs',
'Promise, loading, action and update helpers',
'Themeable with CSS variables and data-* selectors',
'Server rendering and the Next.js App Router',
'Fully type-safe, zero dependencies',
'Screen reader and keyboard ready',
'Pauses on hover and focus',
'Promise and loading helpers',
'Multiple positioning options',
'Works with any CSS framework',
'Fully type-safe API',
];

return (
<motion.div
ref={ref}
initial="hidden"
animate={isInView ? "visible" : "hidden"}
variants={containerVariants}
<div
className="backdrop-blur-xl bg-white/60 border border-neutral-200/50 rounded-3xl p-5 shadow-xl shadow-neutral-900/5"
>
<motion.h2
variants={itemVariants}
<h2
className="text-lg font-semibold text-neutral-900 mb-4"
>
Features
</motion.h2>
</h2>

<ul className="space-y-3">
{features.map((feature, index) => (
<motion.li
<li
key={index}
variants={itemVariants}
className="flex items-center text-sm text-neutral-700"
>
<div className="w-1.5 h-1.5 bg-neutral-400 rounded-full mr-3 flex-shrink-0"></div>
{feature}
</motion.li>
</li>
))}
</ul>

<motion.div
variants={itemVariants}
<div
className="mt-8 pt-4 border-t border-neutral-200/60"
>
<div className="space-y-3">
<div className="flex items-center justify-between text-[13px] text-neutral-600">
<span>Bundle size</span>
<span className="font-medium">~2kB</span>
<span>Bundle size (gzip)</span>
<span className="font-medium">7.0 kB</span>
</div>
<div className="flex items-center justify-between text-[13px] text-neutral-600">
<span>Dependencies</span>
<span className="font-medium">Zero</span>
<span>Headless entry</span>
<span className="font-medium">3.1 kB</span>
</div>
</div>
</motion.div>
</motion.div>
</div>
</div>
);
}
159 changes: 64 additions & 95 deletions playground/src/app/components/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,106 +1,75 @@
import Image from 'next/image';
import { motion } from 'motion/react';

const LINKS = [
{ label: 'Docs', href: '/docs' },
{ label: 'GitHub', href: 'https://github.com/m2na7/react-compact-toast' },
{ label: 'npm', href: 'https://www.npmjs.com/package/react-compact-toast' },
];

const FACTS = [
{ value: '7.0 kB', label: 'gzipped' },
{ value: '3.1 kB', label: 'headless' },
{ value: '0', label: 'dependencies' },
{ value: '18 · 19', label: 'React' },
];

export default function Header() {
return (
<div className="min-h-screen flex items-center justify-center px-4 -mt-16">
<div className="text-center max-w-4xl mx-auto">
<motion.div
initial={{ scale: 0, rotate: -180 }}
animate={{ scale: 1, rotate: 0 }}
transition={{
type: "spring",
stiffness: 260,
damping: 20,
delay: 0.1
}}
className="inline-flex items-center justify-center w-24 h-24 bg-gradient-to-r from-blue-500 to-indigo-500 rounded-2xl mb-8 shadow-xl overflow-hidden cursor-pointer"
>
<Image
src="/logo.webp"
alt="React Compact Toast Logo"
width={60}
height={60}
className="object-contain"
/>
</motion.div>

<div className="mb-8">
<motion.h1
initial={{ opacity: 0, y: 30 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.8, delay: 0.3 }}
className="text-5xl md:text-7xl font-bold mb-8 bg-gradient-to-r from-gray-900 via-blue-600 to-gray-900 bg-clip-text text-transparent leading-tight"
>
<div className="relative z-10 max-w-6xl mx-auto px-4 sm:px-6">
<div className="flex flex-wrap items-center justify-between gap-6 border-b border-neutral-200 py-4">
<div className="flex items-center gap-3">
<span className="inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-lg bg-gradient-to-r from-blue-500 to-indigo-500">
<Image
src="/logo.webp"
alt=""
width={20}
height={20}
className="object-contain"
/>
</span>
<span className="text-[15px] font-semibold tracking-tight text-neutral-900">
React Compact Toast
</motion.h1>

<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, delay: 0.5 }}
className="flex items-center justify-center gap-4 mb-8"
>
<motion.span
whileHover={{ scale: 1.05, y: -2 }}
whileTap={{ scale: 0.95 }}
className="inline-flex items-center px-4 py-2 rounded-full text-sm font-medium bg-green-100 text-green-700 border border-green-200 cursor-pointer shadow-md"
>
✨ ≈2 kB
</motion.span>
<motion.span
whileHover={{ scale: 1.05, y: -2 }}
whileTap={{ scale: 0.95 }}
className="inline-flex items-center px-4 py-2 rounded-full text-sm font-medium bg-blue-100 text-blue-700 border border-blue-200 cursor-pointer shadow-md"
>
🚀 Zero deps
</motion.span>
</motion.div>
</span>
</div>

<motion.p
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, delay: 0.7 }}
className="text-xl md:text-2xl text-gray-600 font-normal max-w-3xl mx-auto leading-relaxed mb-8"
>
Compact, easy-to-use toast notifications for React
</motion.p>

<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, delay: 0.9 }}
className="text-lg text-gray-500 max-w-2xl mx-auto leading-relaxed"
>
<p className="text-base text-gray-400">
⚡ Lightweight • ⚙️ Headless Architecture • 🎯 Intuitive API • ✨ Fully Customizable
</p>
</motion.div>

<motion.div
initial={{ opacity: 0, y: 30 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.8, delay: 1.1 }}
className="mt-12"
>
<div className="animate-bounce">
<svg
className="w-6 h-6 text-gray-400 mx-auto"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
<nav className="flex items-center gap-5 text-sm">
{LINKS.map(({ label, href }) => (
<a
key={label}
href={href}
className="text-blue-600 hover:underline underline-offset-4"
{...(href.startsWith('http')
? { target: '_blank', rel: 'noopener noreferrer' }
: {})}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M19 14l-7 7m0 0l-7-7m7 7V3"
/>
</svg>
</div>
</motion.div>
{label}
</a>
))}
</nav>
</div>

<header className="pb-9 pt-11">
<h1 className="max-w-[22ch] text-3xl font-bold leading-tight tracking-tight text-neutral-900 sm:text-4xl">
Toast notifications you can call from anywhere.
</h1>
<p className="mt-3.5 max-w-[48ch] text-[17px] leading-relaxed text-neutral-600">
No provider to mount, no hook to declare. Import{' '}
<code className="font-mono text-[0.875em] text-neutral-900">toast</code>{' '}
and call it.
</p>

<dl className="mt-6 flex flex-wrap gap-x-6 gap-y-2 text-sm text-neutral-600">
{FACTS.map(({ value, label }) => (
<div key={label} className="flex items-baseline gap-1.5">
<dt className="sr-only">{label}</dt>
<dd className="font-medium tabular-nums text-neutral-900">
{value}
</dd>
<span aria-hidden="true">{label}</span>
</div>
))}
</dl>
</header>
</div>
);
}
}
Loading