@souldi/try-on 0.1.94 → 0.3.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 +34 -12
- package/dist/widget.mjs +1 -1
- package/dist/widget.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,13 +61,26 @@ The result surface is the widget's and only the widget's: an accessible
|
|
|
61
61
|
`<dialog>` inside an isolated Shadow DOM, appended to `<body>`. It reads none of
|
|
62
62
|
your CSS selectors and never touches your product images, so a theme change
|
|
63
63
|
cannot break it — and there is nothing to point it at. It is also where the
|
|
64
|
-
customer decides
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
customer decides. It has two screens:
|
|
65
|
+
|
|
66
|
+
- **Try-on** — the render, beside the customer's size (when the garment has a
|
|
67
|
+
size chart), an **Add size X to cart** button (when you supply
|
|
68
|
+
[`onAddToCart`](#onaddtocart)), Refine, and the garment's back view when
|
|
69
|
+
there is one.
|
|
70
|
+
- **Size** — "How size X sits on you": the same size and cart button beside a
|
|
71
|
+
mannequin showing how that size fits the customer's body, and a **Try on**
|
|
72
|
+
button (or **View try-on**, once a result exists).
|
|
73
|
+
|
|
74
|
+
The dialog can open on **Size** before any try-on has been generated — the
|
|
75
|
+
size comes from the customer's measurements, not from a render — so the size
|
|
76
|
+
shown on the try-on button opens it, before and after a try-on. The ruler
|
|
77
|
+
shown on the button before a size exists is a way into sizing: it signs the
|
|
78
|
+
customer in and takes them to their size, or to their profile when no size is
|
|
79
|
+
ready yet. Neither ever starts a try-on. **Your profile** (retake the photo,
|
|
80
|
+
edit measurements, sign out) opens from inside the dialog. The dialog can be
|
|
81
|
+
reopened after closing; the try-on button becomes **View try-on** once a result
|
|
82
|
+
exists, and the button's size, the dialog's size and the cart button always
|
|
83
|
+
name the same size — a measurement edit updates all of them at once.
|
|
71
84
|
|
|
72
85
|
Everything optional is simply absent when it does not apply — no size, no
|
|
73
86
|
cart button, no fit detail on a garment without a chart — and nothing is
|
|
@@ -102,7 +115,8 @@ Callbacks about a specific try-on receive a trailing `info` object:
|
|
|
102
115
|
| Field | Type | Present on | Description |
|
|
103
116
|
|-------|------|-----------|-------------|
|
|
104
117
|
| `buttonId` | `string` | most | The `containerId` of the button this callback is about |
|
|
105
|
-
| `operation` | `'generate' \| 'refine'` | `onError`, `onResultShown` | Which operation this is about |
|
|
118
|
+
| `operation` | `'generate' \| 'refine' \| 'view'` | `onError`, `onResultShown` | Which operation this is about |
|
|
119
|
+
| `shownInResult` | `boolean` | `onError` | `true` when the widget has already said this inside its open dialog, under the result it failed to change — so you need not say it again |
|
|
106
120
|
| `view` | `string \| null` | `onGenerationSuccess`, `onResultShown` | The Render View this result is (e.g. `'front'`), when the garment offers more than one |
|
|
107
121
|
| `how` | `'verified' \| 'shared' \| 'restored'` | `onSignedIn` | How this tab's session began. Only `'verified'` is a *new* sign-in — `'shared'` and `'restored'` are this tab catching up with a session that began elsewhere |
|
|
108
122
|
| `resolution` | `string` | `onPhotoReady` | The preprocessing outcome, e.g. `'clean'` or `'soft-issue'` |
|
|
@@ -118,8 +132,9 @@ and `onError(message)` keep working unchanged.
|
|
|
118
132
|
Note that `onError` with `operation: 'refine'` also covers a refine the widget
|
|
119
133
|
*declined* — only the most recently generated result can be refined, so a
|
|
120
134
|
request against an older one is reported here rather than silently dropped.
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
The previous result is untouched either way. A failed `refine` or `view` with
|
|
136
|
+
the dialog open is already shown in it (`shownInResult: true`); with the dialog
|
|
137
|
+
closed, it is yours to show if you want the customer to see it.
|
|
123
138
|
|
|
124
139
|
`onResultShown` receives the same `info` `onGenerationSuccess` did for that
|
|
125
140
|
result, minus the image URL — it is about the same render, just reported once
|
|
@@ -150,8 +165,8 @@ address, or body measurements.
|
|
|
150
165
|
#### `onAddToCart`
|
|
151
166
|
|
|
152
167
|
The widget knows a customer's size; only you know your cart. Supply
|
|
153
|
-
`onAddToCart` and the
|
|
154
|
-
|
|
168
|
+
`onAddToCart` and the dialog draws an **Add size X to cart** button on both its
|
|
169
|
+
screens. Leave it out and there is no cart control at all.
|
|
155
170
|
|
|
156
171
|
It is called with one `intent` and must **resolve** (never reject) to an
|
|
157
172
|
outcome:
|
|
@@ -192,6 +207,13 @@ Add a try-on button for a specific garment. Call once per product on the page.
|
|
|
192
207
|
| `garmentUrl` | `string` | Yes | Public URL of the garment image |
|
|
193
208
|
| `internalId` | `string` | No | Your internal/vendor id for this garment; correlated server-side |
|
|
194
209
|
|
|
210
|
+
It returns a handle for that button. Among its methods:
|
|
211
|
+
|
|
212
|
+
| Method | Description |
|
|
213
|
+
|--------|-------------|
|
|
214
|
+
| `setGarment(garmentUrl, internalId?)` | Point the button at another garment — a colour switch. The button's previous result is forgotten; a try-on still running for the previous garment is shown when it lands. |
|
|
215
|
+
| `openSize()` | Open the dialog on the customer's size, exactly as the size on the button does — for a "check your size" control of your own. Does nothing while the button has no size to show. |
|
|
216
|
+
|
|
195
217
|
> **Removed in 0.2.0:** `targetImageId`. It named an `<img>` on your page for the
|
|
196
218
|
> widget to overwrite with the result, and it is gone — the widget shows every
|
|
197
219
|
> result in its own dialog instead (see [How It Works](#how-it-works)). Passing
|