magic-pill 8.0.3 → 9.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/CHANGELOG.md +120 -31
  2. package/MIGRATING.md +224 -0
  3. package/README.md +322 -252
  4. package/dist/MagicPill/MagicPill.d.mts +27 -0
  5. package/dist/MagicPill/MagicPill.d.ts +27 -0
  6. package/dist/MagicPill/MagicPill.js +2 -0
  7. package/dist/MagicPill/MagicPill.js.map +1 -0
  8. package/dist/MagicPill/MagicPill.mjs +2 -0
  9. package/dist/MagicPill/MagicPill.mjs.map +1 -0
  10. package/dist/MagicPill/choreography.js +2 -0
  11. package/dist/MagicPill/choreography.js.map +1 -0
  12. package/dist/MagicPill/choreography.mjs +2 -0
  13. package/dist/MagicPill/choreography.mjs.map +1 -0
  14. package/dist/Pill/Pill.d.mts +7 -0
  15. package/dist/Pill/Pill.d.ts +7 -0
  16. package/dist/Pill/Pill.js +2 -0
  17. package/dist/Pill/Pill.js.map +1 -0
  18. package/dist/Pill/Pill.mjs +2 -0
  19. package/dist/Pill/Pill.mjs.map +1 -0
  20. package/dist/Pill/PillAction.d.mts +7 -0
  21. package/dist/Pill/PillAction.d.ts +7 -0
  22. package/dist/Pill/PillAction.js +2 -0
  23. package/dist/Pill/PillAction.js.map +1 -0
  24. package/dist/Pill/PillAction.mjs +2 -0
  25. package/dist/Pill/PillAction.mjs.map +1 -0
  26. package/dist/Pill/PillContext.d.mts +3 -0
  27. package/dist/Pill/PillContext.d.ts +3 -0
  28. package/dist/Pill/PillContext.js +2 -0
  29. package/dist/Pill/PillContext.js.map +1 -0
  30. package/dist/Pill/PillContext.mjs +2 -0
  31. package/dist/Pill/PillContext.mjs.map +1 -0
  32. package/dist/Pill/PillPanel.d.mts +9 -0
  33. package/dist/Pill/PillPanel.d.ts +9 -0
  34. package/dist/Pill/PillPanel.js +2 -0
  35. package/dist/Pill/PillPanel.js.map +1 -0
  36. package/dist/Pill/PillPanel.mjs +2 -0
  37. package/dist/Pill/PillPanel.mjs.map +1 -0
  38. package/dist/Pill/parts.d.mts +10 -0
  39. package/dist/Pill/parts.d.ts +10 -0
  40. package/dist/Pill/parts.js +2 -0
  41. package/dist/Pill/parts.js.map +1 -0
  42. package/dist/Pill/parts.mjs +2 -0
  43. package/dist/Pill/parts.mjs.map +1 -0
  44. package/dist/Pill/types.d.mts +88 -0
  45. package/dist/Pill/types.d.ts +88 -0
  46. package/dist/PillNavbar/PillNavbar.d.mts +31 -0
  47. package/dist/PillNavbar/PillNavbar.d.ts +31 -0
  48. package/dist/PillNavbar/PillNavbar.js +2 -0
  49. package/dist/PillNavbar/PillNavbar.js.map +1 -0
  50. package/dist/PillNavbar/PillNavbar.mjs +2 -0
  51. package/dist/PillNavbar/PillNavbar.mjs.map +1 -0
  52. package/dist/PillNavbar/matchPath.d.mts +2 -0
  53. package/dist/PillNavbar/matchPath.d.ts +2 -0
  54. package/dist/PillNavbar/matchPath.js +2 -0
  55. package/dist/PillNavbar/matchPath.js.map +1 -0
  56. package/dist/PillNavbar/matchPath.mjs +2 -0
  57. package/dist/PillNavbar/matchPath.mjs.map +1 -0
  58. package/dist/PillNotification/PillNotification.d.mts +51 -0
  59. package/dist/PillNotification/PillNotification.d.ts +51 -0
  60. package/dist/PillNotification/PillNotification.js +2 -0
  61. package/dist/PillNotification/PillNotification.js.map +1 -0
  62. package/dist/PillNotification/PillNotification.mjs +2 -0
  63. package/dist/PillNotification/PillNotification.mjs.map +1 -0
  64. package/dist/icons/ArrowIcon.d.mts +4 -0
  65. package/dist/icons/ArrowIcon.d.ts +4 -0
  66. package/dist/icons/ArrowIcon.js +2 -0
  67. package/dist/icons/ArrowIcon.js.map +1 -0
  68. package/dist/icons/ArrowIcon.mjs +2 -0
  69. package/dist/icons/ArrowIcon.mjs.map +1 -0
  70. package/dist/icons/BoxIcon.d.mts +4 -0
  71. package/dist/icons/BoxIcon.d.ts +4 -0
  72. package/dist/icons/BoxIcon.js +2 -0
  73. package/dist/icons/BoxIcon.js.map +1 -0
  74. package/dist/icons/BoxIcon.mjs +2 -0
  75. package/dist/icons/BoxIcon.mjs.map +1 -0
  76. package/dist/icons/CheckIcon.d.mts +4 -0
  77. package/dist/icons/CheckIcon.d.ts +4 -0
  78. package/dist/icons/CheckIcon.js +2 -0
  79. package/dist/icons/CheckIcon.js.map +1 -0
  80. package/dist/icons/CheckIcon.mjs +2 -0
  81. package/dist/icons/CheckIcon.mjs.map +1 -0
  82. package/dist/icons/CloseIcon.d.mts +4 -0
  83. package/dist/icons/CloseIcon.d.ts +4 -0
  84. package/dist/icons/CloseIcon.js +2 -0
  85. package/dist/icons/CloseIcon.js.map +1 -0
  86. package/dist/icons/CloseIcon.mjs +2 -0
  87. package/dist/icons/CloseIcon.mjs.map +1 -0
  88. package/dist/icons/CouponIcon.d.mts +4 -0
  89. package/dist/icons/CouponIcon.d.ts +4 -0
  90. package/dist/icons/CouponIcon.js +2 -0
  91. package/dist/icons/CouponIcon.js.map +1 -0
  92. package/dist/icons/CouponIcon.mjs +2 -0
  93. package/dist/icons/CouponIcon.mjs.map +1 -0
  94. package/dist/icons/DocumentIcon.d.mts +4 -0
  95. package/dist/icons/DocumentIcon.d.ts +4 -0
  96. package/dist/icons/DocumentIcon.js +2 -0
  97. package/dist/icons/DocumentIcon.js.map +1 -0
  98. package/dist/icons/DocumentIcon.mjs +2 -0
  99. package/dist/icons/DocumentIcon.mjs.map +1 -0
  100. package/dist/icons/HelpIcon.d.mts +4 -0
  101. package/dist/icons/HelpIcon.d.ts +4 -0
  102. package/dist/icons/HelpIcon.js +2 -0
  103. package/dist/icons/HelpIcon.js.map +1 -0
  104. package/dist/icons/HelpIcon.mjs +2 -0
  105. package/dist/icons/HelpIcon.mjs.map +1 -0
  106. package/dist/icons/InfoIcon.d.mts +4 -0
  107. package/dist/icons/InfoIcon.d.ts +4 -0
  108. package/dist/icons/InfoIcon.js +2 -0
  109. package/dist/icons/InfoIcon.js.map +1 -0
  110. package/dist/icons/InfoIcon.mjs +2 -0
  111. package/dist/icons/InfoIcon.mjs.map +1 -0
  112. package/dist/icons/MailIcon.d.mts +4 -0
  113. package/dist/icons/MailIcon.d.ts +4 -0
  114. package/dist/icons/MailIcon.js +2 -0
  115. package/dist/icons/MailIcon.js.map +1 -0
  116. package/dist/icons/MailIcon.mjs +2 -0
  117. package/dist/icons/MailIcon.mjs.map +1 -0
  118. package/dist/icons/PhoneIcon.d.mts +4 -0
  119. package/dist/icons/PhoneIcon.d.ts +4 -0
  120. package/dist/icons/PhoneIcon.js +2 -0
  121. package/dist/icons/PhoneIcon.js.map +1 -0
  122. package/dist/icons/PhoneIcon.mjs +2 -0
  123. package/dist/icons/PhoneIcon.mjs.map +1 -0
  124. package/dist/icons/PlusIcon.d.mts +4 -0
  125. package/dist/icons/PlusIcon.d.ts +4 -0
  126. package/dist/icons/PlusIcon.js +2 -0
  127. package/dist/icons/PlusIcon.js.map +1 -0
  128. package/dist/icons/PlusIcon.mjs +2 -0
  129. package/dist/icons/PlusIcon.mjs.map +1 -0
  130. package/dist/icons/UndoIcon.d.mts +4 -0
  131. package/dist/icons/UndoIcon.d.ts +4 -0
  132. package/dist/icons/UndoIcon.js +2 -0
  133. package/dist/icons/UndoIcon.js.map +1 -0
  134. package/dist/icons/UndoIcon.mjs +2 -0
  135. package/dist/icons/UndoIcon.mjs.map +1 -0
  136. package/dist/icons/types.d.mts +3 -0
  137. package/dist/icons/types.d.ts +3 -0
  138. package/dist/index.d.mts +25 -0
  139. package/dist/index.d.ts +25 -5
  140. package/dist/index.js +1 -2
  141. package/dist/index.mjs +1 -0
  142. package/dist/store/store.d.mts +63 -0
  143. package/dist/store/store.d.ts +63 -0
  144. package/dist/store/store.js +2 -0
  145. package/dist/store/store.js.map +1 -0
  146. package/dist/store/store.mjs +2 -0
  147. package/dist/store/store.mjs.map +1 -0
  148. package/dist/store/usePillQueue.d.mts +6 -0
  149. package/dist/store/usePillQueue.d.ts +6 -0
  150. package/dist/store/usePillQueue.js +2 -0
  151. package/dist/store/usePillQueue.js.map +1 -0
  152. package/dist/store/usePillQueue.mjs +2 -0
  153. package/dist/store/usePillQueue.mjs.map +1 -0
  154. package/dist/styles.css +427 -0
  155. package/dist/utils/react.js +2 -0
  156. package/dist/utils/react.js.map +1 -0
  157. package/dist/utils/react.mjs +2 -0
  158. package/dist/utils/react.mjs.map +1 -0
  159. package/dist/utils/url.js +2 -0
  160. package/dist/utils/url.js.map +1 -0
  161. package/dist/utils/url.mjs +2 -0
  162. package/dist/utils/url.mjs.map +1 -0
  163. package/package.json +37 -24
  164. package/dist/MagicPill.d.ts +0 -8
  165. package/dist/Navbar/Navbar.d.ts +0 -9
  166. package/dist/Notification/Notification.d.ts +0 -9
  167. package/dist/defaultPillData.d.ts +0 -2
  168. package/dist/icons/arrow_label.d.ts +0 -3
  169. package/dist/icons/box_label.d.ts +0 -3
  170. package/dist/icons/checkmark.d.ts +0 -3
  171. package/dist/icons/checkmark_label.d.ts +0 -3
  172. package/dist/icons/coupon.d.ts +0 -3
  173. package/dist/icons/cross_label.d.ts +0 -3
  174. package/dist/icons/info.d.ts +0 -3
  175. package/dist/icons/mail_label.d.ts +0 -3
  176. package/dist/icons/plus_label.d.ts +0 -3
  177. package/dist/icons/questionmark.d.ts +0 -3
  178. package/dist/icons/quotation_label.d.ts +0 -3
  179. package/dist/icons/tel_label.d.ts +0 -3
  180. package/dist/icons/undo_label.d.ts +0 -3
  181. package/dist/index.esm.js +0 -2
  182. package/dist/index.esm.js.map +0 -1
  183. package/dist/index.js.map +0 -1
  184. package/dist/magicpill.css +0 -267
  185. package/dist/types/index.d.ts +0 -3
  186. package/dist/types/magicPill.d.ts +0 -50
  187. package/dist/types/navbar.d.ts +0 -27
  188. package/dist/types/notification.d.ts +0 -140
  189. package/dist/utils/handlers.d.ts +0 -19
  190. package/dist/utils/icons.d.ts +0 -18
package/README.md CHANGED
@@ -1,10 +1,7 @@
1
1
  # Magic Pill
2
2
  Let it empower you.
3
3
 
4
- ## Disclaimer
5
- Even though Magic Pill is already available to everyone, please keep in mind that its development is not over yet.
6
- You can technically use it but the documentation is still being improved.
7
- I'll update this section once a real usable version is released.
4
+ > **Status:** Magic Pill 9 is the first version with a **stable, documented API**. While it's in pre-release, install it with `npm install magic-pill@next`. The `latest` tag is still 8.1.0, documented in the [8.1.0 README](https://github.com/CedricTheveneau/Magic-Pill/tree/v8.1.0#readme). Coming from 8.x? Read the [migration guide](./MIGRATING.md).
8
5
 
9
6
  #### Thank you !!
10
7
  Thank you for your patience and to all people who already have shown interest in Magic Pill, it's my very first npm package and I couldn't ask for a better reception of my package after only a few days after its initial release.
@@ -15,284 +12,350 @@ Thank you for your patience and to all people who already have shown interest in
15
12
  [![DeepScan grade](https://deepscan.io/api/teams/23515/projects/28307/branches/911491/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=23515&pid=28307&bid=911491)
16
13
  [![Known Vulnerabilities](https://snyk.io/test/github/CedricTheveneau/Magic-Pill/badge.svg)](https://snyk.io/test/github/CedricTheveneau/Magic-Pill)
17
14
  [![install size](https://packagephobia.com/badge?p=magic-pill@latest)](https://packagephobia.com/result?p=magic-pill@latest)
18
- [<svg width=20 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 96"><path d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"></path></svg>](https://github.com/CedricTheveneau/Magic-Pill)
19
- [<svg width=20 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 7.334v8h6.666v1.332H12v-1.332h12v-8zm6.666 6.664H5.334v-4H3.999v4H1.335V8.667h5.331zm4 0v1.336H8.001V8.667h5.334v5.332zm12.001 0h-1.33v-4h-1.336v4h-1.335v-4h-1.33v4h-2.671V8.667h8.002z"></path><path d="M10.665 10H12v2.667h-1.335z"></path></svg>](https://www.npmjs.com/package/magic-pill)
20
15
 
21
16
  ## Introduction
22
- Magic Pill is a powerful React component that lets you show contextual information to your users in multiple ways. It can function as a notification system mimicking Apple's Dynamic Island, or as a dynamic navbar for seamless navigation. Built with TypeScript for enhanced type safety and developer experience.
17
+ Magic Pill is **a design primitive, not just a notification library.** At its core is *the pill*: a dark, fully rounded, elevated container with a strong design language, and you can put anything inside it.
18
+
19
+ On top of it come ready-made **templates** (a notification, a navbar) and a **controller** you can call from anywhere: `pill().notify(...)`. Use one pill as a discreet assistant at the bottom of the page, or several pills together (a sidebar, a navbar, a modal) to build a whole interface.
23
20
 
24
21
  ## Features
25
- - [X] Multiple modes: Notification system and Dynamic Navbar
26
- - [X] Written in TypeScript with comprehensive type definitions
27
- - [X] Highly customizable React component with strongly typed props
28
- - [X] Fully customized styling based on CSS variables for easy theme adaptation
29
- - [X] Built with NextJS in mind, also works with vanilla React
30
- - [X] No external library dependency (apart from bundling)
31
- - [X] Lightweight and efficient
32
- - [X] Full TypeScript support with proper type checking
22
+ - [X] Two lines to get started: mount `<MagicPill />`, then call `pill().notify(...)` from anywhere, even outside React
23
+ - [X] A notification queue on top of a **base layer** (e.g. a navbar): notifications take the pill over, then hand it back
24
+ - [X] Several named pills on one page, at any edge or corner, inline, or as a modal
25
+ - [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
26
+ - [X] Shape-changing animations (circle ↔ pill ↔ panel) that respect reduced motion
27
+ - [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
28
+ - [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
29
+ - [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
30
+ - [X] Written in TypeScript, zero runtime dependencies
33
31
 
34
32
  ## Installation
35
- ### CDN
36
- Want to quickly give it a try? Add Magic Pill to any React/NextJS project within 10 seconds with our CDN links!
37
- #### jsDelivr
38
- ```html
39
- <script src="https://cdn.jsdelivr.net/npm/magic-pill/dist/index.js"></script>
40
- <link href="https://cdn.jsdelivr.net/npm/magic-pill@latest/dist/magicpill.css" rel="stylesheet" />
33
+ ```bash
34
+ npm install magic-pill@next
41
35
  ```
42
- #### unpkg
43
- ```html
44
- <script src="https://unpkg.com/magic-pill@latest/dist/index.js"></script>
45
- <link href="https://unpkg.com/magic-pill@latest/dist/magicpill.css" rel="stylesheet" />
36
+
37
+ ### Requirements
38
+ - **React and React DOM 18 or later** (peer dependencies).
39
+ - **Next.js is optional**: Magic Pill works in any React app (Vite, React Router, Remix…).
40
+ - **TypeScript is optional**: the type definitions ship with the package.
41
+ - Browsers from 2023 onwards (the stylesheet uses CSS nesting and cascade layers).
42
+
43
+ > **No CDN build:** Magic Pill is published for bundlers (Next.js, Vite, webpack…) as ES modules and CommonJS. It has no UMD build, so it can't be loaded with a plain `<script>` tag yet.
44
+
45
+ ## Quick start
46
+ **1. Import the stylesheet and mount the pill once**, e.g. in your root layout:
47
+ ```tsx
48
+ // app/layout.tsx (Next.js App Router: this can stay a Server Component)
49
+ import "magic-pill/styles.css";
50
+ import { MagicPill } from "magic-pill";
51
+
52
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
53
+ return (
54
+ <html lang="en">
55
+ <body>
56
+ {children}
57
+ <MagicPill />
58
+ </body>
59
+ </html>
60
+ );
61
+ }
46
62
  ```
47
63
 
48
- ### npm
49
- Magic Pill is available on npm, simply use the following command and you're ready to go!
50
- ```bash
51
- npm install magic-pill
64
+ **2. Notify from anywhere** in your client code: an event handler, a store, a fetch callback…
65
+ ```tsx
66
+ import { pill, CheckIcon } from "magic-pill";
67
+
68
+ pill().notify({ icon: <CheckIcon />, message: "Saved!", variant: "success" });
52
69
  ```
53
70
 
54
- ## How to use it?
55
- ### Import styles
56
- For it to work properly, you need to import styles in your app (we recommend importing it into your app.tsx file).
57
- ```typescript
58
- // Import in your Next.js or React project
59
- import "magic-pill/dist/magicpill.css";
71
+ That's it. The pill pops in at the bottom of the page, stays for 5 seconds, then goes away.
72
+
73
+ ### Fonts
74
+ Magic Pill loads no fonts: it uses your page's fonts. For the signature look, an italic serif for messages (**Overlock**) and a bold sans for action labels (**Lexend**), point the two font tokens at them.
75
+
76
+ With `next/font`, the `variable` option sets the tokens directly:
77
+ ```tsx
78
+ // app/layout.tsx
79
+ import { Lexend, Overlock } from "next/font/google";
80
+
81
+ const overlock = Overlock({ subsets: ["latin"], style: "italic", weight: ["400", "700", "900"], variable: "--mp-font-text" });
82
+ const lexend = Lexend({ subsets: ["latin"], weight: "700", variable: "--mp-font-accent" });
83
+
84
+ // <html lang="en" className={`${overlock.variable} ${lexend.variable}`}>
60
85
  ```
61
86
 
62
- ### Usage with React/Next.js
63
- Magic Pill is designed to be used with a Context to manage its state globally. Here's how to set it up:
64
-
65
- 1. First, create a context for Magic Pill (e.g., in `app/contexts/magicPillContext.tsx`):
66
- ```typescript
67
- "use client"
68
- import React, { createContext, useContext, useState } from "react";
69
- import { MagicPillType, Mode, NotificationIcon, CTAIcon, MagicPillNavbarItem } from "magic-pill";
70
- import { updateMode, updateNotificationIcon, updateNotificationMessage, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoTitle, updateInfoContent, updateInfoCloseLabel, updateNavItemLabel, updateNavItemLink, updateNavItemIcon, addNavItem, deleteNavItem } from "magic-pill";
71
-
72
- const defaultPillData: MagicPillType = {
73
- mode: "navbar",
74
- navbar: {
75
- navItems: [
76
- {
77
- icon: "arrow",
78
- label: "mp-test",
79
- link: "/mp-test"
80
- },
81
- {
82
- icon: "cross",
83
- label: "demo",
84
- link: "/demo"
85
- }
86
- ]
87
- }
88
- };
89
-
90
- interface MagicPillContextType {
91
- pillData: MagicPillType;
92
- setPillData: (data: MagicPillType) => void;
93
- // Direct data manipulation methods
94
- updateMode: (mode: Mode) => void;
95
- updateNotificationIcon: (icon: NotificationIcon) => void;
96
- updateNotificationMessage: (message: string) => void;
97
- updateCTAIcon: (icon: CTAIcon) => void;
98
- updateCTALabel: (label: string) => void;
99
- updateCTALink: (link: string) => void;
100
- updateInfoTitle: (title: string) => void;
101
- updateInfoContent: (content: string) => void;
102
- updateInfoCloseLabel: (closeLabel: string) => void;
103
- updateNavItemLabel: (label: string, index: number) => void;
104
- updateNavItemLink: (link: string, index: number) => void;
105
- updateNavItemIcon: (icon: CTAIcon, index: number) => void;
106
- addNavItem: (navItem: MagicPillNavbarItem) => void;
107
- deleteNavItem: (index: number) => void;
87
+ Without Next.js, load the fonts however you like (self-hosted is best for privacy), then set the tokens:
88
+ ```css
89
+ :root {
90
+ --mp-font-text: "Overlock", serif;
91
+ --mp-font-accent: "Lexend", sans-serif;
108
92
  }
93
+ ```
109
94
 
110
- const MagicPillContext = createContext<MagicPillContextType>({
111
- pillData: defaultPillData,
112
- setPillData: () => {},
113
- updateMode: () => {},
114
- updateNotificationIcon: () => {},
115
- updateNotificationMessage: () => {},
116
- updateCTAIcon: () => {},
117
- updateCTALabel: () => {},
118
- updateCTALink: () => {},
119
- updateInfoTitle: () => {},
120
- updateInfoContent: () => {},
121
- updateInfoCloseLabel: () => {},
122
- updateNavItemLabel: () => {},
123
- updateNavItemLink: () => {},
124
- updateNavItemIcon: () => {},
125
- addNavItem: () => {},
126
- deleteNavItem: () => {},
95
+ ## Notifications
96
+ ```tsx
97
+ import { pill, CheckIcon, UndoIcon } from "magic-pill";
98
+
99
+ const id = pill().notify({
100
+ variant: "success",
101
+ icon: <CheckIcon />,
102
+ message: "Item successfully removed from cart!",
103
+ action: { icon: <UndoIcon />, label: "Undo", onClick: restoreItem },
104
+ duration: 8000,
127
105
  });
106
+ ```
128
107
 
129
- export const useMagicPill = () => {
130
- const context = useContext(MagicPillContext);
131
- if (!context) {
132
- throw new Error("useMagicPill must be used within a MagicPillProvider");
133
- }
134
- return context;
135
- };
136
-
137
- export const MagicPillProvider = ({
138
- children
139
- }: {
140
- children: React.ReactNode
141
- }) => {
142
- const [pillData, setPillData] = useState<MagicPillType>(defaultPillData);
143
-
144
- // Create wrapper functions that use the handlers with the local setPillData
145
- const contextValue: MagicPillContextType = {
146
- pillData,
147
- setPillData,
148
- updateMode: (mode: Mode) => updateMode(mode, setPillData),
149
- updateNotificationIcon: (icon: NotificationIcon) => updateNotificationIcon(icon, setPillData),
150
- updateNotificationMessage: (message: string) => updateNotificationMessage(message, setPillData),
151
- updateCTAIcon: (icon: CTAIcon) => updateCTAIcon(icon, setPillData),
152
- updateCTALabel: (label: string) => updateCTALabel(label, setPillData),
153
- updateCTALink: (link: string) => updateCTALink(link, setPillData),
154
- updateInfoTitle: (title: string) => updateInfoTitle(title, setPillData),
155
- updateInfoContent: (content: string) => updateInfoContent(content, setPillData),
156
- updateInfoCloseLabel: (closeLabel: string) => updateInfoCloseLabel(closeLabel, setPillData),
157
- updateNavItemLabel: (label: string, index: number) => updateNavItemLabel(label, index, setPillData),
158
- updateNavItemLink: (link: string, index: number) => updateNavItemLink(link, index, setPillData),
159
- updateNavItemIcon: (icon: CTAIcon, index: number) => updateNavItemIcon(icon, index, setPillData),
160
- addNavItem: (navItem: MagicPillNavbarItem) => addNavItem(navItem, setPillData),
161
- deleteNavItem: (index: number) => deleteNavItem(index, setPillData),
162
- };
108
+ | Option | Type | Notes |
109
+ |---|---|---|
110
+ | `message` | `ReactNode` | Required (unless you use `render`). Any content, e.g. `<>Total: <strong>768.99$</strong></>`. Never parsed as HTML. |
111
+ | `icon` | `ReactNode` | The leading icon, followed by the divider. |
112
+ | `action` | `{ icon?, label, onClick }` or `{ icon?, label, href }` | The round button. Its label shows on hover and focus. Clicking it dismisses the notification; call `event.preventDefault()` in `onClick` to keep it open. |
113
+ | `panel` | `{ title?, content, trigger?, closeLabel? }` | A "Learn more" action that grows the pill into a panel. `trigger` defaults to `{ icon: <PlusIcon />, label: "Learn more" }`, `closeLabel` to `"Close"`. |
114
+ | `variant` | `"neutral"` · `"success"` · `"danger"` · any string | Defaults to the host's variant. |
115
+ | `duration` | `number` (ms) | Defaults to the host's (5000). `Infinity` keeps it until dismissed. |
116
+ | `id` | `string` | Notifying again with the same id updates the notification in place. |
117
+ | `announce` | `string` · `false` | What screen readers hear. Defaults to the message's text. |
118
+ | `onDismiss` | `(id, reason) => void` | `reason` is `"timeout"`, `"action"`, `"dismissed"` or `"cleared"`. |
119
+ | `render` | `({ id, dismiss }) => ReactNode` | Your own content instead of the template, with the same queue, timing and animation. See [Your own templates](#your-own-templates). |
120
+
121
+ **How it behaves:**
122
+ - Notifications queue up and show one at a time, first in, first out.
123
+ - The countdown starts once the pill is fully shown. It pauses while the pill is hovered, holds keyboard focus or has its panel open, or while the browser tab is hidden, and it starts again from the full duration afterwards.
124
+ - Calls made before `<MagicPill>` mounts are kept, and shown once it mounts.
125
+ - `pill()` is for client code. Called on the server, it does nothing (it warns in development), so visitors never see each other's notifications.
126
+
127
+ **The controller:**
128
+ ```ts
129
+ const id = pill().notify({ message: "Saving…", duration: Infinity });
130
+ pill().update(id, { message: "Saved", variant: "success", duration: 3000 }); // in place, countdown restarts
131
+ pill().dismiss(id); // or pill().dismiss() for the visible one
132
+ pill().clear(); // empty the queue
133
+ ```
163
134
 
164
- return (
165
- <MagicPillContext.Provider value={contextValue}>
166
- {children}
167
- {pillData && <div id="magic-pill-root" />}
168
- </MagicPillContext.Provider>
169
- );
170
- };
135
+ **More examples**, the templates from the design:
136
+ ```tsx
137
+ // A question: the action is an answer
138
+ pill().notify({ icon: <HelpIcon />, message: "Do you need some help?", action: { icon: <CheckIcon />, label: "Yes", onClick: openHelp } });
139
+
140
+ // Live data, and a link (rendered with your router's link component, see below)
141
+ pill().notify({
142
+ icon: <InfoIcon />,
143
+ message: <>Your current cart total is: <strong>{total}$</strong></>,
144
+ action: { icon: <CheckIcon />, label: "Checkout", href: "/checkout" },
145
+ });
146
+
147
+ // A promotion that stays open while it works
148
+ pill().notify({
149
+ icon: <CouponIcon />,
150
+ message: "Interested in 10% off your next purchase?",
151
+ action: {
152
+ icon: <ArrowIcon />,
153
+ label: "Activate the promo code",
154
+ onClick: (event) => {
155
+ event.preventDefault();
156
+ activatePromo().then(() => pill().dismiss());
157
+ },
158
+ },
159
+ });
160
+
161
+ // An expandable panel
162
+ pill().notify({
163
+ icon: <InfoIcon />,
164
+ message: "Discover the powers Magic Pill gives you!",
165
+ panel: { title: "Discover the powers Magic Pill gives you!", content: <p>Anything can go in a panel.</p> },
166
+ duration: Infinity,
167
+ });
171
168
  ```
172
169
 
173
- 2. Wrap your app with the provider (in `app/layout.tsx`):
174
- ```typescript
175
- import "magic-pill/dist/magicpill.css";
176
- import { MagicPillProvider } from "./contexts/magicPillContext";
177
- import { MagicPillInitializer } from "./contexts/magicPillInitializer";
170
+ ## The host: `<MagicPill>`
171
+ `<MagicPill>` is a pill plus its queue. It takes every [`<Pill>` prop](#the-primitive) except `presence`, and adds:
172
+
173
+ | Prop | Default | Notes |
174
+ |---|---|---|
175
+ | `name` | `"main"` | Which `pill(name)` controls it. Mount one host per name. |
176
+ | `children` | none | The **base layer**: shown whenever no notification is. Without it, the pill hides between notifications. |
177
+ | `duration` | `5000` | Default display time for notifications. |
178
+ | `idle` | `"hidden"` | With no base layer and nothing queued: `"hidden"`, or `"rest"` for a small resting circle showing `idleIcon`. |
179
+ | `idleIcon` | none | The icon of the resting circle. |
180
+ | `linkComponent` | `<a>` | Renders notification actions that have an `href`, e.g. Next's `Link`. |
181
+ | `classNames` | none | Classes for the notification's parts: `icon`, `divider`, `message`, `actions`, `action`, `panel`. |
182
+ | `placement` | `"bottom"` | See [placements](#the-primitive). |
178
183
 
179
- export default function RootLayout({ children }) {
184
+ ### A navbar as the base layer
185
+ Notifications take the pill over, then it goes back to the navbar. The navbar works with any router: give it the current `pathname` and your link component.
180
186
 
187
+ ```tsx
188
+ // app/app-pill.tsx
189
+ "use client";
190
+ import Link from "next/link";
191
+ import { usePathname } from "next/navigation";
192
+ import { MagicPill, PillNavbar, BoxIcon, DocumentIcon, MailIcon } from "magic-pill";
193
+
194
+ const items = [
195
+ { href: "/", label: "Home", icon: <BoxIcon /> },
196
+ { href: "/blog", label: "Blog", icon: <DocumentIcon /> },
197
+ { href: "/contact", label: "Contact", icon: <MailIcon /> },
198
+ ];
199
+
200
+ export function AppPill() {
181
201
  return (
182
- <html lang="fr">
183
- <body>
184
- <MagicPillProvider>
185
- {children}
186
- <MagicPillInitializer />
187
- </MagicPillProvider>
188
- </body>
189
- </html>
202
+ <MagicPill linkComponent={Link}>
203
+ <PillNavbar items={items} pathname={usePathname()} linkComponent={Link} />
204
+ </MagicPill>
190
205
  );
191
206
  }
192
207
  ```
193
208
 
194
- 3. Create an initializer file for Magic Pill (e.g., in `app/contexts/magicPillInitializer.tsx`):
209
+ - **Matching:** an item is active on its own path and below it, on whole segments: `/blog` is active on `/blog/my-post`, not on `/blogroll`. `/` is only active on `/`. When several items match, the longest `href` wins. Override with `match: "exact"` or `match: (pathname) => boolean`.
210
+ - **The active link** shows its label and gets `aria-current="page"`.
211
+ - **Without `pathname`**, the navbar reads `window.location.pathname` after mounting and on back/forward navigation. That misses client-side navigations, so pass `pathname` when you use a client-side router.
212
+ - **`aria-label`** defaults to `"Main"`.
213
+
214
+ **React Router:** its `Link` takes `to` instead of `href`. Wrap it once:
195
215
  ```tsx
196
- "use client"
197
- import { MagicPill } from "magic-pill";
198
- import { useMagicPill } from "./magicPill";
216
+ import { forwardRef, type AnchorHTMLAttributes } from "react";
217
+ import { Link, useLocation } from "react-router";
218
+ import type { LinkComponent } from "magic-pill";
199
219
 
200
- export const MagicPillInitializer = () => {
201
- const { pillData } = useMagicPill();
220
+ export const RouterLink: LinkComponent = forwardRef<HTMLAnchorElement, AnchorHTMLAttributes<HTMLAnchorElement> & { href: string }>(
221
+ function RouterLink({ href, ...props }, ref) {
222
+ return <Link to={href} {...props} ref={ref} />;
223
+ },
224
+ );
202
225
 
203
- return (
204
- <MagicPill pillData={pillData}/>
205
- )
206
- };
226
+ // <PillNavbar items={items} pathname={useLocation().pathname} linkComponent={RouterLink} />
227
+ ```
228
+
229
+ ### Several pills
230
+ Give each host a name, and target it with `pill(name)`:
231
+ ```tsx
232
+ <MagicPill name="sidebar" placement="left">
233
+ <PillNavbar items={items} pathname={pathname} linkComponent={Link} />
234
+ </MagicPill>
235
+ <MagicPill name="assistant" placement="bottom-end" idle="rest" idleIcon={<HelpIcon />} />
236
+ ```
237
+ ```ts
238
+ pill("sidebar").notify({ message: "3 new posts" });
239
+ pill("assistant").notify({ icon: <HelpIcon />, message: "Need a hand?", duration: Infinity });
240
+ ```
241
+
242
+ ## The primitive
243
+ Everything above is built from `<Pill>` and its parts, and you can use them directly. A `<Pill>` you write yourself isn't connected to `pill()`: you control it with props.
244
+
245
+ ```tsx
246
+ import { Pill, PillActions, PillAction, PhoneIcon, MailIcon, DocumentIcon } from "magic-pill";
247
+
248
+ // The toolbox from the design: only actions
249
+ <Pill placement="bottom" aria-label="Contact us">
250
+ <PillActions>
251
+ <PillAction icon={<PhoneIcon />} label="Call us" href="tel:+33100000000" />
252
+ <PillAction icon={<MailIcon />} label="Send an email" href="mailto:hello@example.com" />
253
+ <PillAction icon={<DocumentIcon />} label="Ask for a quotation" href="/quote" linkComponent={Link} />
254
+ </PillActions>
255
+ </Pill>
207
256
  ```
208
- > **🎉 | At this point, if you launch you app, Magic Pill should appear in your view**
209
257
 
210
- 4. Use Magic Pill anywhere in your app (e.g., in `app/demo/page.tsx`):
211
- ```typescript
212
- "use client"
213
- import { useEffect } from "react";
214
- import { useMagicPill } from "../contexts/magicPillContext";
258
+ | `<Pill>` prop | Values | Default |
259
+ |---|---|---|
260
+ | `placement` | `"inline"` (in the page flow), `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-start"`, `"top-end"`, `"bottom-start"`, `"bottom-end"` (fixed; `start`/`end` follow the text direction), `"overlay"` (a modal `<dialog>`) | `"inline"` |
261
+ | `presence` / `defaultPresence` / `onPresenceChange` | `"hidden"`, `"rest"` (a circle with the icon only), `"compact"`, `"expanded"` (every action label shown), `"panel"` | `"compact"` |
262
+ | `orientation` | `"horizontal"`, `"vertical"` | `"vertical"` for `left`/`right` |
263
+ | `variant` | `"neutral"`, `"success"`, `"danger"`, or any string (see [Styling](#styling)) | `"neutral"` |
264
+ | `unstyled` | `boolean`: keep the behaviour, drop the look | `false` |
215
265
 
216
- export default function MPTest() {
217
- const { setPillData } = useMagicPill();
266
+ Any other prop (`className`, `aria-label`, `ref`…) goes to the element.
218
267
 
219
- useEffect(() => {
220
- setPillData({ mode: "notification", notification: { icon: "info", message: "Hello, world!" } });
221
- }, []);
268
+ **The parts:**
269
+ - `PillIcon`: the leading icon. Decorative unless you give it a `label`.
270
+ - `PillDivider`: the thin line after the icon.
271
+ - `PillMessage`: the message, in the italic serif.
272
+ - `PillActions` and `PillAction`: round buttons. `label` is required: it's the accessible name, and it shows on hover, on focus, with `expanded`, or at the `expanded` level. A `PillAction` is a `<button>` with `onClick`, or a link with `href` (through `linkComponent` if you pass one).
273
+ - `PillPanel` and `PillPanelTrigger`: content shown at the `panel` level, and the action that opens it. The panel takes the focus when it opens, closes on Escape or with its close button, and gives the focus back to the trigger. One panel per pill.
222
274
 
223
- return (
224
- <h1>Magic Pill Demo Page</h1>
225
- );
226
- }
275
+ **A modal:** `placement="overlay"` renders a native modal `<dialog>`, which brings a focus trap, Escape and an inert page with it.
276
+ ```tsx
277
+ <Pill placement="overlay" variant="danger" presence={open ? "compact" : "hidden"} onPresenceChange={(p) => setOpen(p !== "hidden")}>
278
+ <PillMessage>Delete this item?</PillMessage>
279
+ <PillActions>
280
+ <PillAction icon={<CheckIcon />} label="Delete" expanded onClick={confirmDelete} />
281
+ <PillAction icon={<CloseIcon />} label="Cancel" onClick={() => setOpen(false)} />
282
+ </PillActions>
283
+ </Pill>
227
284
  ```
228
- > **It really is as simple as that, to use Magic Pill, once the setup is done**
229
-
230
- ### Update Magic Pill's content granularly
231
- Magic Pill, right from the start, has been thought out to be as highly customizable as possible.
232
- To help you use it in the best way possible, a collection of handlers is part of the package.
233
-
234
- - `updateMode` - Change Magic Pill's mode between "notification" and "navbar"
235
- - `updateNotificationIcon` - Change the main notification icon
236
- - `updateNotificationMessage` - Change the main notification message
237
- - `updateCTAIcon` - Change the notification's CTA (Call To Action) icon
238
- - `updateCTALabel` - Change the notification's CTA (Call To Action) label
239
- - `updateCTALink` - Change the notification's CTA (Call To Action) redirection link
240
- - `updateInfoTitle` - Change the notification's expanded info title
241
- - `updateInfoContent` - Change the notification's expanded info main content
242
- - `updateInfoCloseLabel` - Change the notification's expanded info close button's label
243
- - `updateNavItemLabel` - Change a navbar item's label
244
- - `updateNavItemLink` - Change a navbar item's link
245
- - `updateNavItemIcon` - Change a navbar item's icon
246
- - `handleActiveNavItem` - Automatically working handler directly used by the navbar to update the active link
247
- - `addNavItem` - Add an item to the navbar
248
- - `deleteNavItem` - Delete an item to the navbar
249
-
250
- ### Available Icons
251
- #### Notification Icons
252
- - `"info"` - Information icon
253
- - `"checkmark"` - Success/confirmation icon
254
- - `"questionmark"` - Help/question icon
255
- - `"coupon"` - Coupon/offer icon
256
- - `""` - No icon
257
-
258
- #### CTA (Call to Action) Icons
259
- - `"arrow"` - Arrow icon
260
- - `"box"` - Box icon
261
- - `"checkmark"` - Checkmark icon
262
- - `"cross"` - Cross/close icon
263
- - `"info"` - Information icon
264
- - `"mail"` - Mail/email icon
265
- - `"plus"` - Plus/add icon
266
- - `"quotation"` - Quote/speech icon
267
- - `"tel"` - Phone/telephone icon
268
- - `"undo"` - Undo/back icon
269
- - `""` - No icon
270
-
271
- ### Customization
272
- Magic Pill is easily customizable through CSS variables. Simply replace the theme colors or fonts by changing the values in the variables set in ":root".
273
285
 
274
- ```css
275
- /* Font import */
276
- @import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap');
286
+ ### Your own templates
287
+ Templates are plain arrangements of the parts, so yours work the same way. `usePill()` gives a part access to its pill (`presence`, `setPresence`, `placement`, `orientation`, `variant`). Inside a `<MagicPill>`, the `render` option puts your arrangement in the queue:
277
288
 
278
- /* CSS variables */
279
- :root {
280
- --mp__themeDark: #141414;
281
- --mp__themeLight: #F9F9F9;
282
- --mp__font-text: "Overlock", sans-serif;
283
- --mp__font-accent: "Lexend", sans-serif;
284
- --mp__normal: normal;
285
- --mp__italic: italic;
286
- --mp__medium: 400;
287
- --mp__bold: 700;
288
- --mp__black: 900;
289
- --mp__success: #3F7253;
290
- --mp__danger: #FC5D6A;
291
- --mp__textSize: 19.4px;
292
- --mp__titleSize: 31.42px;
293
- }
289
+ ```tsx
290
+ pill().notify({
291
+ announce: "Incoming call from Alex",
292
+ duration: Infinity,
293
+ render: ({ dismiss }) => (
294
+ <>
295
+ <PillIcon><PhoneIcon /></PillIcon>
296
+ <PillDivider />
297
+ <PillMessage>Alex is calling</PillMessage>
298
+ <PillActions>
299
+ <PillAction icon={<CheckIcon />} label="Answer" onClick={() => { answer(); dismiss(); }} />
300
+ <PillAction icon={<CloseIcon />} label="Decline" onClick={dismiss} />
301
+ </PillActions>
302
+ </>
303
+ ),
304
+ });
294
305
  ```
295
306
 
307
+ ### React Server Components
308
+ - The parts, `PillAction`, `PillNotification`, the icons and `pill()` have no `"use client"`. A Server Component can render them (and pass `linkComponent={Link}`) without shipping them to the browser.
309
+ - `Pill`, `MagicPill`, `PillPanel`, `PillPanelTrigger`, `PillNavbar`, `usePill` and `usePillQueue` are Client Components. You can still render them from a Server Component.
310
+ - Call `pill()` from client code: event handlers, effects, client-side stores.
311
+
312
+ ### Headless: `usePillQueue`
313
+ To build your own display on the same store: `const { current, queued } = usePillQueue("main");`.
314
+
315
+ ## Icons
316
+ Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-hidden`). Any other icon or SVG works too: icons are just React content.
317
+
318
+ `ArrowIcon` · `BoxIcon` · `CheckIcon` · `CloseIcon` · `CouponIcon` · `DocumentIcon` · `HelpIcon` · `InfoIcon` · `MailIcon` · `PhoneIcon` · `PlusIcon` · `UndoIcon`
319
+
320
+ ## Styling
321
+ - **Easy to override:** every rule sits in a `magic-pill` cascade layer. Any CSS of yours that isn't in a layer wins, whatever its specificity, with no `!important`.
322
+ - **No collisions:** parts are selected by `data-mp` attributes (`[data-mp="pill"]`, `"icon"`, `"divider"`, `"message"`, `"actions"`, `"action"`, `"action-icon"`, `"label"`, `"panel"`, `"panel-title"`, `"panel-body"`, `"panel-footer"`, `"navbar"`), and states by `data-presence`, `data-placement`, `data-orientation` and `data-variant`. There are no class names of ours to clash with yours.
323
+ - **Classes:** every part takes a `className`; templates and `<MagicPill>` take `classNames`.
324
+ - **Tailwind CSS v4:** declare the layer order once, before your imports, so utilities win: `@layer theme, base, magic-pill, components, utilities;`.
325
+ - **Your own variants:** `variant="brand"` gives `data-variant="brand"`, so you can write `[data-variant="brand"] { --mp-surface: #4b2bd6; }`.
326
+
327
+ **Tokens:** set them on `:root`, on one pill, or anywhere in between.
328
+
329
+ | Token | Default |
330
+ |---|---|
331
+ | `--mp-surface` / `--mp-on-surface` | `#141414` / `#f9f9f9` |
332
+ | `--mp-action` / `--mp-on-action` | `#f9f9f9` / `#141414` |
333
+ | `--mp-success` / `--mp-danger` | `#3f7253` / `#c2303e` |
334
+ | `--mp-font-text` / `--mp-font-accent` | `inherit` (see [Fonts](#fonts)) |
335
+ | `--mp-text-size` / `--mp-title-size` | fluid, about 1rem / 1.5–2rem |
336
+ | `--mp-padding` / `--mp-gap` / `--mp-action-size` | `0.875rem` / `1rem` / `2.75rem` |
337
+ | `--mp-max-width` / `--mp-message-width` / `--mp-panel-width` | `48rem` / `24rem` / `32rem` |
338
+ | `--mp-radius-panel` / `--mp-shadow` | `2.5rem` / a soft drop shadow |
339
+ | `--mp-offset` / `--mp-z-index` | `1.5rem` from the viewport edges (plus safe areas) / `50` |
340
+ | `--mp-backdrop` | the overlay's backdrop |
341
+ | `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
342
+
343
+ The pill fits small screens: sizes are in `rem`, fixed pills stay inside the viewport and its safe areas, and long panels scroll.
344
+
345
+ ## Accessibility
346
+ - **Announcements:** each `<MagicPill>` has a polite live region that reads notifications out (or your `announce` text). A hidden pill leaves the accessibility tree.
347
+ - **Time to act:** the countdown pauses on hover and keyboard focus, and while a panel is open.
348
+ - **Panels and modals:** they take and give back the focus, and close on Escape. The overlay is a native modal `<dialog>`.
349
+ - **Accessible names:** every action has one (`label` is required), and icons are hidden from assistive technology.
350
+ - **Motion and contrast:** with `prefers-reduced-motion`, shape changes become short fades. In forced-colours mode, the shapes keep visible outlines.
351
+
352
+ ## Security
353
+ - **No HTML strings:** contents are React nodes and never parsed as HTML, so text from your users can't inject markup.
354
+ - **Safe links:** links only render relative, `http(s):`, `mailto:` and `tel:` URLs. Anything else, such as `javascript:`, renders without a link (with a warning in development). React 18 doesn't block those URLs by itself.
355
+
356
+ ## TypeScript
357
+ Everything is typed. The main types are `NotifyOptions`, `NotifyInput`, `PillController`, `MagicPillProps`, `PillProps`, `PillPresence`, `PillPlacement`, `PillVariant`, `NavItem` and `LinkComponent`.
358
+
296
359
  ## Build your own
297
360
  Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under [MIT License](https://www.tldrlegal.com/license/mit-license), which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
298
361
 
@@ -302,12 +365,20 @@ Here's how to proceed:
302
365
  git clone https://github.com/CedricTheveneau/Magic-Pill.git
303
366
  ```
304
367
 
305
- 2. Install all dependencies:
368
+ 2. Use the Node.js version from `.nvmrc` (Node 26) and install all dependencies:
306
369
  ```bash
370
+ nvm use
307
371
  npm install
308
372
  ```
309
373
 
310
- 3. You're good to go! For easier development, we recommend creating a Next.js app and creating a symbolic link between the app and the package. Now, when you're making changes to the code in src/, the changes should be reflected in your Next.js app.
374
+ 3. Check that everything works:
375
+ ```bash
376
+ npm run typecheck # TypeScript
377
+ npm test # Vitest test suite
378
+ npm run build # Builds dist/ with tsdown
379
+ ```
380
+
381
+ 4. You're good to go! For easier development, we recommend creating a Next.js app and creating a symbolic link between the app and the package. Now, when you're making changes to the code in src/, the changes should be reflected in your Next.js app.
311
382
  ```bash
312
383
  # Create a new Next.js app
313
384
  npx create-next-app@latest my-app --typescript
@@ -320,17 +391,16 @@ npm link magic-pill
320
391
  ```
321
392
 
322
393
  ## Troubleshooting / Contact
323
- Magic Pill is still under development, you'll certainly encounter issues with it.
324
- You can send me emails anytime at [theveneacedricpro@gmail.com](mailto:theveneacedricpro@gmail.com), I'll try my best to help you out.
394
+ Found a bug or something unclear? Please [open an issue](https://github.com/CedricTheveneau/Magic-Pill/issues).
395
+ You can also send me emails anytime at [theveneaucedricpro@gmail.com](mailto:theveneaucedricpro@gmail.com), I'll try my best to help you out.
325
396
 
326
397
  ## License
327
398
  Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/license/mit-license).
328
399
 
329
400
  ## What's next?
330
- | TODO | DOING |
401
+ | Coming next | Done in 9.0 |
331
402
  |-----------|-----------|
332
- | Support of custom svg icons | Animation fixes |
333
- | Transition between two modes | Responsive version + Proportions rework |
334
- | Implementation of function triggers on CTAs | Full documentation |
335
- | Transition between two modes | Proper testing |
336
- | Add new modes | |
403
+ | Toolbox and carousel indicator templates | Custom icons (any React content) |
404
+ | Animated morphing between contents | Transitions between the navbar and notifications |
405
+ | More built-in icons | Function triggers on actions (`onClick`) |
406
+ | A documentation site with live examples | Responsive styles, full documentation, tests |