@base44/app-plugin-commerce 0.4.1 → 0.5.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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/skills/commerce/SKILL.md +12 -10
- package/skills/commerce/install/02-storefront.md +74 -98
- package/skills/commerce/references/storefront-custom.md +1 -1
- package/skills/commerce/references/storefront-parts.md +184 -0
- package/src/commerce/storefront/cartUI.jsx +63 -17
- package/src/commerce/storefront/index.js +1 -1
- package/src/commerce/storefront/parts/cart.jsx +64 -40
- package/src/commerce/storefront/parts/checkout.jsx +91 -55
- package/src/commerce/storefront/parts/drawer.jsx +35 -67
- package/src/commerce/storefront/parts/orderReceived.jsx +24 -12
- package/src/commerce/storefront/parts/parts.css +12 -29
- package/src/commerce/storefront/parts/shared.jsx +31 -21
- package/src/commerce/storefront/parts/visibility.js +36 -0
- package/src/commerce/storefront/useCheckout.jsx +27 -0
- package/skills/commerce/references/storefront-styling.md +0 -99
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
read_when: "You are writing the CSS for the cart, drawer, checkout or receipt — the parts' look."
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Styling the parts
|
|
6
|
-
|
|
7
|
-
The parts ship **layout geometry and nothing else** (`src/commerce/storefront/parts/parts.css`,
|
|
8
|
-
loaded automatically by `@/commerce/storefront`): field grids, labels above
|
|
9
|
-
full-width controls, media as a fixed square, rows as media + content +
|
|
10
|
-
controls with the money pushed right, totals as label-left/value-right, the
|
|
11
|
-
drawer as a right-hand panel over a full-viewport overlay. Nothing in it
|
|
12
|
-
carries color, background, border, radius, shadow, font or text decoration — a
|
|
13
|
-
release check enforces that — so an unstyled store reads as *unfinished*, never
|
|
14
|
-
as broken, and the look is entirely yours.
|
|
15
|
-
|
|
16
|
-
**Every rule is wrapped in `:where()`, so its specificity is 0.** A plain
|
|
17
|
-
`[data-part="row"] { display: grid }` in your stylesheet wins — no `!important`,
|
|
18
|
-
no cascade fights, no need to know what the sheet did.
|
|
19
|
-
|
|
20
|
-
## Two ways in, one vocabulary
|
|
21
|
-
|
|
22
|
-
```css
|
|
23
|
-
/* index.css — selectors, next to the store's design classes */
|
|
24
|
-
[data-part="control"] { … }
|
|
25
|
-
[data-part="option"][data-state="selected"] { … }
|
|
26
|
-
[data-part="row"][data-pending] { opacity: .55; }
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
```jsx
|
|
30
|
-
{/* or classes, keyed by the same data-part names */}
|
|
31
|
-
<Cart.Lines className="bag" classes={{ row: "bag-row", media: "bag-thumb", "line-total": "price" }} />
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Tailwind reaches inner parts with arbitrary variants
|
|
35
|
-
(`className="[&_[data-part=option]]:choice-row"`) or `@apply` inside a design
|
|
36
|
-
class. Either way the names are the ones below.
|
|
37
|
-
|
|
38
|
-
## The minimum that makes a store look designed
|
|
39
|
-
|
|
40
|
-
⚑ **Style the controls.** Browser-default inputs are a white box in a system
|
|
41
|
-
font — on a dark or branded storefront that alone reads as unfinished:
|
|
42
|
-
|
|
43
|
-
```css
|
|
44
|
-
[data-part="control"], [data-part="input"] {
|
|
45
|
-
border: …; background: …; color: inherit; font: inherit; padding: …;
|
|
46
|
-
}
|
|
47
|
-
[data-part="control"]:focus-visible { outline: …; } /* keep a visible focus ring */
|
|
48
|
-
[data-part="field"][data-invalid] [data-part="control"] { border-color: …; }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Then, in the store's own values: the labels (`[data-part="label"]` — size,
|
|
52
|
-
tracking, case), the option rows (`[data-part="option"]` — padding, border,
|
|
53
|
-
and the `[data-state="selected"]` treatment, which is the one control customers
|
|
54
|
-
look for), the totals (`[data-part="value"]`, `[data-emphasis]` for the total
|
|
55
|
-
line), the buttons (`[data-part="place-order"]`, `apply`, `remove`,
|
|
56
|
-
`increase`/`decrease`), the notices (`[data-part="error"]`, `blocker`, `hint` —
|
|
57
|
-
`[data-severity="error"]` marks the loud ones), and the drawer surface
|
|
58
|
-
(`[data-part="panel"]` needs a background of its own, `[data-part="overlay"]` a
|
|
59
|
-
scrim).
|
|
60
|
-
|
|
61
|
-
**The parts add no outer margins** — space *between* sections comes from the
|
|
62
|
-
containers you wrap them in (`gap` on your checkout grid, your aside, your
|
|
63
|
-
drawer panel's column).
|
|
64
|
-
|
|
65
|
-
## Tuning the built-in geometry
|
|
66
|
-
|
|
67
|
-
Set these anywhere — `:root`, a page, one part — instead of rewriting the rules:
|
|
68
|
-
|
|
69
|
-
| Custom property | Default | Controls |
|
|
70
|
-
|---|---|---|
|
|
71
|
-
| `--commerce-gap` | `1rem` | fields, rows, options, panel sections |
|
|
72
|
-
| `--commerce-gap-tight` | `0.4rem` | label→control, name→attributes, stepper |
|
|
73
|
-
| `--commerce-field-columns` | `2` | address-form columns (set `1` in a narrow aside or a media query) |
|
|
74
|
-
| `--commerce-media-size` | `4rem` | cart/summary thumbnail edge |
|
|
75
|
-
| `--commerce-drawer-width` | `28rem` | drawer panel width |
|
|
76
|
-
| `--commerce-drawer-z` | `50` | drawer stacking order (raise above a sticky header) |
|
|
77
|
-
|
|
78
|
-
## `data-part` inventory
|
|
79
|
-
|
|
80
|
-
| Part root | Inner `data-part`s | State attributes |
|
|
81
|
-
|---|---|---|
|
|
82
|
-
| `address-fields`; `ship-to-different` | field · label · required · control · error | `data-which`, `data-key`, `data-span`, `data-invalid` |
|
|
83
|
-
| `shipping-methods` `payment-methods` | hint · option · option-input · option-label · option-cost / option-description · chosen | `data-state="selected"`, `data-syncing`, `data-severity` |
|
|
84
|
-
| `lines` `items`; `notices` | row · media · content · name · attributes · controls · stepper · increase · decrease · quantity · remove · line-total · error; notice | `data-pending`, `data-empty`, `data-code` |
|
|
85
|
-
| `totals`; `payment-instructions` | row · label · value; description · account | `data-key`, `data-emphasis` |
|
|
86
|
-
| `coupon-field` | input · apply · error · applied · code · remove | `data-busy` |
|
|
87
|
-
| `place-order` · `order-error` · `blockers` | blocker | `data-state="placing"`, `data-code` |
|
|
88
|
-
| `trigger` · `drawer` | overlay · panel; `close` | `data-state="open\|closed"` |
|
|
89
|
-
|
|
90
|
-
`media` is an `<img>` when the line has an image and an empty `<div
|
|
91
|
-
data-part="media" data-empty>` when it doesn't — same box either way, so style
|
|
92
|
-
the placeholder (`[data-empty]`) rather than letting it render as a hole.
|
|
93
|
-
|
|
94
|
-
## When CSS isn't enough
|
|
95
|
-
|
|
96
|
-
A control that needs different markup takes the part's render override
|
|
97
|
-
(`inputRender`, `optionRender`, `lineRender`, `itemRender`, `fieldRender`) —
|
|
98
|
-
your element, the part's wiring. A whole section that needs different structure
|
|
99
|
-
drops to its hook: [`./storefront-custom.md`](./storefront-custom.md).
|