@vibes.diy/prompts 14.3.203 → 14.3.205

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 (256) hide show
  1. package/index.d.ts +0 -1
  2. package/index.js +0 -1
  3. package/index.js.map +1 -1
  4. package/llms/access.md +4 -4
  5. package/llms/backend.md +15 -1
  6. package/llms/blockly.md +2 -2
  7. package/llms/bluesky.md +1 -1
  8. package/llms/board-games.md +3 -3
  9. package/llms/calendar.md +1 -1
  10. package/llms/callai.md +4 -4
  11. package/llms/connections.md +1 -1
  12. package/llms/create-vibe.md +3 -3
  13. package/llms/fireproof.md +7 -7
  14. package/llms/github.md +7 -2
  15. package/llms/image-gen.md +2 -2
  16. package/llms/index.d.ts +28 -28
  17. package/llms/index.js +84 -84
  18. package/llms/index.js.map +1 -1
  19. package/llms/maps.md +1 -1
  20. package/llms/match-style.md +1 -1
  21. package/llms/motion.md +7 -7
  22. package/llms/p5.md +1 -1
  23. package/llms/physics.md +2 -2
  24. package/llms/reskin.md +21 -21
  25. package/llms/richtext.md +5 -5
  26. package/llms/spotify.md +1 -1
  27. package/llms/stripe-subscriptions.js +1 -1
  28. package/llms/stripe-subscriptions.js.map +1 -1
  29. package/llms/stripe-subscriptions.md +179 -35
  30. package/llms/stripe.js +5 -1
  31. package/llms/stripe.js.map +1 -1
  32. package/llms/stripe.md +247 -58
  33. package/llms/strudel.md +3 -3
  34. package/llms/three-js.md +4 -4
  35. package/llms/touch-games.js +1 -1
  36. package/llms/touch-games.js.map +1 -1
  37. package/llms/touch-games.md +3 -3
  38. package/llms/ui-blog.d.ts +2 -0
  39. package/llms/ui-blog.js +7 -0
  40. package/llms/ui-blog.js.map +1 -0
  41. package/llms/{pouf-blog.md → ui-blog.md} +10 -10
  42. package/llms/ui-booking.d.ts +2 -0
  43. package/llms/ui-booking.js +7 -0
  44. package/llms/ui-booking.js.map +1 -0
  45. package/llms/{pouf-booking.md → ui-booking.md} +8 -8
  46. package/llms/ui-calendar.d.ts +2 -0
  47. package/llms/ui-calendar.js +7 -0
  48. package/llms/ui-calendar.js.map +1 -0
  49. package/llms/{pouf-calendar.md → ui-calendar.md} +5 -5
  50. package/llms/ui-chat.d.ts +2 -0
  51. package/llms/ui-chat.js +7 -0
  52. package/llms/ui-chat.js.map +1 -0
  53. package/llms/{pouf-chat.md → ui-chat.md} +4 -4
  54. package/llms/ui-contact.d.ts +2 -0
  55. package/llms/ui-contact.js +7 -0
  56. package/llms/ui-contact.js.map +1 -0
  57. package/llms/{pouf-contact.md → ui-contact.md} +7 -7
  58. package/llms/ui-course.d.ts +2 -0
  59. package/llms/ui-course.js +7 -0
  60. package/llms/ui-course.js.map +1 -0
  61. package/llms/{pouf-course.md → ui-course.md} +9 -9
  62. package/llms/ui-crm.d.ts +2 -0
  63. package/llms/ui-crm.js +7 -0
  64. package/llms/ui-crm.js.map +1 -0
  65. package/llms/{pouf-crm.md → ui-crm.md} +5 -5
  66. package/llms/ui-dashboard.d.ts +2 -0
  67. package/llms/ui-dashboard.js +7 -0
  68. package/llms/ui-dashboard.js.map +1 -0
  69. package/llms/{pouf-dashboard.md → ui-dashboard.md} +7 -7
  70. package/llms/ui-editorial.d.ts +2 -0
  71. package/llms/ui-editorial.js +7 -0
  72. package/llms/ui-editorial.js.map +1 -0
  73. package/llms/{pouf-editorial.md → ui-editorial.md} +5 -5
  74. package/llms/ui-event.d.ts +2 -0
  75. package/llms/ui-event.js +7 -0
  76. package/llms/ui-event.js.map +1 -0
  77. package/llms/{pouf-event.md → ui-event.md} +5 -5
  78. package/llms/ui-feed.d.ts +2 -0
  79. package/llms/ui-feed.js +7 -0
  80. package/llms/ui-feed.js.map +1 -0
  81. package/llms/{pouf-feed.md → ui-feed.md} +5 -5
  82. package/llms/ui-game.d.ts +2 -0
  83. package/llms/ui-game.js +7 -0
  84. package/llms/ui-game.js.map +1 -0
  85. package/llms/{pouf-game.md → ui-game.md} +6 -6
  86. package/llms/ui-inbox.d.ts +2 -0
  87. package/llms/ui-inbox.js +7 -0
  88. package/llms/ui-inbox.js.map +1 -0
  89. package/llms/{pouf-inbox.md → ui-inbox.md} +5 -5
  90. package/llms/ui-inventory.d.ts +2 -0
  91. package/llms/ui-inventory.js +7 -0
  92. package/llms/ui-inventory.js.map +1 -0
  93. package/llms/{pouf-inventory.md → ui-inventory.md} +5 -5
  94. package/llms/ui-kanban.d.ts +2 -0
  95. package/llms/ui-kanban.js +7 -0
  96. package/llms/ui-kanban.js.map +1 -0
  97. package/llms/{pouf-kanban.md → ui-kanban.md} +5 -5
  98. package/llms/ui-landing.d.ts +2 -0
  99. package/llms/ui-landing.js +7 -0
  100. package/llms/ui-landing.js.map +1 -0
  101. package/llms/{pouf-landing.md → ui-landing.md} +6 -6
  102. package/llms/ui-login.d.ts +2 -0
  103. package/llms/ui-login.js +7 -0
  104. package/llms/ui-login.js.map +1 -0
  105. package/llms/{pouf-login.md → ui-login.md} +7 -7
  106. package/llms/ui-music.d.ts +2 -0
  107. package/llms/ui-music.js +7 -0
  108. package/llms/ui-music.js.map +1 -0
  109. package/llms/{pouf-music.md → ui-music.md} +6 -6
  110. package/llms/ui-onboarding.d.ts +2 -0
  111. package/llms/ui-onboarding.js +7 -0
  112. package/llms/ui-onboarding.js.map +1 -0
  113. package/llms/{pouf-onboarding.md → ui-onboarding.md} +5 -5
  114. package/llms/ui-pricing.d.ts +2 -0
  115. package/llms/ui-pricing.js +7 -0
  116. package/llms/ui-pricing.js.map +1 -0
  117. package/llms/{pouf-pricing.md → ui-pricing.md} +5 -5
  118. package/llms/ui-profile.d.ts +2 -0
  119. package/llms/ui-profile.js +7 -0
  120. package/llms/ui-profile.js.map +1 -0
  121. package/llms/{pouf-profile.md → ui-profile.md} +4 -4
  122. package/llms/ui-quiz.d.ts +2 -0
  123. package/llms/ui-quiz.js +7 -0
  124. package/llms/ui-quiz.js.map +1 -0
  125. package/llms/{pouf-quiz.md → ui-quiz.md} +6 -6
  126. package/llms/ui-settings.d.ts +2 -0
  127. package/llms/ui-settings.js +7 -0
  128. package/llms/ui-settings.js.map +1 -0
  129. package/llms/{pouf-settings.md → ui-settings.md} +5 -5
  130. package/llms/ui-storefront.d.ts +2 -0
  131. package/llms/ui-storefront.js +7 -0
  132. package/llms/ui-storefront.js.map +1 -0
  133. package/llms/ui-storefront.md +468 -0
  134. package/llms/ui-support.d.ts +2 -0
  135. package/llms/ui-support.js +7 -0
  136. package/llms/ui-support.js.map +1 -0
  137. package/llms/{pouf-support.md → ui-support.md} +5 -5
  138. package/llms/ui-testimonials.d.ts +2 -0
  139. package/llms/ui-testimonials.js +7 -0
  140. package/llms/ui-testimonials.js.map +1 -0
  141. package/llms/{pouf-testimonials.md → ui-testimonials.md} +6 -6
  142. package/llms/ui-todo.d.ts +2 -0
  143. package/llms/ui-todo.js +7 -0
  144. package/llms/ui-todo.js.map +1 -0
  145. package/llms/{pouf-todo.md → ui-todo.md} +5 -5
  146. package/llms/ui-weather.d.ts +2 -0
  147. package/llms/ui-weather.js +7 -0
  148. package/llms/ui-weather.js.map +1 -0
  149. package/llms/{pouf-weather.md → ui-weather.md} +5 -5
  150. package/llms/use-vibe.md +4 -4
  151. package/llms/use-viewer.md +5 -5
  152. package/llms/voxel.md +1 -1
  153. package/llms/web-audio.md +12 -12
  154. package/llms/worlds.md +3 -3
  155. package/llms/youtube.md +1 -1
  156. package/package.json +5 -5
  157. package/system-prompt-initial-instant.md +3 -3
  158. package/system-prompt-initial-oneshot.md +1 -1
  159. package/system-prompt-initial.md +1 -1
  160. package/system-prompt.md +4 -4
  161. package/themes/colorsets.js +7 -7
  162. package/themes/colorsets.js.map +1 -1
  163. package/themes/looks/pouf/brief.md +87 -87
  164. package/themes/looks/pouf/catalog.generated.d.ts +1 -1
  165. package/themes/looks/pouf/catalog.generated.js +17 -17
  166. package/themes/looks/pouf/catalog.generated.js.map +1 -1
  167. package/themes/looks/pouf/variety.js +4 -4
  168. package/themes/looks/pouf/variety.js.map +1 -1
  169. package/llms/pouf-blog.d.ts +0 -2
  170. package/llms/pouf-blog.js +0 -6
  171. package/llms/pouf-blog.js.map +0 -1
  172. package/llms/pouf-booking.d.ts +0 -2
  173. package/llms/pouf-booking.js +0 -6
  174. package/llms/pouf-booking.js.map +0 -1
  175. package/llms/pouf-calendar.d.ts +0 -2
  176. package/llms/pouf-calendar.js +0 -6
  177. package/llms/pouf-calendar.js.map +0 -1
  178. package/llms/pouf-chat.d.ts +0 -2
  179. package/llms/pouf-chat.js +0 -6
  180. package/llms/pouf-chat.js.map +0 -1
  181. package/llms/pouf-contact.d.ts +0 -2
  182. package/llms/pouf-contact.js +0 -6
  183. package/llms/pouf-contact.js.map +0 -1
  184. package/llms/pouf-course.d.ts +0 -2
  185. package/llms/pouf-course.js +0 -6
  186. package/llms/pouf-course.js.map +0 -1
  187. package/llms/pouf-crm.d.ts +0 -2
  188. package/llms/pouf-crm.js +0 -6
  189. package/llms/pouf-crm.js.map +0 -1
  190. package/llms/pouf-dashboard.d.ts +0 -2
  191. package/llms/pouf-dashboard.js +0 -6
  192. package/llms/pouf-dashboard.js.map +0 -1
  193. package/llms/pouf-editorial.d.ts +0 -2
  194. package/llms/pouf-editorial.js +0 -6
  195. package/llms/pouf-editorial.js.map +0 -1
  196. package/llms/pouf-event.d.ts +0 -2
  197. package/llms/pouf-event.js +0 -6
  198. package/llms/pouf-event.js.map +0 -1
  199. package/llms/pouf-feed.d.ts +0 -2
  200. package/llms/pouf-feed.js +0 -6
  201. package/llms/pouf-feed.js.map +0 -1
  202. package/llms/pouf-game.d.ts +0 -2
  203. package/llms/pouf-game.js +0 -6
  204. package/llms/pouf-game.js.map +0 -1
  205. package/llms/pouf-inbox.d.ts +0 -2
  206. package/llms/pouf-inbox.js +0 -6
  207. package/llms/pouf-inbox.js.map +0 -1
  208. package/llms/pouf-inventory.d.ts +0 -2
  209. package/llms/pouf-inventory.js +0 -6
  210. package/llms/pouf-inventory.js.map +0 -1
  211. package/llms/pouf-kanban.d.ts +0 -2
  212. package/llms/pouf-kanban.js +0 -6
  213. package/llms/pouf-kanban.js.map +0 -1
  214. package/llms/pouf-landing.d.ts +0 -2
  215. package/llms/pouf-landing.js +0 -6
  216. package/llms/pouf-landing.js.map +0 -1
  217. package/llms/pouf-login.d.ts +0 -2
  218. package/llms/pouf-login.js +0 -6
  219. package/llms/pouf-login.js.map +0 -1
  220. package/llms/pouf-music.d.ts +0 -2
  221. package/llms/pouf-music.js +0 -6
  222. package/llms/pouf-music.js.map +0 -1
  223. package/llms/pouf-onboarding.d.ts +0 -2
  224. package/llms/pouf-onboarding.js +0 -6
  225. package/llms/pouf-onboarding.js.map +0 -1
  226. package/llms/pouf-pricing.d.ts +0 -2
  227. package/llms/pouf-pricing.js +0 -6
  228. package/llms/pouf-pricing.js.map +0 -1
  229. package/llms/pouf-profile.d.ts +0 -2
  230. package/llms/pouf-profile.js +0 -6
  231. package/llms/pouf-profile.js.map +0 -1
  232. package/llms/pouf-quiz.d.ts +0 -2
  233. package/llms/pouf-quiz.js +0 -6
  234. package/llms/pouf-quiz.js.map +0 -1
  235. package/llms/pouf-settings.d.ts +0 -2
  236. package/llms/pouf-settings.js +0 -6
  237. package/llms/pouf-settings.js.map +0 -1
  238. package/llms/pouf-storefront.d.ts +0 -2
  239. package/llms/pouf-storefront.js +0 -6
  240. package/llms/pouf-storefront.js.map +0 -1
  241. package/llms/pouf-storefront.md +0 -293
  242. package/llms/pouf-support.d.ts +0 -2
  243. package/llms/pouf-support.js +0 -6
  244. package/llms/pouf-support.js.map +0 -1
  245. package/llms/pouf-testimonials.d.ts +0 -2
  246. package/llms/pouf-testimonials.js +0 -6
  247. package/llms/pouf-testimonials.js.map +0 -1
  248. package/llms/pouf-todo.d.ts +0 -2
  249. package/llms/pouf-todo.js +0 -6
  250. package/llms/pouf-todo.js.map +0 -1
  251. package/llms/pouf-weather.d.ts +0 -2
  252. package/llms/pouf-weather.js +0 -6
  253. package/llms/pouf-weather.js.map +0 -1
  254. package/look-restyle.d.ts +0 -49
  255. package/look-restyle.js +0 -199
  256. package/look-restyle.js.map +0 -1
@@ -95,7 +95,7 @@ Plain Tailwind utilities read the variables:
95
95
  `font-sans` goes once on the root element and every child inherits the face.
96
96
 
97
97
  **Every component is plain JSX with Tailwind utilities, written in the app itself.**
98
- A match-style app imports no look package (`@vibes.diy/pouf`, `@vibes.diy/look`):
98
+ A match-style app imports no look package (`@vibes.diy/ui`, `@vibes.diy/look`):
99
99
  its buttons, cards, rows and fields are a few lines of JSX each, shaped by the
100
100
  recipe below. Each extracted component file paints with the same utilities.
101
101
 
package/llms/motion.md CHANGED
@@ -14,7 +14,7 @@ stops when the component goes away.
14
14
 
15
15
  The sibling boundary: a list whose items fade and rise as they enter uses
16
16
  the house flourish, the `starting:` Tailwind classes, with no engine at all;
17
- a canvas that redraws every frame is `p5`, `worlds` or `physics`; pouf
17
+ a canvas that redraws every frame is `p5`, `worlds` or `physics`; the UI's
18
18
  components carry their own motion (a `Card` with `motion="lift"`, the
19
19
  toasts, the sheets). Motion is the right call when something on the page
20
20
  responds to scroll, to time, or to touch.
@@ -52,8 +52,8 @@ before the engine lands cancels the setup (measured: a `move` stopped during
52
52
  the load moved nothing). `motionScope()` is the collector.
53
53
 
54
54
  **Every helper reads the reduced-motion setting when it runs** and lands on
55
- the end state instead of animating. Pouf's own reduced-motion rule is scoped
56
- to pouf's elements, so an animation the app authors gets no safety net from
55
+ the end state instead of animating. The UI's own reduced-motion rule is scoped
56
+ to the UI's elements, so an animation the app authors gets no safety net from
57
57
  it; the helpers are the net (measured with the media feature emulated: lists
58
58
  land visible, reveals leave everything visible, the count shows its final
59
59
  number, the press does nothing, scroll progress still reports).
@@ -212,7 +212,7 @@ export function pressSquash(target, { scale = 0.94 } = {}) {
212
212
  ### `App.jsx`
213
213
  ```jsx app=story
214
214
  import React, { useEffect, useRef } from "react";
215
- import { Button, Card, Heading, Row, Spacer, Stack, Text } from "@vibes.diy/pouf";
215
+ import { Button, Card, Heading, Row, Spacer, Stack, Text } from "@vibes.diy/ui";
216
216
  import { countUp, motionScope, onEnter, pressSquash, reveal, scrollProgress, sequence, staggerIn } from "./lib/motion.js";
217
217
 
218
218
  const CHAPTERS = [
@@ -297,7 +297,7 @@ export default function App() {
297
297
  ```
298
298
 
299
299
  The JSX stays class-only: positions, sizes and colours are Tailwind classes
300
- and pouf props, and Motion writes transforms and opacity onto the elements
300
+ and component props, and Motion writes transforms and opacity onto the elements
301
301
  through refs and selectors. The one place a style is set in the app's own
302
302
  code is the progress bar's `transform` inside the scroll callback, through
303
303
  its ref, which is what a scroll binding is for.
@@ -434,7 +434,7 @@ export function pressSquash(target, { scale = 0.94 } = {}) {
434
434
  import React, { useEffect, useMemo, useRef, useState } from "react";
435
435
  import { useFireproof } from "use-fireproof";
436
436
  import { useVibe, useViewer } from "use-vibes";
437
- import { Button, Card, Field, Heading, Input, Row, Skeleton, Spacer, Stack, Text } from "@vibes.diy/pouf";
437
+ import { Button, Card, Field, Heading, Input, Row, Skeleton, Spacer, Stack, Text } from "@vibes.diy/ui";
438
438
  import { motionScope, move, pressSquash } from "./lib/motion.js";
439
439
 
440
440
  export default function App() {
@@ -544,7 +544,7 @@ is the baseline and animates nothing, every later snapshot's ids are
544
544
  remembered, and only a top note nobody has seen springs in, so a board that
545
545
  loaded with twenty notes stands still and a reorder moves nothing. (A board
546
546
  that is empty when it opens treats its first note as the baseline too; the
547
- second note is the first to spring.) Pouf's `Card motion="lift"` carries
547
+ second note is the first to spring.) The UI's `Card motion="lift"` carries
548
548
  the hover, so the app writes none of its own.
549
549
 
550
550
  ## Mobile
package/llms/p5.md CHANGED
@@ -24,7 +24,7 @@ the instance so remounts do not leak a second draw loop.
24
24
  ```jsx
25
25
  import React from "react";
26
26
  import p5 from "https://esm.sh/p5@1.11.13";
27
- import { Button, Row, Stack } from "@vibes.diy/pouf";
27
+ import { Button, Row, Stack } from "@vibes.diy/ui";
28
28
 
29
29
  const TAU = Math.PI * 2;
30
30
 
package/llms/physics.md CHANGED
@@ -225,7 +225,7 @@ from the pieces so the next drop replays the last one exactly.
225
225
  import React, { useEffect, useMemo, useRef, useState } from "react";
226
226
  import { useFireproof } from "use-fireproof";
227
227
  import { useVibe, useViewer } from "use-vibes";
228
- import { Badge, Button, Card, Field, Heading, Input, Row, Segmented, Skeleton, Spacer, Stack, Text } from "@vibes.diy/pouf";
228
+ import { Badge, Button, Card, Field, Heading, Input, Row, Segmented, Skeleton, Spacer, Stack, Text } from "@vibes.diy/ui";
229
229
  import { createWorld } from "./lib/physics.js";
230
230
 
231
231
  const WIDTH = 360;
@@ -495,7 +495,7 @@ button that applies a force to every body.
495
495
  ### `App.jsx`
496
496
  ```jsx app=tumble
497
497
  import React, { useEffect, useRef, useState } from "react";
498
- import { Button, Field, Heading, Input, Row, Spacer, Stack, Text } from "@vibes.diy/pouf";
498
+ import { Button, Field, Heading, Input, Row, Spacer, Stack, Text } from "@vibes.diy/ui";
499
499
  import { Matter, createWorld, cssColor } from "./lib/physics.js";
500
500
 
501
501
  const { Bodies, Body, Composite } = Matter;
package/llms/reskin.md CHANGED
@@ -7,8 +7,8 @@ the app keeps its look's components, its logic and its Look tab, and wears that
7
7
  appearance on top of them. Every `Card`, `Button`, `RowCard` and `Heading`
8
8
  stays exactly where it is; what changes is how they are drawn.
9
9
 
10
- This works on every look that shares the component surface (pouf today, and the
11
- looks built on its API): the same tokens, the same hook classes, the same
10
+ This works on every look that shares the component surface (the default look today,
11
+ and the looks built on its API): the same tokens, the same hook classes, the same
12
12
  technique.
13
13
 
14
14
  - Colour, a catalogue font or spacing alone is the Look tab (`set_app_style`);
@@ -30,24 +30,24 @@ so the wrapper's values are the ones every component reads.
30
30
  The tokens: `--bg --surface --ink --text-secondary --purple --on-accent
31
31
  --orange --info --up --down --idle --warn` (colour), `--r-card --r-control
32
32
  --r-pill` (corners), `--lip --lip-row` (the cushion's edge), `--font-family`,
33
- `--s1` … `--s7` (spacing), and the composite surfaces `--pouf-card --pouf-row
34
- --pouf-control --pouf-control-active --pouf-field --pouf-field-focus`. A
33
+ `--s1` … `--s7` (spacing), and the composite surfaces `--ui-card --ui-row
34
+ --ui-control --ui-control-active --ui-field --ui-field-focus`. A
35
35
  composite is resolved where it is declared, so a skin that changes the shadows
36
36
  or the edge re-declares those composites on the wrapper too (`none` for a flat
37
37
  skin).
38
38
 
39
39
  **2. The look's parts are styled through their hook classes, from the wrapper.**
40
- Every component carries a stable class: `.pouf-h1 .pouf-h2 .pouf-h3 .pouf-card
41
- .pouf-rowcard .pouf-btn .pouf-blob .pouf-empty .pouf-stat .pouf-eyebrow
42
- .pouf-grid .pouf-input .pouf-field .pouf-badge .pouf-tabs .pouf-dialog`, and the
43
- rest of the package's `pouf-*` names. Write the skin as `[data-reskin] .pouf-card
40
+ Every component carries a stable class: `.ui-h1 .ui-h2 .ui-h3 .ui-card
41
+ .ui-rowcard .ui-btn .ui-blob .ui-empty .ui-stat .ui-eyebrow
42
+ .ui-grid .ui-input .ui-field .ui-badge .ui-tabs .ui-dialog`, and the
43
+ rest of the package's `ui-*` names. Write the skin as `[data-reskin] .ui-card
44
44
  { … }`. The components themselves take no `className` and no `style`: they keep
45
45
  their props (`tone`, `size`, `variant`), and the skin reaches them by class.
46
46
 
47
47
  **Portaled parts stay in the skin.** `Dialog`, `Select`, `Popover`, `Tooltip`
48
48
  and `AlertDialog` render their open content under `<body>`, outside the
49
49
  wrapper. So the token block is declared on `[data-reskin], body:has([data-reskin])`,
50
- and a rule for a portaled part is written `body:has([data-reskin]) .pouf-dialog
50
+ and a rule for a portaled part is written `body:has([data-reskin]) .ui-dialog
51
51
  { … }`. `body` sits below `:root`, so its tokens win for the whole page, the
52
52
  open modal and dropdown included.
53
53
 
@@ -83,7 +83,7 @@ cushions, Chicago-like bitmap type (`Silkscreen`) over a plain grotesk body
83
83
  import React, { useState } from "react";
84
84
  import { useFireproof } from "use-fireproof";
85
85
  import { useVibe } from "use-vibes";
86
- import { Button, Card, Empty, Field, Heading, Input, Row, RowCard, Skeleton, Stack, Text } from "@vibes.diy/pouf";
86
+ import { Button, Card, Empty, Field, Heading, Input, Row, RowCard, Skeleton, Stack, Text } from "@vibes.diy/ui";
87
87
 
88
88
  const SKIN = `
89
89
  @import url('https://fonts.googleapis.com/css2?family=Silkscreen&family=Space+Grotesk:wght@400;600&display=swap');
@@ -92,8 +92,8 @@ const SKIN = `
92
92
  --purple: #000000; --on-accent: #ffffff;
93
93
  --r-card: 0px; --r-control: 0px; --r-pill: 0px; --lip: 0px; --lip-row: 0px;
94
94
  --font-family: 'Space Grotesk', system-ui, sans-serif;
95
- --pouf-card: none; --pouf-row: none; --pouf-control: none; --pouf-control-active: none;
96
- --pouf-field: inset 0 0 0 1px #000000; --pouf-field-focus: inset 0 0 0 2px #000000;
95
+ --ui-card: none; --ui-row: none; --ui-control: none; --ui-control-active: none;
96
+ --ui-field: inset 0 0 0 1px #000000; --ui-field-focus: inset 0 0 0 2px #000000;
97
97
  min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font-family);
98
98
  }
99
99
  [data-reskin] .menubar { background: #ffffff; border-bottom: 1px solid #000000; padding: 2px 12px; font-family: 'Silkscreen', monospace; }
@@ -101,12 +101,12 @@ const SKIN = `
101
101
  [data-reskin] .titlebar { height: 20px; border-bottom: 1px solid #000000; text-align: center; font-family: 'Silkscreen', monospace; font-size: 12px; line-height: 20px;
102
102
  background: repeating-linear-gradient(#ffffff 0 1px, #000000 1px 2px); }
103
103
  [data-reskin] .titlebar span { background: #ffffff; padding: 0 8px; }
104
- [data-reskin] .pouf-h1, [data-reskin] .pouf-h2 { font-family: 'Silkscreen', monospace; letter-spacing: 0; }
105
- [data-reskin] .pouf-card, [data-reskin] .pouf-rowcard { border: 1px solid #000000; }
106
- [data-reskin] .pouf-btn { border: 1px solid #000000; background: #ffffff; color: #000000; border-radius: 6px; }
107
- [data-reskin] .pouf-btn:active { background: #000000; color: #ffffff; }
108
- [data-reskin] .pouf-empty { border: 1px dashed #000000; }
109
- body:has([data-reskin]) .pouf-dialog { border: 1px solid #000000; border-radius: 0; box-shadow: 2px 2px 0 #000000; }
104
+ [data-reskin] .ui-h1, [data-reskin] .ui-h2 { font-family: 'Silkscreen', monospace; letter-spacing: 0; }
105
+ [data-reskin] .ui-card, [data-reskin] .ui-rowcard { border: 1px solid #000000; }
106
+ [data-reskin] .ui-btn { border: 1px solid #000000; background: #ffffff; color: #000000; border-radius: 6px; }
107
+ [data-reskin] .ui-btn:active { background: #000000; color: #ffffff; }
108
+ [data-reskin] .ui-empty { border: 1px dashed #000000; }
109
+ body:has([data-reskin]) .ui-dialog { border: 1px solid #000000; border-radius: 0; box-shadow: 2px 2px 0 #000000; }
110
110
  `;
111
111
 
112
112
  export default function App() {
@@ -232,7 +232,7 @@ let the components edit it.
232
232
 
233
233
  ```jsx
234
234
  import React, { useState } from "react";
235
- import { Button, Field, Input, Stack } from "@vibes.diy/pouf";
235
+ import { Button, Field, Input, Stack } from "@vibes.diy/ui";
236
236
 
237
237
  const SKIN = `
238
238
  @import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,600;1,400&display=swap');
@@ -289,7 +289,7 @@ example.
289
289
  Name the five things a stranger would recognise and set each one:
290
290
 
291
291
  - **Ground and surfaces:** `--bg`, `--surface`, `--ink`, `--text-secondary`.
292
- - **Type:** one display face for `.pouf-h1`/`.pouf-h2`/`.pouf-eyebrow`, one body
292
+ - **Type:** one display face for `.ui-h1`/`.ui-h2`/`.ui-eyebrow`, one body
293
293
  face on `--font-family`, the heading scale and tracking.
294
294
  - **Edges:** corners (`--r-card`, `--r-control`, `--r-pill`), borders on the
295
295
  hook classes, and the composite surfaces (`none` for flat, a hard offset for
@@ -302,5 +302,5 @@ Name the five things a stranger would recognise and set each one:
302
302
  A newspaper is a cream ground, black ink, a serif masthead over a rule, column
303
303
  grids and no shadows; a terminal is black, one phosphor green, a mono face and
304
304
  a blinking cursor that starts lit; Y2K is chrome gradients, pill corners and a
305
- glossy highlight on `.pouf-btn`. The words on screen stay the app's own: the
305
+ glossy highlight on `.ui-btn`. The words on screen stay the app's own: the
306
306
  style is borrowed, the names and logos of whoever made it famous are not.
package/llms/richtext.md CHANGED
@@ -10,8 +10,8 @@ in Fireproof, saves after typing pauses, loads a document without echoing it
10
10
  back as a save, and styles the written text with Tailwind on the host.
11
11
 
12
12
  The sibling boundary: a short field (a title, a comment, a caption) is
13
- pouf's `Textarea` in a `Field`; a feed of posts is `pouf-feed`; a pipeline
14
- of stories with stages is `pouf-editorial`. Rich text is the right call when
13
+ the UI's `Textarea` in a `Field`; a feed of posts is `ui-feed`; a pipeline
14
+ of stories with stages is `ui-editorial`. Rich text is the right call when
15
15
  the person is writing a page.
16
16
 
17
17
  The worked examples below were built and measured for this doc (Chromium,
@@ -165,7 +165,7 @@ export function createEditor(host, { content = EMPTY_DOC, placeholder = "Start w
165
165
  import React, { useEffect, useMemo, useRef, useState } from "react";
166
166
  import { useFireproof } from "use-fireproof";
167
167
  import { useVibe, useViewer } from "use-vibes";
168
- import { Badge, Button, Card, Heading, IconButton, Row, Skeleton, Spacer, Stack, Text } from "@vibes.diy/pouf";
168
+ import { Badge, Button, Card, Heading, IconButton, Row, Skeleton, Spacer, Stack, Text } from "@vibes.diy/ui";
169
169
  import { EMPTY_DOC, createEditor, titleOf } from "./lib/editor.js";
170
170
 
171
171
  // The written page is styled from the host: Tailwind reaches into the editor with arbitrary
@@ -471,7 +471,7 @@ through Tailwind's arbitrary variants**: `[&_h1]:text-2xl`,
471
471
  `[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]`.
472
472
  The JSX stays class-only and the theme tokens (`text-primary`,
473
473
  `text-muted-foreground`, `bg-muted`) carry the owner's restyle into the
474
- written page. Measured: the pouf lint passes a host carrying these classes.
474
+ written page. Measured: the design lint passes a host carrying these classes.
475
475
 
476
476
  ## Commands and the toolbar
477
477
 
@@ -553,7 +553,7 @@ export function createEditor(host, { content = EMPTY_DOC, placeholder = "Start w
553
553
  import React, { useEffect, useRef, useState } from "react";
554
554
  import { useFireproof } from "use-fireproof";
555
555
  import { useVibe, useViewer } from "use-vibes";
556
- import { Badge, Button, Card, Heading, Row, Spacer, Stack, Text } from "@vibes.diy/pouf";
556
+ import { Badge, Button, Card, Heading, Row, Spacer, Stack, Text } from "@vibes.diy/ui";
557
557
  import { EMPTY_DOC, createEditor } from "./lib/editor.js";
558
558
 
559
559
  const PAGE_ID = "page:home";
package/llms/spotify.md CHANGED
@@ -325,7 +325,7 @@ function artistRow(a) {
325
325
  ```jsx app=spotify-browser
326
326
  import React, { useEffect, useRef, useState } from "react";
327
327
  import { apiFetch } from "use-vibes";
328
- import { Badge, Button, Field, Heading, Input, Row, Stack, Text } from "@vibes.diy/pouf";
328
+ import { Badge, Button, Field, Heading, Input, Row, Stack, Text } from "@vibes.diy/ui";
329
329
 
330
330
  // The setup verdict, read on mount and again whenever the app comes back into view: the owner
331
331
  // sets the pair in another tab and returns, and search unlocks without a reload.
@@ -1,7 +1,7 @@
1
1
  export const stripeSubscriptionsConfig = {
2
2
  name: "stripe-subscriptions",
3
3
  label: "Stripe subscriptions",
4
- description: "A paid membership or subscription through Stripe Checkout in subscription mode, ONLY when the person asks for recurring money — monthly, yearly, subscribe, membership fee, paid tier, paywall — into the owner's own Stripe account through ctx.stripe, connected once with Connect Stripe: the Connect Stripe and Customer Portal setup items, test mode first with the membership's mode passed on every call and live once the owner takes this app live, every Stripe call in backend.js with no Stripe.js in the page, one pending membership then one Checkout Session opened in a new tab, entitlement computed from Stripe's status plus one GRACE_DAYS knob for a past_due card, members-only content as a channel the membership record grants and the backend withdraws, cancellation and card changes in Stripe's Customer Portal, and a scheduled sweep that re-reads every live subscription. A one-time charge (dues once, a ticket, a deposit) is the stripe skill; an app with members-only content that charges nothing does not need this — offer it as the [pay] option instead",
4
+ description: "A paid membership or subscription through Stripe Checkout in subscription mode, ONLY when the person asks for recurring money — monthly, yearly, subscribe, membership fee, paid tier, paywall — into the owner's own Stripe account through ctx.stripe, connected once with Connect Stripe: the plans are the owner's, plan records in the app's database with a price and a month or year interval that only the owner writes (access.js) from the app's own Plans screen, starting empty with the owner's first plan, and backend.js subscribes at the price it reads from the plan the member names, never an amount from the browser or a constant in backend.js; the Connect Stripe and Customer Portal setup items, test mode first with the membership's mode passed on every call and live once the owner takes this app live, every Stripe call in backend.js with no Stripe.js in the page, one pending membership then one Checkout Session opened in a new tab, entitlement computed from Stripe's status plus one GRACE_DAYS knob for a past_due card, members-only content as a channel the membership record grants and the backend withdraws, cancellation and card changes in Stripe's Customer Portal, and a scheduled sweep that re-reads every live subscription. A one-time charge (dues once, a ticket, a deposit) is the stripe skill; an app with members-only content that charges nothing does not need this — offer it as the [pay] option instead",
5
5
  cues: [
6
6
  "subscription",
7
7
  "subscribe",
@@ -1 +1 @@
1
- {"version":3,"file":"stripe-subscriptions.js","sourceRoot":"","sources":["../../jsr/llms/stripe-subscriptions.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,yBAAyB,GAAc;IAClD,IAAI,EAAE,sBAAsB;IAC5B,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EACT,siCAAsiC;IACxiC,IAAI,EAAE;QACJ,cAAc;QACd,WAAW;QACX,SAAS;QACT,WAAW;QACX,SAAS;QACT,QAAQ;QACR,gBAAgB;QAChB,iBAAiB;QACjB,WAAW;QACX,SAAS;QACT,WAAW;QACX,cAAc;QACd,iBAAiB;KAClB;CACF,CAAC"}
1
+ {"version":3,"file":"stripe-subscriptions.js","sourceRoot":"","sources":["../../jsr/llms/stripe-subscriptions.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,yBAAyB,GAAc;IAClD,IAAI,EAAE,sBAAsB;IAC5B,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EACT,g5CAAg5C;IACl5C,IAAI,EAAE;QACJ,cAAc;QACd,WAAW;QACX,SAAS;QACT,WAAW;QACX,SAAS;QACT,QAAQ;QACR,gBAAgB;QAChB,iBAAiB;QACjB,WAAW;QACX,SAAS;QACT,WAAW;QACX,cAAc;QACd,iBAAiB;KAClB;CACF,CAAC"}
@@ -26,6 +26,26 @@ grants. An app where each visitor sells their own subscriptions is a
26
26
  marketplace, a bigger thing than this recipe — say so and build the
27
27
  one-merchant half.
28
28
 
29
+ **The plans are the owner's, and they live in the app.**
30
+
31
+ The plans are the owner's: each plan is a plan record in the app's own database that only the owner writes, from the app's own screen, and backend.js subscribes the member at the price and interval it reads from that record — never an amount the browser sends, never a constant in backend.js.
32
+
33
+ The owner names each plan, sets its price and whether it renews monthly or
34
+ yearly, and takes one off sale, all from the app's own **Plans** screen with no
35
+ new build — and asking the builder for "a $30 yearly plan" writes the same
36
+ record the screen does. `access.js` takes a `plan` record from the owner alone
37
+ and checks its price is whole cents and its interval is `month` or `year`. The
38
+ live list starts empty: the app's code writes no plan, so the owner's first view
39
+ is the form for their first plan, and a visitor sees *Memberships open soon*
40
+ until there is one. A `seed.json` may carry example plans for the screenshot;
41
+ they reach the live app only when the owner asks for the examples. A new price
42
+ applies to people who join from then on: Stripe keeps billing each current
43
+ member the price they joined at.
44
+
45
+ A page that sells both — monthly coffee plans and single bags — takes both
46
+ skills: the bags are products on the `stripe` skill's catalog and checkout,
47
+ the plans are this recipe, and each keeps its own records.
48
+
29
49
  ## 1. The setup items: Connect Stripe, and the Customer portal
30
50
 
31
51
  The owner sets up Stripe once. The Setup surface the two items land on — the
@@ -169,12 +189,16 @@ Every membership records the mode it was made in, and every ctx.stripe.fetch cal
169
189
  - `Idempotency-Key` is `<record id>:<attempt>`, so two first presses that both
170
190
  got past the claim (a record that does not exist yet has no revision to
171
191
  claim) mint one session at Stripe; and a second press on an open attempt
172
- reuses its session for the day rather than minting another.
192
+ reuses its session for the day rather than minting another. A press for a
193
+ different plan, or after the owner changed the price, first expires the open
194
+ session at Stripe (`POST /v1/checkout/sessions/<id>/expire`), so the tab
195
+ still showing it cannot start a second subscription; when Stripe answers
196
+ that it was already paid, the route settles it and that is the membership.
173
197
 
174
198
  Amounts are integers in the currency's smallest unit: $5 a month is unit_amount 500, never 5.0.
175
199
 
176
- The price lives in the app's own plan list on the server; the browser sends a
177
- plan name, never an amount. One subscription per person: `/subscribe` refuses
200
+ The price lives on the owner's plan record, which the server reads; the browser
201
+ sends a plan's id, never an amount. One subscription per person: `/subscribe` refuses
178
202
  while the member's subscription is **live at Stripe** — `active`, `trialing`,
179
203
  `past_due`, `unpaid` or `paused`, entitled or not — because a lapsed member
180
204
  whose card Stripe is still retrying must not be sold a second subscription
@@ -321,7 +345,7 @@ export const config = {
321
345
  scheduled: { interval: "30m" },
322
346
  // The routes read the member's own record; access.js binds the database, so the fetch lane needs
323
347
  // this declaration, and every route owes the check it waives: it reads membership-<mode>-<caller> only.
324
- fetch: { unfilteredReads: { dbs: ["club"], why: "the /subscribe, /confirm, /refresh and /portal routes read the signed-in member's own membership record in the app's current mode, membership-<mode>-<their handle>, and nothing else" } },
348
+ fetch: { unfilteredReads: { dbs: ["club"], why: "the /subscribe route reads the plan the member names from the owner's plans; the /subscribe, /confirm, /refresh and /portal routes read the signed-in member's own membership record in the app's current mode, membership-<mode>-<their handle>, and nothing else" } },
325
349
  };
326
350
 
327
351
  const DB = "club";
@@ -329,10 +353,16 @@ const SESSION_TTL_MS = 24 * 60 * 60 * 1000;
329
353
  // The one knob: how long a past_due member stays in while Stripe retries the card. Zero locks
330
354
  // the moment a renewal fails.
331
355
  const GRACE_DAYS = 5;
332
- const PLANS = {
333
- monthly: { title: "Club membership (monthly)", amount: 500, currency: "usd", interval: "month" },
334
- yearly: { title: "Club membership (yearly)", amount: 5000, currency: "usd", interval: "year" },
335
- };
356
+ // The plans are the owner's: `plan` records in this database, written by the owner alone from the
357
+ // app's Plans screen (access.js), each priced in the currency's smallest unit with its interval.
358
+ // The browser names a plan, never an amount.
359
+ async function planFor(ctx, planId) {
360
+ if (typeof planId !== "string" || !planId.startsWith("plan-")) return null;
361
+ const plan = await ctx.db.get(planId, { db: DB });
362
+ if (plan?.type !== "plan" || plan.onSale !== true) return null;
363
+ if (!Number.isInteger(plan.amount) || plan.amount <= 0 || (plan.interval !== "month" && plan.interval !== "year")) return null;
364
+ return plan;
365
+ }
336
366
  // Nothing at Stripe will change these again; everything else is live and re-read.
337
367
  const TERMINAL = new Set(["canceled", "incomplete_expired"]);
338
368
 
@@ -516,7 +546,7 @@ export async function fetch(request, ctx) {
516
546
  const current = await ctx.db.get(id, { db: DB }); // null before the first attempt in this mode
517
547
 
518
548
  if (url.pathname === "/subscribe" && request.method === "POST") {
519
- const { plan, mode: shown } = await request.json();
549
+ const { planId, mode: shown } = await request.json();
520
550
  // The member joins in the mode their page showed them, or not at all: a page that still shows
521
551
  // the other mode refreshes first.
522
552
  if (shown !== mode) return json({ ok: false, reason: "mode-changed", mode }, 409);
@@ -524,14 +554,26 @@ export async function fetch(request, ctx) {
524
554
  // The portal is where a member cancels, so nobody joins before it exists: the KEPT verdict for
525
555
  // this mode, never a Stripe read per press.
526
556
  if ((await ctx.db.get(portalState(mode), { db: DB }))?.saved !== true) return json({ ok: false, reason: "setup-incomplete" }, 503);
527
- const price = PLANS[plan];
528
- if (!price) return json({ ok: false, reason: "unknown-plan" }, 400);
557
+ // The price and interval are the ones on the owner's plan record, read now: off sale, or no
558
+ // such plan, and nobody is subscribed.
559
+ const plan = await planFor(ctx, planId);
560
+ if (!plan) return json({ ok: false, reason: "unknown-plan" }, 400);
529
561
  // A subscription that is live at Stripe — entitled or not — is managed in the portal, never
530
562
  // doubled: a past_due member whose grace ran out still has a subscription Stripe is retrying.
531
563
  if (current?.subscriptionId && !TERMINAL.has(current.status)) return json({ ok: false, reason: "already-member" }, 409);
532
564
  // A second press, a retry, another tab: the open attempt is reused, never repeated.
533
- if (current?.status === "pending" && current.sessionUrl && Date.now() - current.sessionCreatedAt < SESSION_TTL_MS) {
534
- return json({ ok: true, url: current.sessionUrl });
565
+ if (current?.status === "pending" && current.sessionId && Date.now() - current.sessionCreatedAt < SESSION_TTL_MS) {
566
+ if (current.planId === plan._id && current.amount === plan.amount && current.currency === plan.currency && current.interval === plan.interval) {
567
+ return json({ ok: true, url: current.sessionUrl });
568
+ }
569
+ // A different plan, or a price the owner changed since, is a new attempt — but the open session
570
+ // could still complete in its own tab, and the record is about to forget it. Close it at Stripe
571
+ // first; Stripe refuses to expire a session already paid, and then that one is the membership.
572
+ const closed = await stripe(ctx, current.mode, "POST", `/checkout/sessions/${current.sessionId}/expire`);
573
+ if (!closed.ok) {
574
+ const settled = await settlePending(ctx, current, mode);
575
+ return json({ ok: false, reason: settled.subscriptionId ? "already-member" : "retry" }, 409);
576
+ }
535
577
  }
536
578
 
537
579
  const attempt = (current?.attempt ?? 0) + 1;
@@ -539,9 +581,11 @@ export async function fetch(request, ctx) {
539
581
  _id: id,
540
582
  type: "membership",
541
583
  memberHandle: me,
542
- plan,
543
- amount: price.amount,
544
- currency: price.currency,
584
+ planId: plan._id,
585
+ plan: plan.title,
586
+ amount: plan.amount, // the price this member joins at, whatever the plan says later
587
+ currency: plan.currency,
588
+ interval: plan.interval,
545
589
  mode, // the account this membership is made in; every later call for it passes the same mode
546
590
  status: "pending",
547
591
  entitled: false,
@@ -566,10 +610,10 @@ export async function fetch(request, ctx) {
566
610
  const form = new URLSearchParams({
567
611
  mode: "subscription",
568
612
  "line_items[0][quantity]": "1",
569
- "line_items[0][price_data][currency]": price.currency,
570
- "line_items[0][price_data][unit_amount]": String(price.amount),
571
- "line_items[0][price_data][recurring][interval]": price.interval,
572
- "line_items[0][price_data][product_data][name]": price.title,
613
+ "line_items[0][price_data][currency]": membership.currency,
614
+ "line_items[0][price_data][unit_amount]": String(membership.amount),
615
+ "line_items[0][price_data][recurring][interval]": membership.interval,
616
+ "line_items[0][price_data][product_data][name]": membership.plan,
573
617
  client_reference_id: id,
574
618
  "metadata[attempt]": String(attempt),
575
619
  success_url: appUrl(ctx, "#subscribed"),
@@ -658,6 +702,18 @@ export function club(doc, oldDoc, user, ctx) {
658
702
  return { channels: [mine, "memberships"], grant: { users: { [doc.memberHandle]: granted }, roles: { owner: ["memberships", "members"] } } };
659
703
  }
660
704
 
705
+ // A plan: the owner names it and sets its price and interval from the app's own screen, and anyone
706
+ // reads it. backend.js subscribes members at the price on this record, so the owner alone writes one.
707
+ if (doc.type === "plan") {
708
+ ctx.requireRole("owner");
709
+ const named = doc._id?.startsWith("plan-") && typeof doc.title === "string" && doc.title.trim() !== "";
710
+ const priced = Number.isInteger(doc.amount) && doc.amount > 0 && /^[a-z]{3}$/.test(doc.currency ?? "");
711
+ if (!named || !priced || (doc.interval !== "month" && doc.interval !== "year") || typeof doc.onSale !== "boolean") {
712
+ throw { forbidden: "a plan has a name, a whole-cent price, a currency and a month or year interval" };
713
+ }
714
+ return { channels: ["public"], grant: { public: ["public"] } };
715
+ }
716
+
661
717
  // A post: the owner writes it; members read it on the channel their membership record grants.
662
718
  if (doc.type === "post") {
663
719
  if (oldDoc && doc.authorHandle !== oldDoc.authorHandle) throw { forbidden: "a post keeps its author" };
@@ -683,7 +739,18 @@ export function club(doc, oldDoc, user, ctx) {
683
739
  import React, { useEffect, useRef, useState } from "react";
684
740
  import { useFireproof } from "use-fireproof";
685
741
  import { apiFetch, useViewer } from "use-vibes";
686
- import { Badge, Button, Heading, Row, Stack, Text } from "@vibes.diy/pouf";
742
+ import { Badge, Button, Field, Heading, Input, Row, Segmented, Stack, Text } from "@vibes.diy/ui";
743
+ import { Checkbox } from "@vibes.diy/ui/interactive";
744
+
745
+ // Amounts are in the currency's smallest unit, the one Stripe charges in: cents for usd, whole yen
746
+ // for jpy. Show, edit and read them through that unit, never a fixed 100.
747
+ const digits = (currency) => new Intl.NumberFormat("en", { style: "currency", currency }).resolvedOptions().maximumFractionDigits;
748
+ const money = (amount, currency) => new Intl.NumberFormat(undefined, { style: "currency", currency }).format(amount / 10 ** digits(currency));
749
+ const toMinor = (text, currency) => Math.round(Number(text) * 10 ** digits(currency));
750
+ const shown = (amount, currency) => (amount / 10 ** digits(currency)).toFixed(digits(currency));
751
+ const CURRENCY = "usd"; // the currency new plans are priced in
752
+ const INTERVALS = [{ value: "month", label: "Monthly" }, { value: "year", label: "Yearly" }];
753
+ const per = (plan) => `${money(plan.amount, plan.currency)} a ${plan.interval}`;
687
754
 
688
755
  // The setup verdict, read on mount and again whenever the app comes back into view: the owner
689
756
  // connects Stripe or saves the portal in another tab and returns, and the Join buttons unlock
@@ -774,13 +841,79 @@ function SetupScreen({ setup }) {
774
841
  );
775
842
  }
776
843
 
844
+ // One plan on the owner's list: its price edits in place, and On sale offers it to new members or
845
+ // stops. Members already in keep the price they joined at; Stripe bills them that.
846
+ function PlanRow({ plan, save }) {
847
+ const [price, setPrice] = useState(shown(plan.amount, plan.currency));
848
+ useEffect(() => setPrice(shown(plan.amount, plan.currency)), [plan.amount]);
849
+ const commit = () => {
850
+ const amount = toMinor(price, plan.currency);
851
+ if (Number.isInteger(amount) && amount > 0 && amount !== plan.amount) save({ ...plan, amount }, () => setPrice(shown(plan.amount, plan.currency)));
852
+ else setPrice(shown(plan.amount, plan.currency));
853
+ };
854
+ return (
855
+ <Row gap={2}>
856
+ <Text>{plan.title} · {plan.interval === "year" ? "yearly" : "monthly"}</Text>
857
+ <Field label="Price">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={price} onChange={setPrice} onBlur={commit} onKeyDown={(e) => e.key === "Enter" && commit()} inputMode="decimal" />}</Field>
858
+ <Checkbox label="On sale" checked={plan.onSale} onChange={(on) => save({ ...plan, onSale: on === true })} />
859
+ </Row>
860
+ );
861
+ }
862
+
863
+ // The owner's plans: each save is a `plan` record that access.js takes from the owner alone, and its
864
+ // price and interval are what /subscribe charges. Empty, the form for the first plan leads; from
865
+ // then on the list leads with a compact add on top.
866
+ function Plans({ plans, onAdd }) {
867
+ const { database } = useFireproof("club");
868
+ const [title, setTitle] = useState("");
869
+ const [price, setPrice] = useState("");
870
+ const [renews, setRenews] = useState("month");
871
+ const [error, setError] = useState(null);
872
+ // A put lands on this device at once; the server's verdict arrives on its receipt. A refused save
873
+ // converges back to what the server holds, and the owner gets their draft and the reason back.
874
+ const save = async (plan, undo) => {
875
+ setError(null);
876
+ const { synced } = await database.put(plan);
877
+ synced.on((s) => {
878
+ if (s.status !== "refused") return;
879
+ undo?.();
880
+ setError(s.message ?? "That did not save: a plan needs a name and a price like 5.00.");
881
+ });
882
+ };
883
+ const add = () => {
884
+ const amount = toMinor(price, CURRENCY);
885
+ if (!title.trim() || !Number.isInteger(amount) || amount <= 0) return setError("Give it a name and a price like 5.00.");
886
+ const plan = { _id: "plan-" + crypto.randomUUID(), type: "plan", title: title.trim(), amount, currency: CURRENCY, interval: renews, onSale: true, createdAt: Date.now() };
887
+ // The form empties as the owner presses Add; the draft comes back only if the write is refused.
888
+ // The owner stays here: the first entry would otherwise flip the default screen to the shop.
889
+ onAdd?.();
890
+ setTitle("");
891
+ setPrice("");
892
+ save(plan, () => { setTitle(plan.title); setPrice(shown(plan.amount, plan.currency)); });
893
+ };
894
+ return (
895
+ <Stack>
896
+ <Heading>{plans.length === 0 ? "Add your first plan" : "Plans"}</Heading>
897
+ <Row gap={2}>
898
+ <Field label="Name">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={title} onChange={setTitle} placeholder="Club membership" />}</Field>
899
+ <Field label="Price">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={price} onChange={setPrice} placeholder="5.00" inputMode="decimal" />}</Field>
900
+ <Segmented label="Renews" value={renews} onChange={setRenews} options={INTERVALS} />
901
+ <Button onClick={add}>Add</Button>
902
+ </Row>
903
+ {error && <Text>{error}</Text>}
904
+ {plans.map((p) => <PlanRow key={p._id} plan={p} save={save} />)}
905
+ </Stack>
906
+ );
907
+ }
908
+
777
909
  export default function App() {
778
910
  const { viewer, requestLogin } = useViewer();
779
911
  const { useLiveQuery } = useFireproof("club"); // memberships AND posts: one database, one grant set
780
912
  const { docs: memberships } = useLiveQuery("type", { key: "membership" });
781
913
  const { docs: posts } = useLiveQuery("type", { key: "post" });
914
+ const { docs: plans } = useLiveQuery("type", { key: "plan" });
782
915
  const setup = useSetup();
783
- const [screen, setScreen] = useState("club");
916
+ const [picked, setPicked] = useState(null);
784
917
  const [busy, setBusy] = useState(false);
785
918
  const [error, setError] = useState(null);
786
919
 
@@ -816,6 +949,7 @@ export default function App() {
816
949
  data.reason === "stripe" ? data.message
817
950
  : data.reason === "already-member" ? "You already have a membership — manage it below."
818
951
  : data.reason === "mode-changed" ? `Memberships here just moved to ${data.mode} mode. Refresh the page and press Join again.`
952
+ : data.reason === "unknown-plan" ? "That plan is no longer offered."
819
953
  : "Memberships are not open yet."
820
954
  );
821
955
  return;
@@ -831,36 +965,43 @@ export default function App() {
831
965
  const mine = viewer && setup ? memberships.find((m) => m._id === `membership-${setup.mode}-${viewer.userHandle}`) : undefined;
832
966
  const entitled = mine?.entitled === true;
833
967
  const ends = mine?.currentPeriodEnd ? new Date(mine.currentPeriodEnd).toLocaleDateString() : null;
968
+ const offered = plans.filter((p) => p.onSale);
969
+ const pitch = offered.length === 0 ? "Memberships open soon." : `Members read every post. Join for ${offered.map(per).join(" or ")}, cancel any time.`;
970
+ // The owner with no plans yet starts on Plans, the form for their first plan in front.
971
+ const screen = picked ?? (setup?.owner && plans.length === 0 ? "plans" : "club");
834
972
 
835
973
  return (
836
974
  <Stack>
837
975
  <Row gap={2}>
838
- <Button variant="quiet" onClick={() => setScreen("club")}>The club</Button>
839
- {/* The Setup entry: the owner's alone, highlighted while an item is still to do, quiet once done. */}
976
+ <Button variant="quiet" onClick={() => setPicked("club")}>The club</Button>
977
+ {/* The owner's own screens: the plans, and Setup highlighted while an item is still to do. */}
978
+ {setup?.owner && <Button variant="quiet" onClick={() => setPicked("plans")}>Plans</Button>}
840
979
  {setup?.owner && (
841
- <Button variant={ready ? "quiet" : "solid"} onClick={() => setScreen("setup")}>
980
+ <Button variant={ready ? "quiet" : "solid"} onClick={() => setPicked("setup")}>
842
981
  Setup{ready ? "" : " · to do"}
843
982
  </Button>
844
983
  )}
845
984
  </Row>
846
985
  {screen === "setup" && setup?.owner ? (
847
986
  <SetupScreen setup={setup} />
987
+ ) : screen === "plans" && setup?.owner ? (
988
+ <Plans plans={plans} onAdd={() => setPicked("plans")} />
848
989
  ) : (
849
990
  <Stack>
850
991
  <Heading>The club</Heading>
851
992
  {!viewer ? (
852
993
  <Stack>
853
- <Text>Members read every post. Join for $5 a month, cancel any time.</Text>
854
- <Button onClick={() => requestLogin()}>Sign in to join</Button>
994
+ <Text>{pitch}</Text>
995
+ {offered.length > 0 && <Button onClick={() => requestLogin()}>Sign in to join</Button>}
855
996
  </Stack>
856
997
  ) : entitled ? (
857
998
  <Badge tone="up">{mine.cancelAtPeriodEnd ? `Member until ${ends}` : mine.status === "past_due" ? "Payment due — please update your card" : "Member"}</Badge>
858
999
  ) : (
859
1000
  <Stack>
860
- <Text>Members read every post. Join for $5 a month, cancel any time.</Text>
1001
+ <Text>{pitch}</Text>
861
1002
  {mine?.subscriptionId && mine.status !== "canceled" ? (
862
1003
  <Text>Your last payment did not go through. Update your card below to keep reading.</Text>
863
- ) : ready ? (
1004
+ ) : ready && offered.length > 0 ? (
864
1005
  <Stack>
865
1006
  {/* Test mode is a rehearsal: the owner gets the test card, members learn it ends at go-live. */}
866
1007
  {setup.mode === "test" && (
@@ -869,13 +1010,16 @@ export default function App() {
869
1010
  <Text muted>{setup.owner ? "Join with the test card 4242 4242 4242 4242 and any future date." : "This is a rehearsal: test memberships end when the app goes live."}</Text>
870
1011
  </Row>
871
1012
  )}
872
- <Button onClick={() => openStripe("/subscribe", { plan: "monthly", mode: setup.mode })} disabled={busy} loading={busy}>
873
- Join — Stripe opens in a new tab
874
- </Button>
1013
+ {/* The page names the plan, never its price. */}
1014
+ {offered.map((p) => (
1015
+ <Button key={p._id} onClick={() => openStripe("/subscribe", { planId: p._id, mode: setup.mode })} disabled={busy} loading={busy}>
1016
+ Join {p.title} — {per(p)}, Stripe opens in a new tab
1017
+ </Button>
1018
+ ))}
875
1019
  </Stack>
876
- ) : (
1020
+ ) : offered.length > 0 ? (
877
1021
  <Text muted>Memberships are not open yet.</Text>
878
- )}
1022
+ ) : null}
879
1023
  </Stack>
880
1024
  )}
881
1025
  {/* The portal is reachable whenever Stripe knows this member, entitled or not: a lapsed
@@ -894,7 +1038,7 @@ export default function App() {
894
1038
  {setup?.owner && (
895
1039
  <ul>
896
1040
  {memberships.map((m) => (
897
- <li key={m._id}>@{m.memberHandle} · {m.mode} · {m.plan} · {m.status}{m.entitled ? " · entitled" : ""}{m.currentPeriodEnd ? ` · until ${new Date(m.currentPeriodEnd).toLocaleDateString()}` : ""}</li>
1041
+ <li key={m._id}>@{m.memberHandle} · {m.mode} · {m.plan} · {m.interval ? `${money(m.amount, m.currency)} a ${m.interval} · ` : ""}{m.status}{m.entitled ? " · entitled" : ""}{m.currentPeriodEnd ? ` · until ${new Date(m.currentPeriodEnd).toLocaleDateString()}` : ""}</li>
898
1042
  ))}
899
1043
  </ul>
900
1044
  )}