magic-pill 8.1.0 → 9.0.0-next.1

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 (207) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/MIGRATING.md +224 -0
  3. package/README.md +312 -257
  4. package/dist/MagicPill/MagicPill.d.mts +27 -0
  5. package/dist/MagicPill/MagicPill.d.ts +27 -0
  6. package/dist/MagicPill/MagicPill.js +185 -0
  7. package/dist/MagicPill/MagicPill.mjs +185 -0
  8. package/dist/MagicPill/choreography.js +91 -0
  9. package/dist/MagicPill/choreography.mjs +85 -0
  10. package/dist/Pill/Pill.d.mts +7 -0
  11. package/dist/Pill/Pill.d.ts +7 -0
  12. package/dist/Pill/Pill.js +106 -0
  13. package/dist/Pill/Pill.mjs +106 -0
  14. package/dist/Pill/PillAction.d.mts +7 -0
  15. package/dist/Pill/PillAction.d.ts +7 -0
  16. package/dist/Pill/PillAction.js +67 -0
  17. package/dist/Pill/PillAction.mjs +67 -0
  18. package/dist/Pill/PillContext.d.mts +3 -0
  19. package/dist/Pill/PillContext.d.ts +3 -0
  20. package/dist/Pill/PillContext.js +26 -0
  21. package/dist/Pill/PillContext.mjs +24 -0
  22. package/dist/Pill/PillPanel.d.mts +9 -0
  23. package/dist/Pill/PillPanel.d.ts +9 -0
  24. package/dist/Pill/PillPanel.js +88 -0
  25. package/dist/Pill/PillPanel.mjs +87 -0
  26. package/dist/Pill/parts.d.mts +10 -0
  27. package/dist/Pill/parts.d.ts +10 -0
  28. package/dist/Pill/parts.js +46 -0
  29. package/dist/Pill/parts.mjs +43 -0
  30. package/dist/Pill/types.d.mts +88 -0
  31. package/dist/Pill/types.d.ts +88 -0
  32. package/dist/PillNavbar/PillNavbar.d.mts +31 -0
  33. package/dist/PillNavbar/PillNavbar.d.ts +31 -0
  34. package/dist/PillNavbar/PillNavbar.js +44 -0
  35. package/dist/PillNavbar/PillNavbar.mjs +44 -0
  36. package/dist/PillNavbar/matchPath.d.mts +2 -0
  37. package/dist/PillNavbar/matchPath.d.ts +2 -0
  38. package/dist/PillNavbar/matchPath.js +34 -0
  39. package/dist/PillNavbar/matchPath.mjs +34 -0
  40. package/dist/PillNotification/PillNotification.d.mts +51 -0
  41. package/dist/PillNotification/PillNotification.d.ts +51 -0
  42. package/dist/PillNotification/PillNotification.js +64 -0
  43. package/dist/PillNotification/PillNotification.mjs +63 -0
  44. package/dist/icons/ArrowIcon.d.mts +4 -0
  45. package/dist/icons/ArrowIcon.d.ts +4 -0
  46. package/dist/icons/ArrowIcon.js +21 -0
  47. package/dist/icons/ArrowIcon.mjs +21 -0
  48. package/dist/icons/BoxIcon.d.mts +4 -0
  49. package/dist/icons/BoxIcon.d.ts +4 -0
  50. package/dist/icons/BoxIcon.js +21 -0
  51. package/dist/icons/BoxIcon.mjs +21 -0
  52. package/dist/icons/CheckIcon.d.mts +4 -0
  53. package/dist/icons/CheckIcon.d.ts +4 -0
  54. package/dist/icons/CheckIcon.js +17 -0
  55. package/dist/icons/CheckIcon.mjs +17 -0
  56. package/dist/icons/CloseIcon.d.mts +4 -0
  57. package/dist/icons/CloseIcon.d.ts +4 -0
  58. package/dist/icons/CloseIcon.js +17 -0
  59. package/dist/icons/CloseIcon.mjs +17 -0
  60. package/dist/icons/CouponIcon.d.mts +4 -0
  61. package/dist/icons/CouponIcon.d.ts +4 -0
  62. package/dist/icons/CouponIcon.js +17 -0
  63. package/dist/icons/CouponIcon.mjs +17 -0
  64. package/dist/icons/DocumentIcon.d.mts +4 -0
  65. package/dist/icons/DocumentIcon.d.ts +4 -0
  66. package/dist/icons/DocumentIcon.js +17 -0
  67. package/dist/icons/DocumentIcon.mjs +17 -0
  68. package/dist/icons/HelpIcon.d.mts +4 -0
  69. package/dist/icons/HelpIcon.d.ts +4 -0
  70. package/dist/icons/HelpIcon.js +17 -0
  71. package/dist/icons/HelpIcon.mjs +17 -0
  72. package/dist/icons/InfoIcon.d.mts +4 -0
  73. package/dist/icons/InfoIcon.d.ts +4 -0
  74. package/dist/icons/InfoIcon.js +17 -0
  75. package/dist/icons/InfoIcon.mjs +17 -0
  76. package/dist/icons/MailIcon.d.mts +4 -0
  77. package/dist/icons/MailIcon.d.ts +4 -0
  78. package/dist/icons/MailIcon.js +17 -0
  79. package/dist/icons/MailIcon.mjs +17 -0
  80. package/dist/icons/PhoneIcon.d.mts +4 -0
  81. package/dist/icons/PhoneIcon.d.ts +4 -0
  82. package/dist/icons/PhoneIcon.js +21 -0
  83. package/dist/icons/PhoneIcon.mjs +21 -0
  84. package/dist/icons/PlusIcon.d.mts +4 -0
  85. package/dist/icons/PlusIcon.d.ts +4 -0
  86. package/dist/icons/PlusIcon.js +17 -0
  87. package/dist/icons/PlusIcon.mjs +17 -0
  88. package/dist/icons/UndoIcon.d.mts +4 -0
  89. package/dist/icons/UndoIcon.d.ts +4 -0
  90. package/dist/icons/UndoIcon.js +21 -0
  91. package/dist/icons/UndoIcon.mjs +21 -0
  92. package/dist/icons/types.d.mts +3 -0
  93. package/dist/icons/types.d.ts +3 -0
  94. package/dist/index.d.mts +25 -8
  95. package/dist/index.d.ts +25 -9
  96. package/dist/index.js +50 -1
  97. package/dist/index.mjs +24 -1
  98. package/dist/store/store.d.mts +63 -0
  99. package/dist/store/store.d.ts +63 -0
  100. package/dist/store/store.js +104 -0
  101. package/dist/store/store.mjs +102 -0
  102. package/dist/store/usePillQueue.d.mts +6 -0
  103. package/dist/store/usePillQueue.d.ts +6 -0
  104. package/dist/store/usePillQueue.js +17 -0
  105. package/dist/store/usePillQueue.mjs +17 -0
  106. package/dist/styles.css +456 -0
  107. package/dist/utils/react.js +23 -0
  108. package/dist/utils/react.mjs +21 -0
  109. package/dist/utils/url.js +22 -0
  110. package/dist/utils/url.mjs +22 -0
  111. package/package.json +7 -4
  112. package/dist/MagicPill.d.mts +0 -6
  113. package/dist/MagicPill.d.ts +0 -7
  114. package/dist/MagicPill.js +0 -2
  115. package/dist/MagicPill.js.map +0 -1
  116. package/dist/MagicPill.mjs +0 -2
  117. package/dist/MagicPill.mjs.map +0 -1
  118. package/dist/Navbar/Navbar.js +0 -2
  119. package/dist/Navbar/Navbar.js.map +0 -1
  120. package/dist/Navbar/Navbar.mjs +0 -2
  121. package/dist/Navbar/Navbar.mjs.map +0 -1
  122. package/dist/Notification/Notification.js +0 -2
  123. package/dist/Notification/Notification.js.map +0 -1
  124. package/dist/Notification/Notification.mjs +0 -2
  125. package/dist/Notification/Notification.mjs.map +0 -1
  126. package/dist/defaultPillData.d.mts +0 -2
  127. package/dist/defaultPillData.d.ts +0 -3
  128. package/dist/defaultPillData.js +0 -7
  129. package/dist/defaultPillData.js.map +0 -1
  130. package/dist/defaultPillData.mjs +0 -7
  131. package/dist/defaultPillData.mjs.map +0 -1
  132. package/dist/icons/arrow_label.js +0 -2
  133. package/dist/icons/arrow_label.js.map +0 -1
  134. package/dist/icons/arrow_label.mjs +0 -2
  135. package/dist/icons/arrow_label.mjs.map +0 -1
  136. package/dist/icons/box_label.js +0 -2
  137. package/dist/icons/box_label.js.map +0 -1
  138. package/dist/icons/box_label.mjs +0 -2
  139. package/dist/icons/box_label.mjs.map +0 -1
  140. package/dist/icons/checkmark.js +0 -2
  141. package/dist/icons/checkmark.js.map +0 -1
  142. package/dist/icons/checkmark.mjs +0 -2
  143. package/dist/icons/checkmark.mjs.map +0 -1
  144. package/dist/icons/checkmark_label.js +0 -2
  145. package/dist/icons/checkmark_label.js.map +0 -1
  146. package/dist/icons/checkmark_label.mjs +0 -2
  147. package/dist/icons/checkmark_label.mjs.map +0 -1
  148. package/dist/icons/coupon.js +0 -2
  149. package/dist/icons/coupon.js.map +0 -1
  150. package/dist/icons/coupon.mjs +0 -2
  151. package/dist/icons/coupon.mjs.map +0 -1
  152. package/dist/icons/cross_label.js +0 -2
  153. package/dist/icons/cross_label.js.map +0 -1
  154. package/dist/icons/cross_label.mjs +0 -2
  155. package/dist/icons/cross_label.mjs.map +0 -1
  156. package/dist/icons/info.js +0 -2
  157. package/dist/icons/info.js.map +0 -1
  158. package/dist/icons/info.mjs +0 -2
  159. package/dist/icons/info.mjs.map +0 -1
  160. package/dist/icons/info_label.js +0 -2
  161. package/dist/icons/info_label.js.map +0 -1
  162. package/dist/icons/info_label.mjs +0 -2
  163. package/dist/icons/info_label.mjs.map +0 -1
  164. package/dist/icons/mail_label.js +0 -2
  165. package/dist/icons/mail_label.js.map +0 -1
  166. package/dist/icons/mail_label.mjs +0 -2
  167. package/dist/icons/mail_label.mjs.map +0 -1
  168. package/dist/icons/plus_label.js +0 -2
  169. package/dist/icons/plus_label.js.map +0 -1
  170. package/dist/icons/plus_label.mjs +0 -2
  171. package/dist/icons/plus_label.mjs.map +0 -1
  172. package/dist/icons/questionmark.js +0 -2
  173. package/dist/icons/questionmark.js.map +0 -1
  174. package/dist/icons/questionmark.mjs +0 -2
  175. package/dist/icons/questionmark.mjs.map +0 -1
  176. package/dist/icons/quotation_label.js +0 -2
  177. package/dist/icons/quotation_label.js.map +0 -1
  178. package/dist/icons/quotation_label.mjs +0 -2
  179. package/dist/icons/quotation_label.mjs.map +0 -1
  180. package/dist/icons/tel_label.js +0 -2
  181. package/dist/icons/tel_label.js.map +0 -1
  182. package/dist/icons/tel_label.mjs +0 -2
  183. package/dist/icons/tel_label.mjs.map +0 -1
  184. package/dist/icons/undo_label.js +0 -2
  185. package/dist/icons/undo_label.js.map +0 -1
  186. package/dist/icons/undo_label.mjs +0 -2
  187. package/dist/icons/undo_label.mjs.map +0 -1
  188. package/dist/magicpill.css +0 -315
  189. package/dist/types/index.d.ts +0 -4
  190. package/dist/types/magicPill.d.mts +0 -50
  191. package/dist/types/magicPill.d.ts +0 -50
  192. package/dist/types/navbar.d.mts +0 -27
  193. package/dist/types/navbar.d.ts +0 -28
  194. package/dist/types/notification.d.mts +0 -140
  195. package/dist/types/notification.d.ts +0 -141
  196. package/dist/utils/handlers.d.mts +0 -20
  197. package/dist/utils/handlers.d.ts +0 -21
  198. package/dist/utils/handlers.js +0 -2
  199. package/dist/utils/handlers.js.map +0 -1
  200. package/dist/utils/handlers.mjs +0 -2
  201. package/dist/utils/handlers.mjs.map +0 -1
  202. package/dist/utils/icons.d.mts +0 -20
  203. package/dist/utils/icons.d.ts +0 -20
  204. package/dist/utils/icons.js +0 -2
  205. package/dist/utils/icons.js.map +0 -1
  206. package/dist/utils/icons.mjs +0 -2
  207. package/dist/utils/icons.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased]
4
+ Work towards 9.0.0, the first release with a stable API. It's a breaking release: see [MIGRATING.md](./MIGRATING.md) to move from 8.x.
5
+
6
+ ### Added
7
+ - The pill primitive: `Pill` with its parts `PillIcon`, `PillDivider`, `PillMessage`, `PillActions`, `PillAction`, `PillPanel` and `PillPanelTrigger`, plus the `usePill()` hook to write your own templates
8
+ - Presence levels (`hidden`, `rest`, `compact`, `expanded`, `panel`), controlled or not
9
+ - Placements: `inline`, fixed at an edge or corner, or `overlay` (a native modal `<dialog>`)
10
+ - Horizontal or vertical orientation, and `neutral`, `success`, `danger` or custom variants
11
+ - Stateless parts and `PillAction` can be rendered by React Server Components without becoming client code
12
+ - Link actions take a `linkComponent` (e.g. Next's `Link`) and only render relative, `http(s):`, `mailto:` and `tel:` URLs. Any other scheme, such as `javascript:`, renders no link
13
+ - Templates built from those parts:
14
+ - `PillNotification`: icon, message, an action (`onClick` or `href`) and an optional expandable panel. Every content is a React node, so nothing is parsed as HTML any more
15
+ - `PillNavbar`: a `<nav>` of icon links for any router (`pathname`, `linkComponent`). Items match whole path segments, the longest match wins, and the active link gets `aria-current="page"`
16
+ - `<MagicPill>` and `pill(name)`: mount the host once, then call `pill().notify({...})` from anywhere, including outside React. This replaces the 8.x Context, Provider and Initializer (about 135 lines of user code)
17
+ - Notifications queue first in, first out, take the pill over, then hand it back to the host's **base layer** (its children, e.g. a `PillNavbar`), so navbar and notifications are no longer exclusive
18
+ - `update(id, patch)`, `dismiss(id?)`, `clear()`, and `notify()` with an existing `id` to update in place
19
+ - `duration` per notification or on the host (`Infinity` keeps it). The countdown pauses on hover, keyboard focus, an open panel and a hidden browser tab
20
+ - Action clicks dismiss the notification unless the handler calls `event.preventDefault()`; `onDismiss(id, reason)` reports `timeout`, `action`, `dismissed` or `cleared`
21
+ - `render` for your own template, which keeps the queue, timing and animation
22
+ - Several named hosts per page (`<MagicPill name="sidebar">`), and `idle="rest"` for a discreet resting circle
23
+ - Shape changes: the pill collapses to a circle, swaps its content there and grows back; with reduced motion, it fades instead
24
+ - Announcements go through a separate live region, so a hidden pill can leave the accessibility tree
25
+ - On the server, `pill()` does nothing (it warns in development), so requests never share notifications
26
+ - `usePillQueue(name)`: the queue as a hook, to build your own host
27
+ - Twelve icons as components (`ArrowIcon`, `BoxIcon`, `CheckIcon`, `CloseIcon`, `CouponIcon`, `DocumentIcon`, `HelpIcon`, `InfoIcon`, `MailIcon`, `PhoneIcon`, `PlusIcon`, `UndoIcon`): drawn in `currentColor`, decorative by default
28
+ - A new stylesheet, `magic-pill/styles.css`:
29
+ - every rule sits in a `magic-pill` cascade layer and targets `data-mp` attributes, so your own CSS overrides it without `!important` and no class names collide;
30
+ - it loads no fonts (it uses your page's fonts unless you set `--mp-font-text`/`--mp-font-accent`);
31
+ - it's sized in `rem`, fits phone screens and safe areas, and supports reduced motion and forced colours
32
+
33
+ - A migration guide from 8.x, [MIGRATING.md](./MIGRATING.md), shipped in the package
34
+ - The README is rewritten for v9: quick start, notifications, the host and its base layer, the primitive, React Server Components, styling and tokens, accessibility and security
35
+
36
+ ### Changed
37
+ - The published JavaScript is readable (not minified) and has no source maps. Your app bundles exactly the same amount of code (your bundler minifies it), and the package is about 40% smaller to install (196 kB unpacked instead of 331 kB in 9.0.0-next.0)
38
+ - Size, measured and checked in CI: the quick start (`MagicPill` + `pill()`) adds about 4.9 kB of gzipped JavaScript and 2.2 kB of gzipped CSS to an app (both minified, as your bundler does); a hand-written `Pill` with its parts, about 1.4 kB of JavaScript
39
+
40
+ ### Fixed (since 9.0.0-next.0)
41
+ - Global resets on links and buttons, such as `a { color: inherit }` or `button { background: none }`, no longer blank out the pill's actions: their look now lives on an inner `[data-mp="action-body"]`
42
+ - In a narrow container, an inline pill wraps its message instead of cutting off its action. While the pill grows, the message still stays on one line
43
+
44
+ ### Removed
45
+ - The 8.x API: the `pillData` prop and `mode`, the types (`MagicPillType`, `Mode`, `NotificationIcon`, `CTAIcon`, `MagicPillNotification*`, `MagicPillNavbar*`), the 15 handlers (`updateMode` … `handleActiveNavItem`), `Icons`, `CTAIcons`, `getIconComponent` and `defaultPillData`
46
+ - The 8.x stylesheet: its `.magicPill`/`.CTA`/… classes, the `--mp__*` variables and the Google Fonts `@import`. The `magic-pill/magicpill.css` and `magic-pill/dist/magicpill.css` paths now serve the new stylesheet
47
+ - Raw HTML content: `info.content` was injected with `dangerouslySetInnerHTML`. Contents are React nodes now
48
+
3
49
  ## [8.1.0] - 2026-11-19
4
50
  A maintenance release: bug fixes, accessibility, a modern build and an up-to-date toolchain. Imports, props and the documented stylesheet path are unchanged.
5
51
 
package/MIGRATING.md ADDED
@@ -0,0 +1,224 @@
1
+ # Migrating from Magic Pill 8 to 9
2
+
3
+ Magic Pill 9 is the first version with a stable, documented API. It's a breaking release, but most apps get **shorter**: the Context, Provider and Initializer that 8.x asked you to write (about 135 lines) go away.
4
+
5
+ ## Why it changed
6
+ In 8.x, your app owned the pill's state. You kept a `pillData` object in your own Context and changed it with 14 setters. The pill showed either a notification or a navbar, never both, and content was a fixed list of icon names, strings and raw HTML.
7
+
8
+ In 9, the package owns its state, and the API has three layers:
9
+ 1. **A primitive**, `<Pill>`, with parts (`PillIcon`, `PillMessage`, `PillAction`…) that take any React content.
10
+ 2. **Templates** made of those parts: `PillNotification` and `PillNavbar`.
11
+ 3. **A host and a controller**: mount `<MagicPill />` once, then call `pill().notify(...)` from anywhere. Notifications queue on top of a **base layer** (your navbar) instead of replacing it.
12
+
13
+ ## 1. Replace your Context with `<MagicPill />`
14
+ **Delete** the files the 8.x README had you create (`magicPillContext.tsx`, `magicPillInitializer.tsx`), the `<MagicPillProvider>` wrapper, and the `useMagicPill()` calls. Then mount the host once:
15
+
16
+ ```tsx
17
+ // app/layout.tsx
18
+ import "magic-pill/styles.css";
19
+ import { MagicPill } from "magic-pill";
20
+
21
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
22
+ return (
23
+ <html lang="en">
24
+ <body>
25
+ {children}
26
+ <MagicPill />
27
+ </body>
28
+ </html>
29
+ );
30
+ }
31
+ ```
32
+
33
+ `MagicPill` keeps its name, but it no longer takes `pillData`. TypeScript flags every old call site.
34
+
35
+ ## 2. Notifications
36
+ Where you used to set the notification mode, call `pill().notify()`:
37
+
38
+ ```tsx
39
+ // 8.x
40
+ setPillData({
41
+ mode: "notification",
42
+ notification: {
43
+ icon: "checkmark",
44
+ message: "Order confirmed",
45
+ cta: { icon: "arrow", label: "Track", link: "/orders" },
46
+ },
47
+ });
48
+
49
+ // 9
50
+ import { pill, CheckIcon, ArrowIcon } from "magic-pill";
51
+
52
+ pill().notify({
53
+ icon: <CheckIcon />,
54
+ message: "Order confirmed",
55
+ action: { icon: <ArrowIcon />, label: "Track", href: "/orders" },
56
+ });
57
+ ```
58
+
59
+ | 8.x | 9 |
60
+ |---|---|
61
+ | `notification.icon: "checkmark"` | `icon: <CheckIcon />` (any React content) |
62
+ | `notification.message: string` | `message: ReactNode` |
63
+ | `cta: { icon, label, link }` | `action: { icon, label, href }` |
64
+ | (no callbacks) | `action: { icon, label, onClick }` |
65
+ | `cta` + `info: { title, content, closeLabel }` | `panel: { trigger: { icon, label }, title, content, closeLabel }` |
66
+ | `info.content` (an HTML string) | `panel.content` (React content) |
67
+ | `updateNotificationMessage(…)`, `updateCTALabel(…)`… | `pill().update(id, { message: … })`, or `notify` again with the same `id` |
68
+ | a fixed 5 s | `duration` per notification, or on `<MagicPill duration>` |
69
+
70
+ **The expandable info panel:**
71
+ ```tsx
72
+ // 8.x
73
+ notification: {
74
+ icon: "info",
75
+ message: "Discover the powers Magic Pill gives you!",
76
+ cta: { icon: "plus", label: "Learn more" },
77
+ info: { title: "Discover", content: "<p>Magic Pill gives you <b>powers</b>.</p>", closeLabel: "Close" },
78
+ }
79
+
80
+ // 9
81
+ pill().notify({
82
+ icon: <InfoIcon />,
83
+ message: "Discover the powers Magic Pill gives you!",
84
+ panel: {
85
+ title: "Discover",
86
+ content: <p>Magic Pill gives you <b>powers</b>.</p>,
87
+ // trigger and closeLabel default to "+ Learn more" and "Close"
88
+ },
89
+ });
90
+ ```
91
+
92
+ > **HTML strings are gone.** If you have HTML you **trust** (never anything from your users), render it yourself: `content: <div dangerouslySetInnerHTML={{ __html: trustedHtml }} />`.
93
+
94
+ **What behaves differently:**
95
+ - **Every notification shows.** In 8.x, a notification only animated in again when its content changed. In 9, each `notify()` call is queued and shown in turn.
96
+ - **The animation is shorter and shape-based:** the pill pops in as a circle, then grows (about 0.75 s, against 2.5 s in 8.x). The 5 s countdown starts once the pill is fully shown.
97
+ - **Actions dismiss** the notification when clicked. Call `event.preventDefault()` in `onClick` to keep it open.
98
+ - **Pauses:** as in 8.1, hover and keyboard focus pause the countdown. An open panel and a hidden browser tab now pause it too.
99
+
100
+ ## 3. Navbar
101
+ The navbar is now the host's **base layer**: it stays mounted, notifications take the pill over, and then it comes back. Switching `mode` doesn't clear your items any more.
102
+
103
+ ```tsx
104
+ // 8.x
105
+ setPillData({
106
+ mode: "navbar",
107
+ navbar: { navItems: [{ icon: "arrow", label: "Home", link: "/" }, { icon: "mail", label: "Contact", link: "/contact" }] },
108
+ });
109
+
110
+ // 9: a client component, rendered once (e.g. from your layout)
111
+ "use client";
112
+ import Link from "next/link";
113
+ import { usePathname } from "next/navigation";
114
+ import { MagicPill, PillNavbar, ArrowIcon, MailIcon } from "magic-pill";
115
+
116
+ const items = [
117
+ { icon: <ArrowIcon />, label: "Home", href: "/" },
118
+ { icon: <MailIcon />, label: "Contact", href: "/contact" },
119
+ ];
120
+
121
+ export function AppPill() {
122
+ return (
123
+ <MagicPill linkComponent={Link}>
124
+ <PillNavbar items={items} pathname={usePathname()} linkComponent={Link} />
125
+ </MagicPill>
126
+ );
127
+ }
128
+ ```
129
+
130
+ | 8.x | 9 |
131
+ |---|---|
132
+ | `navItems: [{ icon, label?, link }]` | `items: [{ icon, label, href, match? }]`. **`label` is now required**: it's the link's accessible name. |
133
+ | `addNavItem`, `deleteNavItem`, `updateNavItem*` | Change the `items` array (your own React state) |
134
+ | `handleActiveNavItem` + `window.location`, matched by label | `pathname` prop + `match`, matched by `href` |
135
+ | Plain `<a>` (full page reloads in Next.js) | `linkComponent={Link}` |
136
+
137
+ The active item also changes: an item is active on its own path and below, on whole segments. In 8.x, a `/` item was active everywhere, and `/blog` matched `/blogroll`.
138
+
139
+ ## 4. Icons
140
+ Icons are components now, and any React content works as an icon.
141
+
142
+ | 8.x name | 9 component |
143
+ |---|---|
144
+ | `info` | `InfoIcon` |
145
+ | `checkmark` | `CheckIcon` |
146
+ | `questionmark` | `HelpIcon` |
147
+ | `coupon` | `CouponIcon` |
148
+ | `arrow` | `ArrowIcon` |
149
+ | `box` | `BoxIcon` |
150
+ | `cross` | `CloseIcon` |
151
+ | `mail` | `MailIcon` |
152
+ | `plus` | `PlusIcon` |
153
+ | `quotation` | `DocumentIcon` |
154
+ | `tel` | `PhoneIcon` |
155
+ | `undo` | `UndoIcon` |
156
+ | `""` (no icon) | leave `icon` out |
157
+
158
+ `Icons`, `CTAIcons` and `getIconComponent` are removed.
159
+
160
+ ## 5. Styling
161
+ **The stylesheet:** `import "magic-pill/styles.css"`. The 8.x paths (`magic-pill/magicpill.css`, `magic-pill/dist/magicpill.css`) still work and serve the new stylesheet.
162
+
163
+ **Fonts are no longer loaded for you.** 8.x imported Lexend and Overlock from Google Fonts. That sent your visitors' IP addresses to Google, and Turbopack dropped the import anyway. 9 uses your page's fonts. To keep the 8.x look, set the font tokens, e.g. with `next/font`:
164
+
165
+ ```tsx
166
+ import { Lexend, Overlock } from "next/font/google";
167
+
168
+ const overlock = Overlock({ subsets: ["latin"], style: "italic", weight: ["400", "700", "900"], variable: "--mp-font-text" });
169
+ const lexend = Lexend({ subsets: ["latin"], weight: "700", variable: "--mp-font-accent" });
170
+ // <html className={`${overlock.variable} ${lexend.variable}`}>
171
+ ```
172
+
173
+ **Tokens:**
174
+
175
+ | 8.x | 9 |
176
+ |---|---|
177
+ | `--mp__themeDark` | `--mp-surface` (the pill) and `--mp-on-action` (text on buttons) |
178
+ | `--mp__themeLight` | `--mp-on-surface` (text on the pill) and `--mp-action` (buttons) |
179
+ | `--mp__font-text` / `--mp__font-accent` | `--mp-font-text` / `--mp-font-accent` (default: `inherit`) |
180
+ | `--mp__success` | `--mp-success` |
181
+ | `--mp__danger` | `--mp-danger`. The default is now `#c2303e`: 8.x's `#fc5d6a` was too light for white text. |
182
+ | `--mp__textSize` / `--mp__titleSize` | `--mp-text-size` / `--mp-title-size` (fluid `rem` defaults instead of px) |
183
+ | `--mp__normal`, `--mp__italic`, `--mp__medium`, `--mp__bold`, `--mp__black` | Removed. Style the parts directly, e.g. `[data-mp="message"] { font-style: normal; }` |
184
+
185
+ 9 also adds spacing, size, radius, shadow, offset and duration tokens. See the README's [Styling](./README.md#styling) section.
186
+
187
+ **Selectors:** 8.x used class names under `html > body`, and overriding them took high specificity or `!important`. 9 uses `data-mp` attributes inside a cascade layer, so any rule of yours wins:
188
+
189
+ | 8.x | 9 |
190
+ |---|---|
191
+ | `.magicPill` | `[data-mp="pill"]` |
192
+ | `.magicPill.out` / `.entry` / `.active` | `[data-presence="hidden"]` / `"rest"` / `"compact"` (also `"expanded"`, `"panel"`) |
193
+ | `.message` | `[data-mp="message"]` |
194
+ | `.CTA` | `[data-mp="action"]` (its label: `[data-mp="label"]`) |
195
+ | `.CTA.active` (navbar) | `[data-mp="action"][aria-current="page"]` |
196
+ | `.info` / `.info .title` / `.info .content` | `[data-mp="panel"]` / `[data-mp="panel-title"]` / `[data-mp="panel-body"]` |
197
+ | `.navbar` | `[data-mp="navbar"]` |
198
+
199
+ **Responsive:** 8.x needed your own mobile CSS (the demo had some). 9 fits small screens by itself, so you can probably delete those overrides.
200
+
201
+ ## 6. Security
202
+ - **No raw HTML:** content isn't parsed as HTML any more (see the note in step 2).
203
+ - **Safe links:** links only render relative, `http(s):`, `mailto:` and `tel:` URLs. A `javascript:` URL now renders without a link (with a warning in development), even on React 18, which doesn't block it.
204
+
205
+ ## 7. Removed exports
206
+ `pillData`, `MagicPillType`, `Mode`, `NotificationIcon`, `CTAIcon`, `MagicPillNotification`, `MagicPillNotificationCTA`, `MagicPillNotificationInfo`, `MagicPillNavbar`, `MagicPillNavbarItem`, `updateMode`, `updateNotificationIcon`, `updateNotificationMessage`, `updateCTAIcon`, `updateCTALabel`, `updateCTALink`, `updateInfoTitle`, `updateInfoContent`, `updateInfoCloseLabel`, `updateNavItemLabel`, `updateNavItemLink`, `updateNavItemIcon`, `addNavItem`, `deleteNavItem`, `handleActiveNavItem`, `Icons`, `CTAIcons`, `getIconComponent`, `defaultPillData`.
207
+
208
+ ## Checklist
209
+ Search your code for leftovers:
210
+
211
+ ```bash
212
+ # 8.x API
213
+ grep -rnE "pillData|useMagicPill|MagicPillProvider|update(Mode|Notification|CTA|Info|NavItem)|(add|delete)NavItem|handleActiveNavItem|getIconComponent|CTAIcons|defaultPillData|MagicPillType|NotificationIcon|CTAIcon" src app
214
+
215
+ # 8.x styles
216
+ grep -rnE "\.magicPill|\.CTA|--mp__" --include="*.css" --include="*.scss" .
217
+ ```
218
+
219
+ Then check that:
220
+ - [ ] `<MagicPill />` is mounted once (per name), and `magic-pill/styles.css` is imported.
221
+ - [ ] Notifications go through `pill().notify()`, and the navbar is a `PillNavbar` inside `<MagicPill>`.
222
+ - [ ] Every nav item has a `label`.
223
+ - [ ] The fonts are set, if you want the Overlock + Lexend look.
224
+ - [ ] Custom CSS targets `data-mp` attributes and `--mp-*` tokens.