create-usebecky 0.0.0-stage → 0.2.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 (157) hide show
  1. package/README.md +80 -2
  2. package/dist/create.js +842 -0
  3. package/dist/extension-skill/usebecky-extension/SKILL.md +181 -0
  4. package/dist/extension-skill/usebecky-extension/references/accounts.md +125 -0
  5. package/dist/extension-skill/usebecky-extension/references/dev-server.md +102 -0
  6. package/dist/extension-skill/usebecky-extension/references/manifest.md +104 -0
  7. package/dist/extension-skill/usebecky-extension/references/oauth-and-tokens.md +179 -0
  8. package/dist/extension-skill/usebecky-extension/references/partner-api.md +87 -0
  9. package/dist/extension-skill/usebecky-extension/references/submit-and-pricing.md +31 -0
  10. package/dist/extension-skill/usebecky-extension/references/ui.md +172 -0
  11. package/dist/extension-skill/usebecky-extension/references/webhooks.md +97 -0
  12. package/dist/index.js +10 -0
  13. package/dist/keys.js +72 -0
  14. package/dist/platform.js +104 -0
  15. package/dist/pm.js +69 -0
  16. package/dist/prompts.js +242 -0
  17. package/dist/scaffold.js +108 -0
  18. package/dist/setup.js +130 -0
  19. package/dist/shared/ai.js +203 -0
  20. package/dist/shared/extension-skill.js +107 -0
  21. package/dist/shared/framework.js +460 -0
  22. package/dist/shared/hosted.js +8 -0
  23. package/dist/shared/ui.js +141 -0
  24. package/dist/skill/usebecky/SKILL.md +339 -0
  25. package/dist/skill/usebecky/references/access-rules.md +307 -0
  26. package/dist/skill/usebecky/references/addons.md +68 -0
  27. package/dist/skill/usebecky/references/analytics.md +166 -0
  28. package/dist/skill/usebecky/references/android.md +434 -0
  29. package/dist/skill/usebecky/references/auth.md +379 -0
  30. package/dist/skill/usebecky/references/cache.md +51 -0
  31. package/dist/skill/usebecky/references/components.md +127 -0
  32. package/dist/skill/usebecky/references/emails.md +105 -0
  33. package/dist/skill/usebecky/references/expo.md +147 -0
  34. package/dist/skill/usebecky/references/functions.md +99 -0
  35. package/dist/skill/usebecky/references/hosting.md +119 -0
  36. package/dist/skill/usebecky/references/http-api.md +233 -0
  37. package/dist/skill/usebecky/references/ios.md +355 -0
  38. package/dist/skill/usebecky/references/payments.md +493 -0
  39. package/dist/skill/usebecky/references/realtime.md +143 -0
  40. package/dist/skill/usebecky/references/scheduled-jobs.md +82 -0
  41. package/dist/skill/usebecky/references/sdk.md +838 -0
  42. package/dist/skill/usebecky/references/storage.md +210 -0
  43. package/dist/skill/usebecky/references/templates.md +191 -0
  44. package/dist/skill/usebecky/references/wordpress.md +87 -0
  45. package/dist/templates.js +74 -0
  46. package/package.json +37 -4
  47. package/templates/expo/App.tsx +48 -0
  48. package/templates/expo/README.md +59 -0
  49. package/templates/expo/_env.example +4 -0
  50. package/templates/expo/_gitignore +12 -0
  51. package/templates/expo/app.json +25 -0
  52. package/templates/expo/assets/icon.png +0 -0
  53. package/templates/expo/brand.ts +7 -0
  54. package/templates/expo/components/Avatar.tsx +75 -0
  55. package/templates/expo/components/ui.tsx +57 -0
  56. package/templates/expo/index.ts +4 -0
  57. package/templates/expo/lib/theme.ts +43 -0
  58. package/templates/expo/lib/usebecky.ts +15 -0
  59. package/templates/expo/package.json +29 -0
  60. package/templates/expo/screens/Home.tsx +187 -0
  61. package/templates/expo/screens/SignIn.tsx +112 -0
  62. package/templates/expo/tsconfig.json +6 -0
  63. package/templates/expo/usebecky.template.json +36 -0
  64. package/templates/extension/README.md +128 -0
  65. package/templates/extension/_env.example +21 -0
  66. package/templates/extension/_gitignore +11 -0
  67. package/templates/extension/logo.svg +1 -0
  68. package/templates/extension/package.json +25 -0
  69. package/templates/extension/src/accounts.ts +90 -0
  70. package/templates/extension/src/app.ts +178 -0
  71. package/templates/extension/src/pages.ts +108 -0
  72. package/templates/extension/src/replay-guard.ts +17 -0
  73. package/templates/extension/src/server.ts +57 -0
  74. package/templates/extension/src/settings.ts +69 -0
  75. package/templates/extension/src/ui.ts +70 -0
  76. package/templates/extension/test/app.test.ts +222 -0
  77. package/templates/extension/tsconfig.json +16 -0
  78. package/templates/extension/usebecky-extension.json +36 -0
  79. package/templates/extension/usebecky.template.json +22 -0
  80. package/templates/landing/README.md +43 -0
  81. package/templates/landing/_env.example +4 -0
  82. package/templates/landing/_gitignore +9 -0
  83. package/templates/landing/index.html +16 -0
  84. package/templates/landing/package.json +28 -0
  85. package/templates/landing/public/icon.svg +1 -0
  86. package/templates/landing/src/App.tsx +97 -0
  87. package/templates/landing/src/components/Contact.tsx +43 -0
  88. package/templates/landing/src/components/Counter.tsx +34 -0
  89. package/templates/landing/src/components/Feedback.tsx +36 -0
  90. package/templates/landing/src/components/Logo.tsx +11 -0
  91. package/templates/landing/src/components/Receipt.tsx +128 -0
  92. package/templates/landing/src/components/Setup.tsx +20 -0
  93. package/templates/landing/src/components/fields.tsx +63 -0
  94. package/templates/landing/src/content.ts +22 -0
  95. package/templates/landing/src/index.css +119 -0
  96. package/templates/landing/src/lib/usebecky.ts +11 -0
  97. package/templates/landing/src/lib/waitlist.ts +46 -0
  98. package/templates/landing/src/main.tsx +12 -0
  99. package/templates/landing/src/vite-env.d.ts +6 -0
  100. package/templates/landing/tsconfig.json +19 -0
  101. package/templates/landing/usebecky.template.json +20 -0
  102. package/templates/landing/vite.config.ts +10 -0
  103. package/templates/notes/README.md +68 -0
  104. package/templates/notes/_env.example +4 -0
  105. package/templates/notes/_gitignore +9 -0
  106. package/templates/notes/index.html +15 -0
  107. package/templates/notes/package.json +28 -0
  108. package/templates/notes/public/icon.svg +1 -0
  109. package/templates/notes/src/App.tsx +35 -0
  110. package/templates/notes/src/brand.ts +7 -0
  111. package/templates/notes/src/components/Composer.tsx +113 -0
  112. package/templates/notes/src/components/NoteEntry.tsx +151 -0
  113. package/templates/notes/src/components/Notes.tsx +163 -0
  114. package/templates/notes/src/components/Setup.tsx +44 -0
  115. package/templates/notes/src/components/SignIn.tsx +112 -0
  116. package/templates/notes/src/components/icons.tsx +54 -0
  117. package/templates/notes/src/index.css +105 -0
  118. package/templates/notes/src/lib/notes.ts +68 -0
  119. package/templates/notes/src/lib/usebecky.ts +9 -0
  120. package/templates/notes/src/main.tsx +22 -0
  121. package/templates/notes/src/vite-env.d.ts +6 -0
  122. package/templates/notes/tsconfig.json +19 -0
  123. package/templates/notes/usebecky.template.json +34 -0
  124. package/templates/notes/vite.config.ts +10 -0
  125. package/templates/saas/README.md +69 -0
  126. package/templates/saas/_env.example +10 -0
  127. package/templates/saas/_gitignore +11 -0
  128. package/templates/saas/app/(app)/account/ManageBilling.tsx +26 -0
  129. package/templates/saas/app/(app)/account/page.tsx +71 -0
  130. package/templates/saas/app/(app)/dashboard/Projects.tsx +227 -0
  131. package/templates/saas/app/(app)/dashboard/page.tsx +21 -0
  132. package/templates/saas/app/(app)/layout.tsx +29 -0
  133. package/templates/saas/app/(app)/premium/page.tsx +62 -0
  134. package/templates/saas/app/auth/callback/page.tsx +33 -0
  135. package/templates/saas/app/globals.css +143 -0
  136. package/templates/saas/app/icon.svg +1 -0
  137. package/templates/saas/app/layout.tsx +20 -0
  138. package/templates/saas/app/page.tsx +87 -0
  139. package/templates/saas/app/pricing/Plans.tsx +133 -0
  140. package/templates/saas/app/pricing/TestCardHint.tsx +18 -0
  141. package/templates/saas/app/pricing/page.tsx +21 -0
  142. package/templates/saas/app/setup/page.tsx +34 -0
  143. package/templates/saas/app/sign-in/SignInForm.tsx +195 -0
  144. package/templates/saas/app/sign-in/page.tsx +21 -0
  145. package/templates/saas/brand.ts +10 -0
  146. package/templates/saas/components/AppNav.tsx +45 -0
  147. package/templates/saas/components/Logo.tsx +22 -0
  148. package/templates/saas/components/SiteHeader.tsx +50 -0
  149. package/templates/saas/components/Status.tsx +15 -0
  150. package/templates/saas/lib/session.ts +26 -0
  151. package/templates/saas/lib/usebecky.ts +11 -0
  152. package/templates/saas/next-env.d.ts +5 -0
  153. package/templates/saas/next.config.ts +5 -0
  154. package/templates/saas/package.json +26 -0
  155. package/templates/saas/postcss.config.mjs +3 -0
  156. package/templates/saas/tsconfig.json +21 -0
  157. package/templates/saas/usebecky.template.json +31 -0
@@ -0,0 +1,43 @@
1
+ # Tidy: a launch page with a waitlist
2
+
3
+ A product page built with React, Vite and usebecky. Visitors join a waitlist, watch the counter go up, send feedback and contact you. You see everything in your dashboard. No accounts needed.
4
+
5
+ ## What's inside
6
+
7
+ - **Waitlist** with a live "people waiting" counter that rolls into place (`src/components/Receipt.tsx`). Each person gets a share link; friends who join through it are saved as their referrals.
8
+ - **Feedback form**, saved in the `feedback` table (`src/components/Feedback.tsx`).
9
+ - **Contact form**, sent to the `contact` form in **Dashboard → Forms**. You get an email for every message (`src/components/Contact.tsx`).
10
+ - **Page-view analytics**: every visit is counted in **Dashboard → Analytics** once you turn it on there (one click; nothing is recorded while it's off), plus events for sign-ups and messages. No cookies (`src/lib/usebecky.ts`).
11
+
12
+ Visitors can add to the waitlist and feedback tables, but nobody can read them through the API. Only you can, in the dashboard.
13
+
14
+ ## Run it
15
+
16
+ ```bash
17
+ npm run dev
18
+ ```
19
+
20
+ Open http://localhost:3002, join the waitlist and send a message. Then look in the dashboard: **Database → Tables → waitlist**, **Forms → Contact form** and **Analytics**.
21
+
22
+ ## Make it yours
23
+
24
+ - **Name and every sentence on the page**: `src/content.ts`. The browser tab title and description are in `index.html`.
25
+ - **Colour**: change `--brand` at the top of `src/index.css`. The top of the page is filled with it, so pick a colour dark enough for white text.
26
+ - **Fonts**: Anybody for headlines and Figtree for text, imported in `src/main.tsx`.
27
+
28
+ ## Connect it later
29
+
30
+ 1. In this folder, run `npx usebecky init` and pick (or create) a project with the **Waitlist & landing page** ready-made setup. It has the `waitlist` and `feedback` tables and the `waitlist_count()` function.
31
+ 2. In the dashboard, open **Forms**, click **New form**, pick **Contact form**, and keep the key `contact`.
32
+ 3. Restart `npm run dev`.
33
+
34
+ ## Learn more
35
+
36
+ The docs are in your dashboard under **Docs**.
37
+
38
+ - **Ready-made setups**: what the Waitlist setup creates (`reference/templates`).
39
+ - **Contact forms**: notifications, spam protection and the inbox (`guides/forms`).
40
+ - **Analytics**: page views and your own events (`guides/analytics`).
41
+ - **Starter apps**: all starters and how to change them (`getting-started/starters`).
42
+
43
+ Your AI assistant knows usebecky too: see `.claude/skills/usebecky` and `AGENTS.md`.
@@ -0,0 +1,4 @@
1
+ # Copy this file to .env.local and paste your values from Dashboard → Settings → API keys.
2
+ # (create-usebecky and `npx usebecky init` write .env.local for you.)
3
+ VITE_USEBECKY_URL=https://api.usebecky.com
4
+ VITE_USEBECKY_PUBLISHABLE_KEY=ub_pk_...
@@ -0,0 +1,9 @@
1
+ node_modules
2
+ dist
3
+ *.log
4
+ .DS_Store
5
+
6
+ # Your keys. Never commit these.
7
+ .env
8
+ .env.local
9
+ .env.*.local
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta name="description" content="Tidy is a shared grocery list that sorts itself by aisle. Join the waitlist." />
7
+ <meta name="theme-color" content="#2340d8" media="(prefers-color-scheme: light)" />
8
+ <meta name="theme-color" content="#2340d8" media="(prefers-color-scheme: dark)" />
9
+ <link rel="icon" href="/icon.svg" type="image/svg+xml" />
10
+ <title>Tidy: join the waitlist</title>
11
+ </head>
12
+ <body>
13
+ <div id="root"></div>
14
+ <script type="module" src="/src/main.tsx"></script>
15
+ </body>
16
+ </html>
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "tidy",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc --noEmit && vite build",
9
+ "preview": "vite preview",
10
+ "typecheck": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "@fontsource-variable/anybody": "5.3.0",
14
+ "@fontsource-variable/figtree": "5.3.0",
15
+ "react": "19.3.1",
16
+ "react-dom": "19.3.1",
17
+ "usebecky": "^0.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "@tailwindcss/vite": "4.3.3",
21
+ "@types/react": "19.3.0",
22
+ "@types/react-dom": "19.3.0",
23
+ "@vitejs/plugin-react": "6.1.2",
24
+ "tailwindcss": "4.3.3",
25
+ "typescript": "5.9.3",
26
+ "vite": "8.3.5"
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="8" fill="#2340d8"/><path d="M10 7h12v18l-2-1.5-2 1.5-2-1.5-2 1.5-2-1.5-2 1.5V7Z" fill="#fff"/><path d="M13 12h6M13 15.5h6M13 19h3.5" stroke="#2340d8" stroke-width="1.8" stroke-linecap="round"/></svg>
@@ -0,0 +1,97 @@
1
+ import { Contact } from './components/Contact'
2
+ import { Feedback } from './components/Feedback'
3
+ import { Logo } from './components/Logo'
4
+ import { Receipt } from './components/Receipt'
5
+ import { Setup } from './components/Setup'
6
+ import { site } from './content'
7
+
8
+ const connected = Boolean(import.meta.env.VITE_USEBECKY_PUBLISHABLE_KEY)
9
+
10
+ export function App() {
11
+ return (
12
+ <>
13
+ <header className="relative overflow-hidden bg-brand text-on-brand">
14
+ <nav className="mx-auto flex max-w-6xl items-center justify-between px-5 py-5 sm:px-8" aria-label="Main">
15
+ <a href="#" className="flex items-center gap-2.5 text-lg font-bold tracking-tight">
16
+ <Logo />
17
+ {site.name}
18
+ </a>
19
+ <div className="flex items-center gap-1 text-sm font-medium sm:gap-2">
20
+ <a href="#feedback" className="hidden rounded-full px-3 py-2 text-on-brand-muted hover:text-on-brand sm:block">
21
+ Feedback
22
+ </a>
23
+ <a href="#contact" className="rounded-full px-3 py-2 text-on-brand-muted hover:text-on-brand">
24
+ Contact
25
+ </a>
26
+ </div>
27
+ </nav>
28
+
29
+ <div className="mx-auto max-w-6xl px-5 pt-8 pb-20 sm:px-8 lg:pt-12 lg:pb-24">
30
+ <h1 className="display max-w-[17ch] text-[clamp(2.75rem,7vw,6rem)] text-balance">{site.headline}</h1>
31
+ <div className="mt-10 grid items-start gap-12 lg:mt-12 lg:grid-cols-[1fr_24rem] lg:gap-20">
32
+ <div className="lg:pt-4">
33
+ <p className="max-w-xl text-lg leading-relaxed text-on-brand-muted sm:text-xl">{site.intro}</p>
34
+ <p className="mt-8 inline-flex items-center gap-2 rounded-full bg-white/12 px-4 py-2 text-sm font-medium ring-1 ring-white/20">
35
+ <span className="size-2 rounded-full bg-[#7cf0b1]" aria-hidden="true" />
36
+ {site.launch}
37
+ </p>
38
+ </div>
39
+ <div id="join" className="w-full max-w-sm lg:-mt-6">
40
+ {connected ? <Receipt /> : <Setup />}
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </header>
45
+
46
+ <main>
47
+ <section aria-labelledby="features-title" className="mx-auto max-w-6xl px-5 py-20 sm:px-8 sm:py-28">
48
+ <h2 id="features-title" className="sr-only">
49
+ What {site.name} does
50
+ </h2>
51
+ <ul className="grid gap-x-12 gap-y-12 md:grid-cols-3">
52
+ {site.features.map((f) => (
53
+ <li key={f.title} className="border-t-2 border-ink pt-6">
54
+ <h3 className="display text-[1.5rem] leading-[1.05] tracking-[-0.02em] [font-stretch:112%]">{f.title}</h3>
55
+ <p className="mt-4 leading-relaxed text-muted">{f.text}</p>
56
+ </li>
57
+ ))}
58
+ </ul>
59
+ </section>
60
+
61
+ <section id="feedback" aria-labelledby="feedback-title" className="border-y border-line bg-surface">
62
+ <div className="mx-auto grid max-w-6xl gap-10 px-5 py-20 sm:px-8 sm:py-24 lg:grid-cols-[1fr_1.2fr] lg:gap-20">
63
+ <div>
64
+ <h2 id="feedback-title" className="display text-[clamp(2rem,3.6vw,2.9rem)] text-balance [font-stretch:110%]">
65
+ {site.feedback.title}
66
+ </h2>
67
+ <p className="mt-5 max-w-md leading-relaxed text-muted">{site.feedback.text}</p>
68
+ </div>
69
+ {connected && <Feedback />}
70
+ </div>
71
+ </section>
72
+
73
+ <section id="contact" aria-labelledby="contact-title" className="mx-auto grid max-w-6xl gap-10 px-5 py-20 sm:px-8 sm:py-24 lg:grid-cols-[1fr_1.2fr] lg:gap-20">
74
+ <div>
75
+ <h2 id="contact-title" className="display text-[clamp(2rem,3.6vw,2.9rem)] text-balance [font-stretch:110%]">
76
+ {site.contact.title}
77
+ </h2>
78
+ <p className="mt-5 max-w-md leading-relaxed text-muted">{site.contact.text}</p>
79
+ </div>
80
+ {connected && <Contact />}
81
+ </section>
82
+ </main>
83
+
84
+ <footer className="border-t border-line">
85
+ <div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-4 px-5 py-8 text-sm text-muted sm:px-8">
86
+ <span className="flex items-center gap-2 font-semibold text-ink">
87
+ <Logo small />
88
+ {site.name}
89
+ </span>
90
+ <span>
91
+ © {new Date().getFullYear()} {site.name}. Built with usebecky.
92
+ </span>
93
+ </div>
94
+ </footer>
95
+ </>
96
+ )
97
+ }
@@ -0,0 +1,43 @@
1
+ // The contact form posts to the "contact" form in Dashboard → Forms. You get an email for every
2
+ // message, and they all wait in the Forms inbox. (create-usebecky made the form for you.)
3
+ import { useState, type FormEvent } from 'react'
4
+ import { baas } from '../lib/usebecky'
5
+ import { Area, ErrorText, Field, Sent, Submit } from './fields'
6
+
7
+ export function Contact() {
8
+ const [busy, setBusy] = useState(false)
9
+ const [error, setError] = useState('')
10
+ const [sent, setSent] = useState<string | null>(null)
11
+
12
+ async function send(event: FormEvent<HTMLFormElement>) {
13
+ event.preventDefault()
14
+ const form = event.currentTarget
15
+ setBusy(true)
16
+ setError('')
17
+ // Sends every field of the form, including the hidden "_gotcha" spam trap.
18
+ const { data, error } = await baas.forms.submit('contact', form)
19
+ setBusy(false)
20
+ if (error) {
21
+ return setError(error.code === 'form_not_found' ? 'There is no "contact" form in this project yet. Create one in Dashboard → Forms with the key "contact".' : error.message)
22
+ }
23
+ baas.analytics.track('contact_sent')
24
+ form.reset()
25
+ setSent(data.message || 'Thanks! We’ll get back to you soon.')
26
+ }
27
+
28
+ if (sent) return <Sent title="Message sent" onReset={() => setSent(null)}>{sent}</Sent>
29
+
30
+ return (
31
+ <form onSubmit={send} className="space-y-5">
32
+ <div className="grid gap-5 sm:grid-cols-2">
33
+ <Field id="contact-name" name="name" label="Name" required autoComplete="name" />
34
+ <Field id="contact-email" name="email" label="Email" type="email" required autoComplete="email" />
35
+ </div>
36
+ <Area id="contact-message" name="message" label="Message" required maxLength={5000} />
37
+ {/* Spam trap: people never see or fill this field, bots do. */}
38
+ <input type="text" name="_gotcha" tabIndex={-1} autoComplete="off" aria-hidden="true" className="hidden" />
39
+ <ErrorText>{error}</ErrorText>
40
+ <Submit busy={busy}>Send message</Submit>
41
+ </form>
42
+ )
43
+ }
@@ -0,0 +1,34 @@
1
+ // A number whose digits roll into place, like a deli-counter display.
2
+ import { useEffect, useState } from 'react'
3
+
4
+ export function Counter({ value }: { value: number | null }) {
5
+ // Start from zeros, then roll to the real number on the next frame.
6
+ const [shown, setShown] = useState<number | null>(null)
7
+ useEffect(() => {
8
+ if (value === null) return
9
+ const id = requestAnimationFrame(() => setShown(value))
10
+ return () => cancelAnimationFrame(id)
11
+ }, [value])
12
+
13
+ const text = (value ?? 0).toLocaleString()
14
+ const target = (shown ?? 0).toLocaleString().padStart(text.length, '0')
15
+ return (
16
+ <span aria-hidden="true" className="tabular-nums">
17
+ {text.split('').map((ch, i) =>
18
+ /\d/.test(ch) ? (
19
+ <span key={text.length - i} className="digit">
20
+ <span style={{ transform: `translateY(-${Number(/\d/.test(target[i]) ? target[i] : 0)}em)` }}>
21
+ {'0123456789'.split('').map((d) => (
22
+ <span key={d} className="block h-[1em]">
23
+ {d}
24
+ </span>
25
+ ))}
26
+ </span>
27
+ </span>
28
+ ) : (
29
+ <span key={`sep-${text.length - i}`}>{ch}</span>
30
+ ),
31
+ )}
32
+ </span>
33
+ )
34
+ }
@@ -0,0 +1,36 @@
1
+ // Feedback goes into the "feedback" table. Anyone can send it; only you can read it (Dashboard → Database).
2
+ import { useState, type FormEvent } from 'react'
3
+ import { baas } from '../lib/usebecky'
4
+ import { sendFeedback } from '../lib/waitlist'
5
+ import { Area, ErrorText, Field, Sent, Submit } from './fields'
6
+
7
+ export function Feedback() {
8
+ const [message, setMessage] = useState('')
9
+ const [email, setEmail] = useState('')
10
+ const [busy, setBusy] = useState(false)
11
+ const [error, setError] = useState('')
12
+ const [sent, setSent] = useState(false)
13
+
14
+ async function send(event: FormEvent<HTMLFormElement>) {
15
+ event.preventDefault()
16
+ setBusy(true)
17
+ setError('')
18
+ const { error } = await sendFeedback(message.trim(), email.trim())
19
+ setBusy(false)
20
+ if (error) return setError(error.message)
21
+ baas.analytics.track('feedback_sent')
22
+ setSent(true)
23
+ setMessage('')
24
+ }
25
+
26
+ if (sent) return <Sent title="Thank you" onReset={() => setSent(false)}>We read every message. If you left your email, we may write back with a question or two.</Sent>
27
+
28
+ return (
29
+ <form onSubmit={send} className="space-y-5">
30
+ <Area id="feedback-message" label="Your idea or problem" required maxLength={5000} value={message} onChange={(e) => setMessage(e.target.value)} placeholder="I do the shopping for four people and we always forget…" />
31
+ <Field id="feedback-email" label="Email" hint="Optional, if you’d like a reply" type="email" autoComplete="email" value={email} onChange={(e) => setEmail(e.target.value)} />
32
+ <ErrorText>{error}</ErrorText>
33
+ <Submit busy={busy}>Send feedback</Submit>
34
+ </form>
35
+ )
36
+ }
@@ -0,0 +1,11 @@
1
+ // The logo: a receipt. Inherits the brand colour.
2
+ export function Logo({ small }: { small?: boolean }) {
3
+ const size = small ? 22 : 28
4
+ return (
5
+ <svg width={size} height={size} viewBox="0 0 32 32" aria-hidden="true">
6
+ <rect width="32" height="32" rx="8" fill={small ? 'var(--brand)' : 'white'} />
7
+ <path d="M10 7h12v18l-2-1.5-2 1.5-2-1.5-2 1.5-2-1.5-2 1.5V7Z" fill={small ? 'white' : 'var(--brand)'} />
8
+ <path d="M13 12h6M13 15.5h6M13 19h3.5" stroke={small ? 'var(--brand)' : 'white'} strokeWidth="1.8" strokeLinecap="round" />
9
+ </svg>
10
+ )
11
+ }
@@ -0,0 +1,128 @@
1
+ // The waitlist: a deli-counter ticket with the live count, the email field and, once you joined, your share link.
2
+ import { useEffect, useState, type FormEvent } from 'react'
3
+ import { site } from '../content'
4
+ import { baas } from '../lib/usebecky'
5
+ import { joinWaitlist, newReferralCode, saveSpot, savedSpot, waitlistCount, type Spot } from '../lib/waitlist'
6
+ import { Counter } from './Counter'
7
+
8
+ export function Receipt() {
9
+ const [count, setCount] = useState<number | null>(null)
10
+ const [email, setEmail] = useState('')
11
+ const [busy, setBusy] = useState(false)
12
+ const [error, setError] = useState('')
13
+ const [spot, setSpot] = useState<Spot | null>(() => savedSpot())
14
+ const [already, setAlready] = useState(false)
15
+
16
+ // The live count: once now, then every 15 seconds.
17
+ useEffect(() => {
18
+ let alive = true
19
+ const load = () => waitlistCount().then((n) => alive && n !== null && setCount(n))
20
+ load()
21
+ const id = setInterval(load, 15_000)
22
+ return () => {
23
+ alive = false
24
+ clearInterval(id)
25
+ }
26
+ }, [])
27
+
28
+ async function join(event: FormEvent<HTMLFormElement>) {
29
+ event.preventDefault()
30
+ setBusy(true)
31
+ setError('')
32
+ const code = newReferralCode()
33
+ const referredBy = new URLSearchParams(location.search).get('ref')
34
+ const result = await joinWaitlist(email.trim(), code, referredBy)
35
+ if (result.status === 'error') {
36
+ setError(result.message)
37
+ setBusy(false)
38
+ return
39
+ }
40
+ const n = await waitlistCount()
41
+ if (n !== null) setCount(n)
42
+ if (result.status === 'already') setAlready(true)
43
+ else {
44
+ baas.analytics.track('waitlist_joined', { referred: Boolean(referredBy) })
45
+ const next = { number: n, code, email: email.trim() }
46
+ saveSpot(next)
47
+ setSpot(next)
48
+ }
49
+ setBusy(false)
50
+ }
51
+
52
+ return (
53
+ <div className="torn relative bg-paper px-7 pt-7 text-paper-ink shadow-[0_30px_60px_-20px_rgb(0_0_0/0.45)] lg:rotate-[1.5deg]">
54
+ {spot ? <Joined spot={spot} count={count} /> : (
55
+ <>
56
+ <p className="text-sm font-semibold">Now in line for {site.name}</p>
57
+ <p className="display mt-3 text-[4.5rem] leading-none tracking-[-0.04em] text-brand" aria-live="polite">
58
+ <Counter value={count} />
59
+ <span className="sr-only">{count === null ? 'Loading' : `${count.toLocaleString()} people`}</span>
60
+ </p>
61
+ <p className="mt-1 text-sm text-paper-ink/70">{count === null ? '\u00a0' : count === 0 ? 'Nobody in line yet. Be the first.' : `${count === 1 ? 'person is' : 'people are'} waiting. Join them.`}</p>
62
+
63
+ <Perforation />
64
+
65
+ <form onSubmit={join} noValidate={false}>
66
+ <label htmlFor="waitlist-email" className="text-sm font-semibold">
67
+ Your email
68
+ </label>
69
+ <input
70
+ id="waitlist-email"
71
+ type="email"
72
+ required
73
+ autoComplete="email"
74
+ placeholder="you@example.com"
75
+ value={email}
76
+ onChange={(e) => {
77
+ setEmail(e.target.value)
78
+ setAlready(false)
79
+ }}
80
+ className="mt-2 h-12 w-full rounded-lg border border-paper-ink/20 bg-white px-4 text-base text-paper-ink outline-none placeholder:text-paper-ink/40 focus:border-brand focus:ring-2 focus:ring-brand/25"
81
+ />
82
+ <button type="submit" disabled={busy} className="mt-3 h-12 w-full rounded-lg bg-brand font-semibold text-on-brand transition-[filter] hover:brightness-110 disabled:opacity-70">
83
+ {busy ? 'Joining…' : site.cta}
84
+ </button>
85
+ <div aria-live="polite" className="text-sm">
86
+ {error && <p className="mt-3 font-medium text-[#b42318]">{error}</p>}
87
+ {already && <p className="mt-3 font-medium">You’re already on the list. We’ll email you when it’s your turn.</p>}
88
+ </div>
89
+ <p className="mt-4 text-xs leading-relaxed text-paper-ink/60">One email when it’s your turn. No spam, and you can leave any time.</p>
90
+ </form>
91
+ </>
92
+ )}
93
+ </div>
94
+ )
95
+ }
96
+
97
+ function Joined({ spot, count }: { spot: Spot; count: number | null }) {
98
+ const [copied, setCopied] = useState(false)
99
+ const link = `${location.origin}${location.pathname}?ref=${spot.code}`
100
+ async function copy() {
101
+ await navigator.clipboard.writeText(link)
102
+ setCopied(true)
103
+ setTimeout(() => setCopied(false), 2000)
104
+ }
105
+ return (
106
+ <div role="status">
107
+ <p className="text-sm font-semibold">You’re in line</p>
108
+ <p className="display mt-3 text-[4.5rem] leading-none tracking-[-0.04em] text-brand">
109
+ <span className="mr-1 align-top text-2xl tracking-normal">No.</span>
110
+ {(spot.number ?? count ?? 0).toLocaleString()}
111
+ </p>
112
+ <p className="mt-2 text-sm leading-relaxed text-paper-ink/75">We’ll email {spot.email} when it’s your turn.</p>
113
+ <Perforation />
114
+ <p className="text-sm font-semibold">Bring the people you shop with</p>
115
+ <div className="mt-2 flex gap-2">
116
+ <input readOnly value={link} aria-label="Your share link" onFocus={(e) => e.currentTarget.select()} className="h-11 min-w-0 flex-1 rounded-lg border border-paper-ink/20 bg-white px-3 text-sm text-paper-ink" />
117
+ <button onClick={copy} className="h-11 shrink-0 rounded-lg bg-brand px-4 text-sm font-semibold text-on-brand">
118
+ {copied ? 'Copied' : 'Copy'}
119
+ </button>
120
+ </div>
121
+ <p className="mt-3 text-xs text-paper-ink/60">Anyone who joins with your link is counted as your referral.</p>
122
+ </div>
123
+ )
124
+ }
125
+
126
+ function Perforation() {
127
+ return <div className="-mx-7 my-6 border-t-2 border-dashed border-paper-ink/15" aria-hidden="true" />
128
+ }
@@ -0,0 +1,20 @@
1
+ // Shown instead of the waitlist when .env.local is missing.
2
+ export function Setup() {
3
+ return (
4
+ <div className="torn bg-paper px-7 pt-7 text-paper-ink lg:rotate-[1.5deg]">
5
+ <p className="text-sm font-semibold">Almost ready</p>
6
+ <p className="display mt-3 text-4xl leading-none">Connect your project</p>
7
+ <ol className="mt-5 list-decimal space-y-2 pl-5 text-sm leading-relaxed text-paper-ink/80">
8
+ <li>
9
+ In this folder, run <code className="rounded bg-black/5 px-1 py-0.5">npx usebecky init</code> and pick a project made from the <strong>Waitlist</strong> template.
10
+ </li>
11
+ <li>
12
+ In the dashboard, open <strong>Forms</strong> and create a <strong>Contact form</strong> with the key <code className="rounded bg-black/5 px-1 py-0.5">contact</code>.
13
+ </li>
14
+ <li>
15
+ Stop <code className="rounded bg-black/5 px-1 py-0.5">npm run dev</code> with Ctrl+C and start it again.
16
+ </li>
17
+ </ol>
18
+ </div>
19
+ )
20
+ }
@@ -0,0 +1,63 @@
1
+ // Form building blocks shared by the feedback and contact forms.
2
+ import type { InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from 'react'
3
+
4
+ const control = 'w-full rounded-xl border border-line bg-page px-4 text-base text-ink outline-none transition-colors placeholder:text-muted/70 focus:border-accent focus:bg-surface'
5
+
6
+ export function Field({ label, hint, id, ...props }: InputHTMLAttributes<HTMLInputElement> & { label: string; hint?: string; id: string }) {
7
+ return (
8
+ <div>
9
+ <Label htmlFor={id} hint={hint}>
10
+ {label}
11
+ </Label>
12
+ <input id={id} {...props} className={`${control} h-12`} />
13
+ </div>
14
+ )
15
+ }
16
+
17
+ export function Area({ label, hint, id, ...props }: TextareaHTMLAttributes<HTMLTextAreaElement> & { label: string; hint?: string; id: string }) {
18
+ return (
19
+ <div>
20
+ <Label htmlFor={id} hint={hint}>
21
+ {label}
22
+ </Label>
23
+ <textarea id={id} rows={5} {...props} className={`${control} resize-y py-3 leading-relaxed`} />
24
+ </div>
25
+ )
26
+ }
27
+
28
+ function Label({ htmlFor, hint, children }: { htmlFor: string; hint?: string; children: ReactNode }) {
29
+ return (
30
+ <label htmlFor={htmlFor} className="mb-2 flex items-baseline justify-between gap-3 text-sm font-semibold">
31
+ {children}
32
+ {hint && <span className="font-normal text-muted">{hint}</span>}
33
+ </label>
34
+ )
35
+ }
36
+
37
+ export function Submit({ busy, children }: { busy: boolean; children: ReactNode }) {
38
+ return (
39
+ <button type="submit" disabled={busy} className="h-12 rounded-xl bg-ink px-6 font-semibold text-page transition-opacity hover:opacity-90 disabled:opacity-60">
40
+ {busy ? 'Sending…' : children}
41
+ </button>
42
+ )
43
+ }
44
+
45
+ export function Sent({ title, children, onReset }: { title: string; children: ReactNode; onReset: () => void }) {
46
+ return (
47
+ <div role="status" className="rounded-2xl border border-line bg-accent-soft p-8">
48
+ <p className="display text-3xl tracking-[-0.02em]">{title}</p>
49
+ <p className="mt-3 leading-relaxed text-muted">{children}</p>
50
+ <button onClick={onReset} className="mt-6 text-sm font-semibold text-accent underline underline-offset-4">
51
+ Send another
52
+ </button>
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export function ErrorText({ children }: { children: ReactNode }) {
58
+ return children ? (
59
+ <p role="alert" className="text-sm font-medium text-danger">
60
+ {children}
61
+ </p>
62
+ ) : null
63
+ }
@@ -0,0 +1,22 @@
1
+ // Everything the page says, in one place. Change the name and the words here.
2
+ // The colour lives in src/index.css (--brand).
3
+ export const site = {
4
+ name: 'Tidy',
5
+ headline: 'The grocery list that sorts itself by aisle.',
6
+ intro: 'Share one list with everyone at home. Tidy groups it the way your store is laid out, so nobody walks back for the milk.',
7
+ cta: 'Join the waitlist',
8
+ launch: 'Opening to the first 500 households this spring.',
9
+ features: [
10
+ { title: 'Sorted by aisle', text: 'Add things in any order. They land under Produce, Bakery or Dairy, in the order you walk the store.' },
11
+ { title: 'Shared and live', text: 'Everyone at home edits the same list. Ticks show up on every phone the moment someone grabs an item.' },
12
+ { title: 'Remembers your staples', text: 'Oat milk every week, coffee every other? Tidy suggests them before you run out.' },
13
+ ],
14
+ feedback: {
15
+ title: 'What would make Tidy perfect for you?',
16
+ text: 'We read every message while we build. Tell us how you shop today and what drives you mad about it.',
17
+ },
18
+ contact: {
19
+ title: 'Questions? Talk to us.',
20
+ text: 'Press, partnerships or anything else. We answer within two working days.',
21
+ },
22
+ }