@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.
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/llms/access.md +4 -4
- package/llms/backend.md +15 -1
- package/llms/blockly.md +2 -2
- package/llms/bluesky.md +1 -1
- package/llms/board-games.md +3 -3
- package/llms/calendar.md +1 -1
- package/llms/callai.md +4 -4
- package/llms/connections.md +1 -1
- package/llms/create-vibe.md +3 -3
- package/llms/fireproof.md +7 -7
- package/llms/github.md +7 -2
- package/llms/image-gen.md +2 -2
- package/llms/index.d.ts +28 -28
- package/llms/index.js +84 -84
- package/llms/index.js.map +1 -1
- package/llms/maps.md +1 -1
- package/llms/match-style.md +1 -1
- package/llms/motion.md +7 -7
- package/llms/p5.md +1 -1
- package/llms/physics.md +2 -2
- package/llms/reskin.md +21 -21
- package/llms/richtext.md +5 -5
- package/llms/spotify.md +1 -1
- package/llms/stripe-subscriptions.js +1 -1
- package/llms/stripe-subscriptions.js.map +1 -1
- package/llms/stripe-subscriptions.md +179 -35
- package/llms/stripe.js +5 -1
- package/llms/stripe.js.map +1 -1
- package/llms/stripe.md +247 -58
- package/llms/strudel.md +3 -3
- package/llms/three-js.md +4 -4
- package/llms/touch-games.js +1 -1
- package/llms/touch-games.js.map +1 -1
- package/llms/touch-games.md +3 -3
- package/llms/ui-blog.d.ts +2 -0
- package/llms/ui-blog.js +7 -0
- package/llms/ui-blog.js.map +1 -0
- package/llms/{pouf-blog.md → ui-blog.md} +10 -10
- package/llms/ui-booking.d.ts +2 -0
- package/llms/ui-booking.js +7 -0
- package/llms/ui-booking.js.map +1 -0
- package/llms/{pouf-booking.md → ui-booking.md} +8 -8
- package/llms/ui-calendar.d.ts +2 -0
- package/llms/ui-calendar.js +7 -0
- package/llms/ui-calendar.js.map +1 -0
- package/llms/{pouf-calendar.md → ui-calendar.md} +5 -5
- package/llms/ui-chat.d.ts +2 -0
- package/llms/ui-chat.js +7 -0
- package/llms/ui-chat.js.map +1 -0
- package/llms/{pouf-chat.md → ui-chat.md} +4 -4
- package/llms/ui-contact.d.ts +2 -0
- package/llms/ui-contact.js +7 -0
- package/llms/ui-contact.js.map +1 -0
- package/llms/{pouf-contact.md → ui-contact.md} +7 -7
- package/llms/ui-course.d.ts +2 -0
- package/llms/ui-course.js +7 -0
- package/llms/ui-course.js.map +1 -0
- package/llms/{pouf-course.md → ui-course.md} +9 -9
- package/llms/ui-crm.d.ts +2 -0
- package/llms/ui-crm.js +7 -0
- package/llms/ui-crm.js.map +1 -0
- package/llms/{pouf-crm.md → ui-crm.md} +5 -5
- package/llms/ui-dashboard.d.ts +2 -0
- package/llms/ui-dashboard.js +7 -0
- package/llms/ui-dashboard.js.map +1 -0
- package/llms/{pouf-dashboard.md → ui-dashboard.md} +7 -7
- package/llms/ui-editorial.d.ts +2 -0
- package/llms/ui-editorial.js +7 -0
- package/llms/ui-editorial.js.map +1 -0
- package/llms/{pouf-editorial.md → ui-editorial.md} +5 -5
- package/llms/ui-event.d.ts +2 -0
- package/llms/ui-event.js +7 -0
- package/llms/ui-event.js.map +1 -0
- package/llms/{pouf-event.md → ui-event.md} +5 -5
- package/llms/ui-feed.d.ts +2 -0
- package/llms/ui-feed.js +7 -0
- package/llms/ui-feed.js.map +1 -0
- package/llms/{pouf-feed.md → ui-feed.md} +5 -5
- package/llms/ui-game.d.ts +2 -0
- package/llms/ui-game.js +7 -0
- package/llms/ui-game.js.map +1 -0
- package/llms/{pouf-game.md → ui-game.md} +6 -6
- package/llms/ui-inbox.d.ts +2 -0
- package/llms/ui-inbox.js +7 -0
- package/llms/ui-inbox.js.map +1 -0
- package/llms/{pouf-inbox.md → ui-inbox.md} +5 -5
- package/llms/ui-inventory.d.ts +2 -0
- package/llms/ui-inventory.js +7 -0
- package/llms/ui-inventory.js.map +1 -0
- package/llms/{pouf-inventory.md → ui-inventory.md} +5 -5
- package/llms/ui-kanban.d.ts +2 -0
- package/llms/ui-kanban.js +7 -0
- package/llms/ui-kanban.js.map +1 -0
- package/llms/{pouf-kanban.md → ui-kanban.md} +5 -5
- package/llms/ui-landing.d.ts +2 -0
- package/llms/ui-landing.js +7 -0
- package/llms/ui-landing.js.map +1 -0
- package/llms/{pouf-landing.md → ui-landing.md} +6 -6
- package/llms/ui-login.d.ts +2 -0
- package/llms/ui-login.js +7 -0
- package/llms/ui-login.js.map +1 -0
- package/llms/{pouf-login.md → ui-login.md} +7 -7
- package/llms/ui-music.d.ts +2 -0
- package/llms/ui-music.js +7 -0
- package/llms/ui-music.js.map +1 -0
- package/llms/{pouf-music.md → ui-music.md} +6 -6
- package/llms/ui-onboarding.d.ts +2 -0
- package/llms/ui-onboarding.js +7 -0
- package/llms/ui-onboarding.js.map +1 -0
- package/llms/{pouf-onboarding.md → ui-onboarding.md} +5 -5
- package/llms/ui-pricing.d.ts +2 -0
- package/llms/ui-pricing.js +7 -0
- package/llms/ui-pricing.js.map +1 -0
- package/llms/{pouf-pricing.md → ui-pricing.md} +5 -5
- package/llms/ui-profile.d.ts +2 -0
- package/llms/ui-profile.js +7 -0
- package/llms/ui-profile.js.map +1 -0
- package/llms/{pouf-profile.md → ui-profile.md} +4 -4
- package/llms/ui-quiz.d.ts +2 -0
- package/llms/ui-quiz.js +7 -0
- package/llms/ui-quiz.js.map +1 -0
- package/llms/{pouf-quiz.md → ui-quiz.md} +6 -6
- package/llms/ui-settings.d.ts +2 -0
- package/llms/ui-settings.js +7 -0
- package/llms/ui-settings.js.map +1 -0
- package/llms/{pouf-settings.md → ui-settings.md} +5 -5
- package/llms/ui-storefront.d.ts +2 -0
- package/llms/ui-storefront.js +7 -0
- package/llms/ui-storefront.js.map +1 -0
- package/llms/ui-storefront.md +468 -0
- package/llms/ui-support.d.ts +2 -0
- package/llms/ui-support.js +7 -0
- package/llms/ui-support.js.map +1 -0
- package/llms/{pouf-support.md → ui-support.md} +5 -5
- package/llms/ui-testimonials.d.ts +2 -0
- package/llms/ui-testimonials.js +7 -0
- package/llms/ui-testimonials.js.map +1 -0
- package/llms/{pouf-testimonials.md → ui-testimonials.md} +6 -6
- package/llms/ui-todo.d.ts +2 -0
- package/llms/ui-todo.js +7 -0
- package/llms/ui-todo.js.map +1 -0
- package/llms/{pouf-todo.md → ui-todo.md} +5 -5
- package/llms/ui-weather.d.ts +2 -0
- package/llms/ui-weather.js +7 -0
- package/llms/ui-weather.js.map +1 -0
- package/llms/{pouf-weather.md → ui-weather.md} +5 -5
- package/llms/use-vibe.md +4 -4
- package/llms/use-viewer.md +5 -5
- package/llms/voxel.md +1 -1
- package/llms/web-audio.md +12 -12
- package/llms/worlds.md +3 -3
- package/llms/youtube.md +1 -1
- package/package.json +5 -5
- package/system-prompt-initial-instant.md +3 -3
- package/system-prompt-initial-oneshot.md +1 -1
- package/system-prompt-initial.md +1 -1
- package/system-prompt.md +4 -4
- package/themes/colorsets.js +7 -7
- package/themes/colorsets.js.map +1 -1
- package/themes/looks/pouf/brief.md +87 -87
- package/themes/looks/pouf/catalog.generated.d.ts +1 -1
- package/themes/looks/pouf/catalog.generated.js +17 -17
- package/themes/looks/pouf/catalog.generated.js.map +1 -1
- package/themes/looks/pouf/variety.js +4 -4
- package/themes/looks/pouf/variety.js.map +1 -1
- package/llms/pouf-blog.d.ts +0 -2
- package/llms/pouf-blog.js +0 -6
- package/llms/pouf-blog.js.map +0 -1
- package/llms/pouf-booking.d.ts +0 -2
- package/llms/pouf-booking.js +0 -6
- package/llms/pouf-booking.js.map +0 -1
- package/llms/pouf-calendar.d.ts +0 -2
- package/llms/pouf-calendar.js +0 -6
- package/llms/pouf-calendar.js.map +0 -1
- package/llms/pouf-chat.d.ts +0 -2
- package/llms/pouf-chat.js +0 -6
- package/llms/pouf-chat.js.map +0 -1
- package/llms/pouf-contact.d.ts +0 -2
- package/llms/pouf-contact.js +0 -6
- package/llms/pouf-contact.js.map +0 -1
- package/llms/pouf-course.d.ts +0 -2
- package/llms/pouf-course.js +0 -6
- package/llms/pouf-course.js.map +0 -1
- package/llms/pouf-crm.d.ts +0 -2
- package/llms/pouf-crm.js +0 -6
- package/llms/pouf-crm.js.map +0 -1
- package/llms/pouf-dashboard.d.ts +0 -2
- package/llms/pouf-dashboard.js +0 -6
- package/llms/pouf-dashboard.js.map +0 -1
- package/llms/pouf-editorial.d.ts +0 -2
- package/llms/pouf-editorial.js +0 -6
- package/llms/pouf-editorial.js.map +0 -1
- package/llms/pouf-event.d.ts +0 -2
- package/llms/pouf-event.js +0 -6
- package/llms/pouf-event.js.map +0 -1
- package/llms/pouf-feed.d.ts +0 -2
- package/llms/pouf-feed.js +0 -6
- package/llms/pouf-feed.js.map +0 -1
- package/llms/pouf-game.d.ts +0 -2
- package/llms/pouf-game.js +0 -6
- package/llms/pouf-game.js.map +0 -1
- package/llms/pouf-inbox.d.ts +0 -2
- package/llms/pouf-inbox.js +0 -6
- package/llms/pouf-inbox.js.map +0 -1
- package/llms/pouf-inventory.d.ts +0 -2
- package/llms/pouf-inventory.js +0 -6
- package/llms/pouf-inventory.js.map +0 -1
- package/llms/pouf-kanban.d.ts +0 -2
- package/llms/pouf-kanban.js +0 -6
- package/llms/pouf-kanban.js.map +0 -1
- package/llms/pouf-landing.d.ts +0 -2
- package/llms/pouf-landing.js +0 -6
- package/llms/pouf-landing.js.map +0 -1
- package/llms/pouf-login.d.ts +0 -2
- package/llms/pouf-login.js +0 -6
- package/llms/pouf-login.js.map +0 -1
- package/llms/pouf-music.d.ts +0 -2
- package/llms/pouf-music.js +0 -6
- package/llms/pouf-music.js.map +0 -1
- package/llms/pouf-onboarding.d.ts +0 -2
- package/llms/pouf-onboarding.js +0 -6
- package/llms/pouf-onboarding.js.map +0 -1
- package/llms/pouf-pricing.d.ts +0 -2
- package/llms/pouf-pricing.js +0 -6
- package/llms/pouf-pricing.js.map +0 -1
- package/llms/pouf-profile.d.ts +0 -2
- package/llms/pouf-profile.js +0 -6
- package/llms/pouf-profile.js.map +0 -1
- package/llms/pouf-quiz.d.ts +0 -2
- package/llms/pouf-quiz.js +0 -6
- package/llms/pouf-quiz.js.map +0 -1
- package/llms/pouf-settings.d.ts +0 -2
- package/llms/pouf-settings.js +0 -6
- package/llms/pouf-settings.js.map +0 -1
- package/llms/pouf-storefront.d.ts +0 -2
- package/llms/pouf-storefront.js +0 -6
- package/llms/pouf-storefront.js.map +0 -1
- package/llms/pouf-storefront.md +0 -293
- package/llms/pouf-support.d.ts +0 -2
- package/llms/pouf-support.js +0 -6
- package/llms/pouf-support.js.map +0 -1
- package/llms/pouf-testimonials.d.ts +0 -2
- package/llms/pouf-testimonials.js +0 -6
- package/llms/pouf-testimonials.js.map +0 -1
- package/llms/pouf-todo.d.ts +0 -2
- package/llms/pouf-todo.js +0 -6
- package/llms/pouf-todo.js.map +0 -1
- package/llms/pouf-weather.d.ts +0 -2
- package/llms/pouf-weather.js +0 -6
- package/llms/pouf-weather.js.map +0 -1
- package/look-restyle.d.ts +0 -49
- package/look-restyle.js +0 -199
- package/look-restyle.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Quiz
|
|
2
2
|
|
|
3
3
|
A short multiple-choice quiz that keeps score: an astronomy club's star-chart check, a refresher round before a test, a pub quiz warm-up, a training check for new staff. Reach for it when the app asks a handful of questions one at a time, says right or wrong after each answer, ends on a score and lets people come back to beat it. Each finished attempt someone saves is its own document, so their past scores are there on the next visit and on any device.
|
|
4
4
|
|
|
5
|
-
Built from @vibes.diy/
|
|
5
|
+
Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
|
|
6
6
|
|
|
7
7
|
## The block
|
|
8
8
|
|
|
9
|
-
One view with one job: answer the questions, then keep the score. A `Heading` and a muted line open the page. The quiz sits on a `Card`: an `Eyebrow` with the question number beside an `info` `Badge` counting correct answers so far (it steps aside on the result, which states the score once), and a `Progress` (`info`) across the top. Each question is a `Heading level={2}` over a `RadioGroup`; `Check answer` is the view's one lead, then the answer shows as a `Badge` (`up` right, `down` wrong) with the right option in muted `Text`, and the lead becomes `Next question`. The result swaps in
|
|
9
|
+
One view with one job: answer the questions, then keep the score. A `Heading` and a muted line open the page. The quiz sits on a `Card`: an `Eyebrow` with the question number beside an `info` `Badge` counting correct answers so far (it steps aside on the result, which states the score once), and a `Progress` (`info`) across the top. Each question is a `Heading level={2}` over a `RadioGroup`; `Check answer` is the view's one lead, then the answer shows as a `Badge` (`up` right, `down` wrong) with the right option in muted `Text`, and the lead becomes `Next question`. The result swaps in an `IconTile` (`up` for a pass, `warn` otherwise), the score and a recap of every question with its own `up` or `down` `Badge`. `Save score` is then the lead, with `loading` while the write lands, beside a quiet `Play again`. A signed-in person's earlier attempts sit below as `RowCard`s, newest first, each with a `Badge` toned by how it went. Saving waits on its `can` verdict from `useVibe("quiz")`, the database the attempts live in: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a `Sign in to save your score` lead wired to `useViewer().requestLogin()` for a visitor who has not signed in, and a sentence in the app's own words when saving is closed. Anyone can take the quiz without signing in; the attempt lives only in the page until it is saved, and the copy says so.
|
|
10
10
|
|
|
11
11
|
### `App.jsx`
|
|
12
12
|
```jsx
|
|
13
13
|
import React, { useState } from "react";
|
|
14
14
|
import { useFireproof } from "use-fireproof";
|
|
15
15
|
import { useViewer, useVibe } from "use-vibes";
|
|
16
|
-
import { Badge,
|
|
17
|
-
import { Progress, RadioGroup } from "@vibes.diy/
|
|
16
|
+
import { Badge, IconTile, Button, Card, Eyebrow, Heading, Row, RowCard, Skeleton, Stack, Text } from "@vibes.diy/ui";
|
|
17
|
+
import { Progress, RadioGroup } from "@vibes.diy/ui/interactive";
|
|
18
18
|
|
|
19
19
|
const QUIZ_ID = "houseplants";
|
|
20
20
|
const QUESTIONS = [
|
|
@@ -177,7 +177,7 @@ export default function App() {
|
|
|
177
177
|
{done ? (
|
|
178
178
|
<Stack gap={4}>
|
|
179
179
|
<Row gap={3} wrap={false}>
|
|
180
|
-
<
|
|
180
|
+
<IconTile icon={passed ? "trophy" : "flame"} tone={passed ? "up" : "warn"} />
|
|
181
181
|
<Stack gap={1}>
|
|
182
182
|
<Heading level={2}>{score === TOTAL ? "Perfect score!" : passed ? "Nice work" : "Keep practising"}</Heading>
|
|
183
183
|
<Text muted>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-settings.js","sourceRoot":"","sources":["../../jsr/llms/ui-settings.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,CAAC,eAAe,CAAC;IAC1B,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,wDAAwD;CACtE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Settings
|
|
2
2
|
|
|
3
3
|
A settings screen for each person's own preferences: the display name in a sleep log, reminder emails for a reading log, a compact or comfortable layout, how loud an alert should be. Reach for it whenever the app lets someone tune how it treats them and expects those choices to stick. Each person's settings persist as their own document, so a choice made on the phone is there on the laptop.
|
|
4
4
|
|
|
5
|
-
Built from @vibes.diy/
|
|
5
|
+
Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
|
|
6
6
|
|
|
7
7
|
## The block
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ One view with one job: change your settings and save them. An `Eyebrow`, the `He
|
|
|
13
13
|
import React, { useEffect, useState } from "react";
|
|
14
14
|
import { useFireproof } from "use-fireproof";
|
|
15
15
|
import { useViewer, useVibe } from "use-vibes";
|
|
16
|
-
import { Badge, Button, Card, Eyebrow, Field, Heading, Input, Row, Skeleton, Stack, Text, Textarea } from "@vibes.diy/
|
|
17
|
-
import { RadioGroup, Separator, Slider, Switch, Tabs, Toaster, toast } from "@vibes.diy/
|
|
16
|
+
import { Badge, Button, Card, Eyebrow, Field, Heading, Input, Row, Skeleton, Stack, Text, Textarea } from "@vibes.diy/ui";
|
|
17
|
+
import { RadioGroup, Separator, Slider, Switch, Tabs, Toaster, toast } from "@vibes.diy/ui/interactive";
|
|
18
18
|
|
|
19
19
|
const DEFAULTS = { name: "", bio: "", density: "comfortable", emailNotif: true, pushNotif: false, volume: 60 };
|
|
20
20
|
const KEYS = Object.keys(DEFAULTS);
|
|
@@ -201,7 +201,7 @@ export default function App() {
|
|
|
201
201
|
// Re-keyed when the saved copy first arrives, so the form starts from it.
|
|
202
202
|
<SettingsForm key={saved ? "saved" : "new"} saved={saved} database={database} can={can} me={me} />
|
|
203
203
|
)}
|
|
204
|
-
<div className="
|
|
204
|
+
<div className="ui-toasts">
|
|
205
205
|
<Toaster />
|
|
206
206
|
</div>
|
|
207
207
|
</main>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const uiStorefrontConfig = {
|
|
2
|
+
name: "ui-storefront",
|
|
3
|
+
aliases: ["pouf-storefront"],
|
|
4
|
+
label: "Storefront block",
|
|
5
|
+
description: "Product grid the owner stocks and prices in the app, with filters, a shopping bag and an order; card payment is the stripe skill",
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=ui-storefront.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-storefront.js","sourceRoot":"","sources":["../../jsr/llms/ui-storefront.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;IAC5B,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,kIAAkI;CAChJ,CAAC"}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# Storefront
|
|
2
|
+
|
|
3
|
+
A small shop: product cards to browse, a category filter and a search, a bag that adds things up, and a checkout that places the order. It fits a potter's ceramics, a bakery's preorders, a club's merch table or a school fair's stall. Reach for it whenever the app's core is a short catalogue that people pick from and then order. The catalogue is the owner's: each thing for sale is a `product` record the owner adds on the app's own Products screen, with its name, price, a short line, a category and a photo, so changing what the shop sells is an edit in the app, never a rebuild. The bag lives in the page while someone shops. Each placed order persists as its own document, so the shop can see what to make and the buyer can see what they ordered. It records orders; taking card payment is the `stripe` skill, which reads these same product records.
|
|
4
|
+
|
|
5
|
+
Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
|
|
6
|
+
|
|
7
|
+
## The block
|
|
8
|
+
|
|
9
|
+
Two screens, one job each. The **Shop** fills the bag and places the order: a `Navbar` carries the brand and a quiet bag button with a live count, and the `Heading` puts an `orange` `Highlight` on one word beside a muted line. A `Segmented` category filter (`tone="info"`) and a search `Input` in a `Field` sit above a `Grid cols="sidebar"`: on the main side a two-column grid of product `Card`s, each fronted by its photo in a `Figure` (or the category's decorative `orange` `IconTile` until a photo is added), an `info` `Badge` for "New" or "Bestseller", the price in numeric `Text` and a quiet `Add to bag` (an `Empty` stands in when nothing matches); on the side the bag's `Card`, one line per product with its total and `IconButton`s to take one away or add one, then the subtotal, shipping and total. `Place order` is the shop's one lead; it shows `loading` while the write lands, and the bag empties only after it does.
|
|
10
|
+
|
|
11
|
+
The **Products** screen is the owner's, behind `can.create` on a product draft: a form for the name, price, short line, category and photo, then one row per product whose price edits in place and whose `On sale` checkbox puts it in front of buyers or takes it away. The catalogue starts empty, and an owner who opens an empty shop lands on this screen with "Add the first thing you sell"; a visitor sees a warm `Empty` until the first product goes on sale. Every price is a whole number in the currency's smallest unit (cents for usd, whole yen for jpy) beside its `currency`, the unit card payments charge in, and the page shows, edits and adds prices through that unit.
|
|
12
|
+
|
|
13
|
+
An order is one document holding a snapshot of each line's title, unit price and quantity, the totals, the currency and the buyer's handle, so a later price change never rewrites an order already placed; the person's own orders list under the bag, each with a `Badge` for its status (`info` received, `warn` ready to collect, `up` collected). Checkout waits on its `can` verdict from `useVibe("orders")`: a `Skeleton` inside an `aria-busy` wrapper while it resolves, a sentence in the app's own words when ordering is closed, and for a visitor who has not signed in a `Sign in to place your order` lead wired to `useViewer().requestLogin()`, with the bag they filled kept in place. Sign-in is required here, unlike a local-first note, because a signed-out write stays on the device until sign-in: an order placed that way would never reach the shop.
|
|
14
|
+
|
|
15
|
+
### `App.jsx`
|
|
16
|
+
```jsx
|
|
17
|
+
import React, { useEffect, useState } from "react";
|
|
18
|
+
import { useFireproof } from "use-fireproof";
|
|
19
|
+
import { useViewer, useVibe } from "use-vibes";
|
|
20
|
+
import {
|
|
21
|
+
Badge,
|
|
22
|
+
IconTile,
|
|
23
|
+
Button,
|
|
24
|
+
Card,
|
|
25
|
+
Empty,
|
|
26
|
+
Eyebrow,
|
|
27
|
+
Field,
|
|
28
|
+
Figure,
|
|
29
|
+
Grid,
|
|
30
|
+
Heading,
|
|
31
|
+
Highlight,
|
|
32
|
+
Icon,
|
|
33
|
+
IconButton,
|
|
34
|
+
Input,
|
|
35
|
+
Navbar,
|
|
36
|
+
Row,
|
|
37
|
+
Segmented,
|
|
38
|
+
Skeleton,
|
|
39
|
+
Spacer,
|
|
40
|
+
Stack,
|
|
41
|
+
Text,
|
|
42
|
+
} from "@vibes.diy/ui";
|
|
43
|
+
import { Checkbox, Select, Separator, Toaster, toast } from "@vibes.diy/ui/interactive";
|
|
44
|
+
|
|
45
|
+
// Prices are whole numbers in the currency's smallest unit: cents for usd, whole yen for jpy.
|
|
46
|
+
// Show, edit and add them through that unit, never a fixed 100.
|
|
47
|
+
const CURRENCY = "usd"; // the currency new products are priced in
|
|
48
|
+
const digits = (currency) => new Intl.NumberFormat("en", { style: "currency", currency }).resolvedOptions().maximumFractionDigits;
|
|
49
|
+
const money = (amount, currency) => new Intl.NumberFormat(undefined, { style: "currency", currency }).format(amount / 10 ** digits(currency));
|
|
50
|
+
const toMinor = (text, currency) => Math.round(Number(text) * 10 ** digits(currency));
|
|
51
|
+
const shown = (amount, currency) => (amount / 10 ** digits(currency)).toFixed(digits(currency));
|
|
52
|
+
|
|
53
|
+
const CATEGORIES = [
|
|
54
|
+
{ value: "table", label: "Table", icon: "drop" },
|
|
55
|
+
{ value: "home", label: "Home", icon: "home" },
|
|
56
|
+
{ value: "gifts", label: "Gifts", icon: "heart" },
|
|
57
|
+
];
|
|
58
|
+
const FILTERS = [{ value: "all", label: "All" }, ...CATEGORIES.map(({ value, label }) => ({ value, label }))];
|
|
59
|
+
const BADGES = [
|
|
60
|
+
{ value: "", label: "No badge" },
|
|
61
|
+
{ value: "New", label: "New" },
|
|
62
|
+
{ value: "Bestseller", label: "Bestseller" },
|
|
63
|
+
];
|
|
64
|
+
const PRODUCT_DRAFT = { _id: "product-draft", type: "product", title: "Draft", amount: 100, currency: CURRENCY, onSale: true };
|
|
65
|
+
const iconOf = (category) => CATEGORIES.find((c) => c.value === category)?.icon ?? "tag";
|
|
66
|
+
// Shipping in the same smallest unit: a flat rate, free over a threshold.
|
|
67
|
+
const SHIPPING = 800;
|
|
68
|
+
const FREE_SHIPPING = 10000;
|
|
69
|
+
const ORDER_STATUS = {
|
|
70
|
+
received: { label: "Received", tone: "info" },
|
|
71
|
+
ready: { label: "Ready to collect", tone: "warn" },
|
|
72
|
+
collected: { label: "Collected", tone: "up" },
|
|
73
|
+
};
|
|
74
|
+
const MAX_QTY = 99; // the most of one thing a bag holds
|
|
75
|
+
const plural = (n, one, many) => (n === 1 ? `1 ${one}` : `${n} ${many}`);
|
|
76
|
+
|
|
77
|
+
// One product on the owner's list: its price edits in place, and On sale puts it in front of
|
|
78
|
+
// buyers or takes it away. A refused write puts the shown price back.
|
|
79
|
+
function ProductRow({ product, save }) {
|
|
80
|
+
const [price, setPrice] = useState(shown(product.amount, product.currency));
|
|
81
|
+
useEffect(() => setPrice(shown(product.amount, product.currency)), [product.amount]);
|
|
82
|
+
const commit = () => {
|
|
83
|
+
const amount = toMinor(price, product.currency);
|
|
84
|
+
if (Number.isInteger(amount) && amount > 0 && amount !== product.amount) save({ ...product, amount }, () => setPrice(shown(product.amount, product.currency)));
|
|
85
|
+
else setPrice(shown(product.amount, product.currency));
|
|
86
|
+
};
|
|
87
|
+
return (
|
|
88
|
+
<Row gap={3} wrap={false}>
|
|
89
|
+
{product._files?.photo?.url ? (
|
|
90
|
+
<Figure src={product._files.photo.url} alt={product.title} width={48} height={48} />
|
|
91
|
+
) : (
|
|
92
|
+
<IconTile icon={iconOf(product.category)} tone="orange" size="sm" />
|
|
93
|
+
)}
|
|
94
|
+
<Text truncate>{product.title}</Text>
|
|
95
|
+
<Spacer />
|
|
96
|
+
<Field label="Price">
|
|
97
|
+
{(id, describedBy) => (
|
|
98
|
+
<Input id={id} describedBy={describedBy} value={price} onChange={setPrice} onBlur={commit} onKeyDown={(e) => e.key === "Enter" && commit()} inputMode="decimal" />
|
|
99
|
+
)}
|
|
100
|
+
</Field>
|
|
101
|
+
<Checkbox label="On sale" checked={product.onSale} onChange={(on) => save({ ...product, onSale: on === true })} />
|
|
102
|
+
</Row>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// The owner's catalogue: what is for sale and what it costs. Each save is a `product` record that
|
|
107
|
+
// access.js takes from the owner alone. Empty, the form for the first product leads.
|
|
108
|
+
function Products({ products, onAdd }) {
|
|
109
|
+
const { database } = useFireproof("orders");
|
|
110
|
+
const blank = { title: "", price: "", blurb: "", category: CATEGORIES[0].value, badge: "", photo: null };
|
|
111
|
+
const [draft, setDraft] = useState(blank);
|
|
112
|
+
const [adding, setAdding] = useState(false);
|
|
113
|
+
const [error, setError] = useState(null);
|
|
114
|
+
// A file input keeps its pick until it remounts, so each new draft gets a fresh one.
|
|
115
|
+
const [pickerKey, setPickerKey] = useState(0);
|
|
116
|
+
const edit = (key, value) => setDraft((d) => ({ ...d, [key]: value }));
|
|
117
|
+
|
|
118
|
+
// A plain put lands on this device at once and the server's verdict arrives on its receipt; a
|
|
119
|
+
// put carrying a photo uploads first and rejects instead. Either way the owner hears why.
|
|
120
|
+
async function save(product, undo) {
|
|
121
|
+
setError(null);
|
|
122
|
+
try {
|
|
123
|
+
const { synced } = await database.put(product);
|
|
124
|
+
synced.on((s) => {
|
|
125
|
+
if (s.status !== "refused") return;
|
|
126
|
+
undo?.();
|
|
127
|
+
setError(s.message ?? "That did not save: a product needs a name and a price like 12.50.");
|
|
128
|
+
});
|
|
129
|
+
} catch (err) {
|
|
130
|
+
undo?.();
|
|
131
|
+
setError(err.message);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function add() {
|
|
136
|
+
const amount = toMinor(draft.price, CURRENCY);
|
|
137
|
+
if (!draft.title.trim() || !Number.isInteger(amount) || amount <= 0) return setError("Give it a name and a price like 12.50.");
|
|
138
|
+
const product = {
|
|
139
|
+
_id: "product-" + crypto.randomUUID(),
|
|
140
|
+
type: "product",
|
|
141
|
+
title: draft.title.trim(),
|
|
142
|
+
blurb: draft.blurb.trim(),
|
|
143
|
+
category: draft.category,
|
|
144
|
+
badge: draft.badge || null,
|
|
145
|
+
amount,
|
|
146
|
+
currency: CURRENCY,
|
|
147
|
+
onSale: true,
|
|
148
|
+
createdAt: Date.now(),
|
|
149
|
+
_files: draft.photo ? { photo: draft.photo } : {},
|
|
150
|
+
};
|
|
151
|
+
// The owner stays here: the first product would otherwise flip an empty shop's default screen.
|
|
152
|
+
onAdd();
|
|
153
|
+
setAdding(true);
|
|
154
|
+
const cleared = { ...blank };
|
|
155
|
+
setDraft(cleared);
|
|
156
|
+
setPickerKey((k) => k + 1);
|
|
157
|
+
// A refused write hands the draft back, unless the owner has touched the next one.
|
|
158
|
+
await save(product, () => setDraft((d) => (d === cleared ? draft : d)));
|
|
159
|
+
setAdding(false);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Stack gap={5}>
|
|
164
|
+
<Card>
|
|
165
|
+
<Stack gap={4}>
|
|
166
|
+
<Heading level={2}>{products.length === 0 ? "Add the first thing you sell" : "Add a product"}</Heading>
|
|
167
|
+
<Grid cols={2} gap={3}>
|
|
168
|
+
<Field label="Name">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={draft.title} onChange={(v) => edit("title", v)} placeholder="Speckled mug" />}</Field>
|
|
169
|
+
<Field label="Price">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={draft.price} onChange={(v) => edit("price", v)} placeholder="28.00" inputMode="decimal" />}</Field>
|
|
170
|
+
<Field label="Short line">{(id, describedBy) => <Input id={id} describedBy={describedBy} value={draft.blurb} onChange={(v) => edit("blurb", v)} placeholder="Holds a generous coffee." />}</Field>
|
|
171
|
+
<Field label="Category">{(id, describedBy) => <Select id={id} describedBy={describedBy} value={draft.category} onChange={(v) => edit("category", v)} options={CATEGORIES} />}</Field>
|
|
172
|
+
<Field label="Badge">{(id, describedBy) => <Select id={id} describedBy={describedBy} value={draft.badge} onChange={(v) => edit("badge", v)} options={BADGES} />}</Field>
|
|
173
|
+
<Field label="Photo">{(id, describedBy) => <input key={pickerKey} id={id} aria-describedby={describedBy} type="file" accept="image/*" onChange={(e) => edit("photo", e.target.files?.[0] ?? null)} />}</Field>
|
|
174
|
+
</Grid>
|
|
175
|
+
{error && <Text>{error}</Text>}
|
|
176
|
+
<Button loading={adding} onClick={add}>
|
|
177
|
+
Add to the shop
|
|
178
|
+
</Button>
|
|
179
|
+
</Stack>
|
|
180
|
+
</Card>
|
|
181
|
+
{products.length > 0 && (
|
|
182
|
+
<Card>
|
|
183
|
+
<Stack gap={3}>
|
|
184
|
+
<Heading level={2}>Products</Heading>
|
|
185
|
+
{products.map((p) => (
|
|
186
|
+
<ProductRow key={p._id} product={p} save={save} />
|
|
187
|
+
))}
|
|
188
|
+
</Stack>
|
|
189
|
+
</Card>
|
|
190
|
+
)}
|
|
191
|
+
</Stack>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export default function App() {
|
|
196
|
+
const { database, useLiveQuery } = useFireproof("orders");
|
|
197
|
+
const { docs: orders } = useLiveQuery("type", { key: "order" });
|
|
198
|
+
const { docs: products } = useLiveQuery("type", { key: "product" });
|
|
199
|
+
const { can, me } = useVibe("orders");
|
|
200
|
+
const { requestLogin } = useViewer();
|
|
201
|
+
|
|
202
|
+
// The owner's verdict on a product draft carrying every field add() stamps: access.js takes
|
|
203
|
+
// product records from the owner alone, and only with a name, a whole-unit price and a currency.
|
|
204
|
+
const canStock = can.create(PRODUCT_DRAFT);
|
|
205
|
+
// An owner with an empty shop starts on Products; after that the shop leads until they switch.
|
|
206
|
+
const [view, setView] = useState(null);
|
|
207
|
+
const screen = view ?? (!canStock.pending && canStock.ok && products.length === 0 ? "products" : "shop");
|
|
208
|
+
|
|
209
|
+
const [category, setCategory] = useState("all");
|
|
210
|
+
const [query, setQuery] = useState("");
|
|
211
|
+
// The bag is a draft: it lives in the page until the order is placed.
|
|
212
|
+
const [bag, setBag] = useState({});
|
|
213
|
+
const [placing, setPlacing] = useState(false);
|
|
214
|
+
|
|
215
|
+
// One currency per bag: the shop sells in CURRENCY, so a record priced in another stays off the shelf.
|
|
216
|
+
const forSale = products.filter((p) => p.onSale && p.currency === CURRENCY).sort((a, b) => a.createdAt - b.createdAt);
|
|
217
|
+
const needle = query.trim().toLowerCase();
|
|
218
|
+
const visible = forSale.filter(
|
|
219
|
+
(p) => (category === "all" || p.category === category) && (needle === "" || `${p.title} ${p.blurb ?? ""}`.toLowerCase().includes(needle))
|
|
220
|
+
);
|
|
221
|
+
// A product taken off sale drops out of the bag's lines as well as the grid.
|
|
222
|
+
const lines = forSale
|
|
223
|
+
.filter((p) => (bag[p._id] ?? 0) > 0)
|
|
224
|
+
.map((p) => ({ productId: p._id, title: p.title, unitAmount: p.amount, qty: bag[p._id] }));
|
|
225
|
+
const count = lines.reduce((n, l) => n + l.qty, 0);
|
|
226
|
+
const subtotal = lines.reduce((n, l) => n + l.unitAmount * l.qty, 0);
|
|
227
|
+
const shipping = subtotal === 0 || subtotal >= FREE_SHIPPING ? 0 : SHIPPING;
|
|
228
|
+
const mine = me ? orders.filter((o) => o.authorHandle === me.userHandle).sort((a, b) => b.createdAt - a.createdAt) : [];
|
|
229
|
+
|
|
230
|
+
// The verdict for the order placeOrder writes, carrying the same fields it stamps.
|
|
231
|
+
const orderDraft = { type: "order", status: "received", authorHandle: me?.userHandle };
|
|
232
|
+
const canOrder = can.create(orderDraft);
|
|
233
|
+
|
|
234
|
+
function change(id, delta) {
|
|
235
|
+
setBag((b) => {
|
|
236
|
+
const qty = Math.min(MAX_QTY, Math.max(0, (b[id] ?? 0) + delta));
|
|
237
|
+
const { [id]: _gone, ...rest } = b;
|
|
238
|
+
return qty === 0 ? rest : { ...rest, [id]: qty };
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function placeOrder() {
|
|
243
|
+
setPlacing(true);
|
|
244
|
+
try {
|
|
245
|
+
await database.put({ ...orderDraft, lines, currency: CURRENCY, subtotal, shipping, total: subtotal + shipping, createdAt: Date.now() });
|
|
246
|
+
// Emptied only once the order lands, so a local failure keeps the bag.
|
|
247
|
+
setBag({});
|
|
248
|
+
toast.success("Order placed. We'll be in touch about collection.");
|
|
249
|
+
} finally {
|
|
250
|
+
setPlacing(false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let checkout;
|
|
255
|
+
if (canOrder.pending)
|
|
256
|
+
checkout = (
|
|
257
|
+
<div aria-busy="true">
|
|
258
|
+
<Skeleton variant="row" />
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
261
|
+
else if (!me)
|
|
262
|
+
checkout = (
|
|
263
|
+
<Button block disabled={count === 0} onClick={requestLogin}>
|
|
264
|
+
Sign in to place your order
|
|
265
|
+
</Button>
|
|
266
|
+
);
|
|
267
|
+
else if (!canOrder.ok) checkout = <Text muted>The shop isn't taking orders right now. Check back soon.</Text>;
|
|
268
|
+
else
|
|
269
|
+
checkout = (
|
|
270
|
+
<Button block disabled={count === 0} loading={placing} onClick={placeOrder}>
|
|
271
|
+
Place order
|
|
272
|
+
</Button>
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<main className="mx-auto max-w-6xl px-4 py-6">
|
|
277
|
+
<Stack gap={6}>
|
|
278
|
+
<Navbar
|
|
279
|
+
brand={
|
|
280
|
+
<Row gap={2} wrap={false}>
|
|
281
|
+
<IconTile icon="sparkle" tone="orange" size="sm" />
|
|
282
|
+
<Text>Kiln & Co.</Text>
|
|
283
|
+
</Row>
|
|
284
|
+
}
|
|
285
|
+
actions={
|
|
286
|
+
<>
|
|
287
|
+
{!canStock.pending && canStock.ok && (
|
|
288
|
+
<Button size="sm" variant="quiet" onClick={() => setView(screen === "products" ? "shop" : "products")}>
|
|
289
|
+
<Icon name={screen === "products" ? "cart" : "tag"} size="sm" />
|
|
290
|
+
{screen === "products" ? "Shop" : "Products"}
|
|
291
|
+
</Button>
|
|
292
|
+
)}
|
|
293
|
+
{screen === "shop" && (
|
|
294
|
+
<Button size="sm" variant="quiet" onClick={() => document.getElementById("bag")?.scrollIntoView({ block: "nearest" })}>
|
|
295
|
+
<Icon name="cart" size="sm" />
|
|
296
|
+
Bag ({count})
|
|
297
|
+
</Button>
|
|
298
|
+
)}
|
|
299
|
+
</>
|
|
300
|
+
}
|
|
301
|
+
/>
|
|
302
|
+
|
|
303
|
+
{screen === "products" ? (
|
|
304
|
+
<Products products={products} onAdd={() => setView("products")} />
|
|
305
|
+
) : (
|
|
306
|
+
<>
|
|
307
|
+
<Stack gap={2}>
|
|
308
|
+
<Eyebrow>Handmade in small batches</Eyebrow>
|
|
309
|
+
<Heading level={1}>
|
|
310
|
+
Pots for <Highlight tone="orange">everyday</Highlight> things.
|
|
311
|
+
</Heading>
|
|
312
|
+
<Text muted>Free shipping over {money(FREE_SHIPPING, CURRENCY)}. Every piece is thrown and glazed by hand.</Text>
|
|
313
|
+
</Stack>
|
|
314
|
+
|
|
315
|
+
<Row justify="between" align="top">
|
|
316
|
+
<Segmented label="Category" tone="info" value={category} onChange={setCategory} options={FILTERS} />
|
|
317
|
+
<Field label="Search the shop">
|
|
318
|
+
{(id, describedBy) => <Input id={id} describedBy={describedBy} value={query} onChange={setQuery} inputMode="search" placeholder="Mug, vase…" />}
|
|
319
|
+
</Field>
|
|
320
|
+
</Row>
|
|
321
|
+
|
|
322
|
+
<Grid cols="sidebar" gap={5}>
|
|
323
|
+
{forSale.length === 0 ? (
|
|
324
|
+
<Empty icon="sparkle" title="New pieces are on their way">
|
|
325
|
+
The shop opens with its first products. Check back soon.
|
|
326
|
+
</Empty>
|
|
327
|
+
) : visible.length === 0 ? (
|
|
328
|
+
<Empty icon="search" title="Nothing matches">
|
|
329
|
+
Try another word or a different category.
|
|
330
|
+
</Empty>
|
|
331
|
+
) : (
|
|
332
|
+
<Grid cols={2} gap={4}>
|
|
333
|
+
{visible.map((p) => (
|
|
334
|
+
<Card key={p._id}>
|
|
335
|
+
<Stack gap={3}>
|
|
336
|
+
{p._files?.photo?.url ? (
|
|
337
|
+
<Figure src={p._files.photo.url} alt={p.title} width={400} height={300} />
|
|
338
|
+
) : (
|
|
339
|
+
<Row justify="between" align="top">
|
|
340
|
+
<IconTile icon={iconOf(p.category)} tone="orange" />
|
|
341
|
+
{p.badge && <Badge tone="info">{p.badge}</Badge>}
|
|
342
|
+
</Row>
|
|
343
|
+
)}
|
|
344
|
+
<Stack gap={1}>
|
|
345
|
+
<Row justify="between" align="top">
|
|
346
|
+
<Heading level={3}>{p.title}</Heading>
|
|
347
|
+
{p._files?.photo?.url && p.badge && <Badge tone="info">{p.badge}</Badge>}
|
|
348
|
+
</Row>
|
|
349
|
+
{p.blurb && (
|
|
350
|
+
<Text size="sm" muted>
|
|
351
|
+
{p.blurb}
|
|
352
|
+
</Text>
|
|
353
|
+
)}
|
|
354
|
+
</Stack>
|
|
355
|
+
<Row justify="between">
|
|
356
|
+
<Text num>{money(p.amount, p.currency)}</Text>
|
|
357
|
+
<Button size="sm" variant="quiet" onClick={() => change(p._id, 1)}>
|
|
358
|
+
Add to bag
|
|
359
|
+
</Button>
|
|
360
|
+
</Row>
|
|
361
|
+
</Stack>
|
|
362
|
+
</Card>
|
|
363
|
+
))}
|
|
364
|
+
</Grid>
|
|
365
|
+
)}
|
|
366
|
+
|
|
367
|
+
<div id="bag">
|
|
368
|
+
<Stack gap={4}>
|
|
369
|
+
<Card>
|
|
370
|
+
<Stack gap={4}>
|
|
371
|
+
<Row justify="between">
|
|
372
|
+
<Heading level={2}>Your bag</Heading>
|
|
373
|
+
<Text size="sm" muted>
|
|
374
|
+
{plural(count, "item", "items")}
|
|
375
|
+
</Text>
|
|
376
|
+
</Row>
|
|
377
|
+
{lines.length === 0 ? (
|
|
378
|
+
<Empty icon="cart" title="Your bag is empty">
|
|
379
|
+
Add something you love and it waits here.
|
|
380
|
+
</Empty>
|
|
381
|
+
) : (
|
|
382
|
+
<Stack gap={3}>
|
|
383
|
+
{lines.map((l) => (
|
|
384
|
+
<Row key={l.productId} gap={2} wrap={false}>
|
|
385
|
+
<Stack gap={1}>
|
|
386
|
+
<Text truncate>{l.title}</Text>
|
|
387
|
+
<Text size="sm" muted num>
|
|
388
|
+
{money(l.unitAmount * l.qty, CURRENCY)}
|
|
389
|
+
</Text>
|
|
390
|
+
</Stack>
|
|
391
|
+
<Spacer />
|
|
392
|
+
<IconButton size="sm" variant="quiet" icon={<Icon name="remove" size="sm" />} label={`One fewer ${l.title}`} onClick={() => change(l.productId, -1)} />
|
|
393
|
+
<Text num>{l.qty}</Text>
|
|
394
|
+
<IconButton size="sm" variant="quiet" icon={<Icon name="add" size="sm" />} label={`One more ${l.title}`} onClick={() => change(l.productId, 1)} />
|
|
395
|
+
</Row>
|
|
396
|
+
))}
|
|
397
|
+
<Separator />
|
|
398
|
+
<Row justify="between">
|
|
399
|
+
<Text size="sm" muted>
|
|
400
|
+
Subtotal
|
|
401
|
+
</Text>
|
|
402
|
+
<Text size="sm" num>
|
|
403
|
+
{money(subtotal, CURRENCY)}
|
|
404
|
+
</Text>
|
|
405
|
+
</Row>
|
|
406
|
+
<Row justify="between">
|
|
407
|
+
<Text size="sm" muted>
|
|
408
|
+
Shipping
|
|
409
|
+
</Text>
|
|
410
|
+
<Text size="sm" num>
|
|
411
|
+
{shipping === 0 ? "Free" : money(shipping, CURRENCY)}
|
|
412
|
+
</Text>
|
|
413
|
+
</Row>
|
|
414
|
+
<Row justify="between">
|
|
415
|
+
<Text>Total</Text>
|
|
416
|
+
<Text num>{money(subtotal + shipping, CURRENCY)}</Text>
|
|
417
|
+
</Row>
|
|
418
|
+
</Stack>
|
|
419
|
+
)}
|
|
420
|
+
{checkout}
|
|
421
|
+
<Text size="sm" muted>
|
|
422
|
+
We confirm your order and you pay when you collect.
|
|
423
|
+
</Text>
|
|
424
|
+
</Stack>
|
|
425
|
+
</Card>
|
|
426
|
+
|
|
427
|
+
{mine.length > 0 && (
|
|
428
|
+
<Card variant="tight">
|
|
429
|
+
<Stack gap={3}>
|
|
430
|
+
<Heading level={3}>Your orders</Heading>
|
|
431
|
+
{mine.map((o) => (
|
|
432
|
+
<Row key={o._id} justify="between" wrap={false}>
|
|
433
|
+
<Stack gap={1}>
|
|
434
|
+
<Text num>{money(o.total, o.currency ?? CURRENCY)}</Text>
|
|
435
|
+
<Text size="sm" muted>
|
|
436
|
+
{new Date(o.createdAt).toLocaleDateString()} · {plural(o.lines.reduce((n, l) => n + l.qty, 0), "item", "items")}
|
|
437
|
+
</Text>
|
|
438
|
+
</Stack>
|
|
439
|
+
<Badge tone={ORDER_STATUS[o.status]?.tone ?? "info"}>{ORDER_STATUS[o.status]?.label ?? "Received"}</Badge>
|
|
440
|
+
</Row>
|
|
441
|
+
))}
|
|
442
|
+
</Stack>
|
|
443
|
+
</Card>
|
|
444
|
+
)}
|
|
445
|
+
</Stack>
|
|
446
|
+
</div>
|
|
447
|
+
</Grid>
|
|
448
|
+
</>
|
|
449
|
+
)}
|
|
450
|
+
</Stack>
|
|
451
|
+
<div className="ui-toasts">
|
|
452
|
+
<Toaster />
|
|
453
|
+
</div>
|
|
454
|
+
</main>
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## Adapting
|
|
460
|
+
|
|
461
|
+
- The catalogue is records, so a shop with three things and a shop with forty are the same code. It ships empty: example products for a first look go in the app's seed data, which the owner clears, and the owner adds the real ones on **Products**. Swap `CATEGORIES`, `BADGES`, the shipping rule and `CURRENCY` for the shop's own.
|
|
462
|
+
- Product records belong to the owner: `access.js` takes a `product` only from the owner (`ctx.requireRole("owner")`), with an `amount` that is a positive whole number, a three-letter lowercase `currency` and an `onSale` true or false, and puts it on a channel every visitor reads. Keep the `orders` database and the field names `title`, `amount`, `currency` and `onSale`: they are the `stripe` skill's, so its checkout reads these records and prices this bag unchanged.
|
|
463
|
+
- Keep the order a snapshot of titles, unit prices and quantities: an order is a record of what was agreed, so a later price change must not touch it.
|
|
464
|
+
- Orders hold who bought what, so `access.js` and the app's sharing should keep each order between its buyer and the shop: a buyer creates and reads their own, the shop reads them all and moves each through `ORDER_STATUS` behind `can.edit(order)`.
|
|
465
|
+
- Card payment is the `stripe` skill, and it comes in when the person asks to take money: its checkout replaces `Place order` with one `pay(...)` that sends each product and its quantity, `backend.js` prices every line from these records, and the order becomes the one `/checkout` writes. Until then, keep the pay-when-you-collect line truthful, and offer `▸ [pay] Take card payments with Stripe` as the capability option.
|
|
466
|
+
- A new write surface gets its own verdict: `can.create(draft)` with the fields the write stamps, `can.edit(doc)` or `can.delete(doc)` on the document it changes, always on `useVibe` of the database it writes.
|
|
467
|
+
|
|
468
|
+
Adapted from 1st-Pouf (MIT) https://1st-pouf.worksonmy.dev/r/storefront.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-support.js","sourceRoot":"","sources":["../../jsr/llms/ui-support.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,eAAe,GAAc;IACxC,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,+DAA+D;CAC7E,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Support
|
|
2
2
|
|
|
3
3
|
A help desk where questions come in as tickets and get answered, chased and closed: a small shop's customer questions, an IT volunteer queue, a landlord's repair requests, a club's member help. Reach for it whenever the app's core is requests that each carry a status (open, waiting on the asker, solved) and get worked through by replying. Tickets, their status and every reply persist, so the queue is where it was left on the next visit and for everyone working it.
|
|
4
4
|
|
|
5
|
-
Built from @vibes.diy/
|
|
5
|
+
Built from @vibes.diy/ui components; persisted state lives in Fireproof. Every write surface is gated on `useVibe(dbName).can`.
|
|
6
6
|
|
|
7
7
|
## The block
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ Two views, one job each. The queue opens with the `Heading` and a muted count of
|
|
|
13
13
|
import React, { useState } from "react";
|
|
14
14
|
import { useFireproof } from "use-fireproof";
|
|
15
15
|
import { useViewer, useVibe } from "use-vibes";
|
|
16
|
-
import { Badge, Button, Card, Empty, Field, Heading, Icon, IconButton, Input, Row, RowCard, Skeleton, Spacer, Stack, Text, Textarea } from "@vibes.diy/
|
|
17
|
-
import { Checkbox, Dialog, Select, Toaster, toast } from "@vibes.diy/
|
|
16
|
+
import { Badge, Button, Card, Empty, Field, Heading, Icon, IconButton, Input, Row, RowCard, Skeleton, Spacer, Stack, Text, Textarea } from "@vibes.diy/ui";
|
|
17
|
+
import { Checkbox, Dialog, Select, Toaster, toast } from "@vibes.diy/ui/interactive";
|
|
18
18
|
|
|
19
19
|
const STATUS = {
|
|
20
20
|
open: { label: "Open", tone: "info" },
|
|
@@ -313,7 +313,7 @@ export default function App() {
|
|
|
313
313
|
)}
|
|
314
314
|
</Stack>
|
|
315
315
|
)}
|
|
316
|
-
<div className="
|
|
316
|
+
<div className="ui-toasts">
|
|
317
317
|
<Toaster />
|
|
318
318
|
</div>
|
|
319
319
|
</main>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const uiTestimonialsConfig = {
|
|
2
|
+
name: "ui-testimonials",
|
|
3
|
+
aliases: ["pouf-testimonials"],
|
|
4
|
+
label: "Testimonials block",
|
|
5
|
+
description: "Testimonials section with category filter, story carousel and reported outcomes",
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=ui-testimonials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-testimonials.js","sourceRoot":"","sources":["../../jsr/llms/ui-testimonials.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAc;IAC7C,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EAAE,iFAAiF;CAC/F,CAAC"}
|