@souldi/try-on 0.5.1 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -8,6 +8,9 @@
8
8
  - **Removed: the size screen.** "How size X sits on you" and its 3D mannequin are gone from the dialog, and the size in the dialog is no longer a button. The mannequin's standalone build is still published, for older bundles that load it.
9
9
  - **Removed: Refine.** The dialog has no Refine control, and the button handle's `refine()` is gone. `onError` no longer reports `operation: 'refine'`, and `onGenerationSuccess` / `onResultShown` no longer carry `refinable`. Refine stays in the Souldi API; the widget never sends a `refinement_prompt`.
10
10
  - `openSize()` on the button handle still opens the dialog on the customer's size. Before a try-on it now shows the garment and **Try on** there.
11
+ - **New: between two sizes, the customer picks.** When the customer is between two neighbouring sizes, the dialog shows "Your size: between M and L" with two options, M for a closer fit and L for a looser one, the recommended one preselected, and "Both will fit you." under them. **Add size X to cart** follows the choice; a new recommendation (edited measurements, another colour) resets it. Shown only where there is a cart button; otherwise the dialog names one size and gives the same advice in words. A customer whose second size is not a neighbour still sees one size, now captioned "This one is harder to call." alone (it used to follow "From your measurements.").
12
+ - **`onAddToCart` gains `recommendedSize` and `recommendationId`** beside `size`, which is the size the customer chose. Additive: a handler that reads `size` alone keeps working. See [`onAddToCart`](README.md#onaddtocart).
13
+ - **Edit my profile.** The customer's profile opens from a row at the foot of the dialog, on every state, instead of a button on the picture. It shows their photo and measurements, and they edit the measurements there, in place: **Edit measurements** turns the list into fields, and **Save changes** updates the size on the button and in the dialog without closing it. Leaving with unsaved changes asks first. The add-your-weight prompt under the size opens it on the missing field. The separate "Your Souldi." window no longer edits measurements; it stays reachable from **Account settings** for the photo choice and deleting the account.
11
14
 
12
15
  ## 0.5.0
13
16
 
package/README.md CHANGED
@@ -77,8 +77,10 @@ from the customer's measurements, not from a render — so the size shown on
77
77
  the try-on button opens it, before and after a try-on. The ruler
78
78
  shown on the button before a size exists is a way into sizing: it signs the
79
79
  customer in and takes them to their size, or to their profile when no size is
80
- ready yet. Neither ever starts a try-on. **Your profile** (retake the photo,
81
- edit measurements, sign out) opens from inside the dialog. The dialog can be
80
+ ready yet. Neither ever starts a try-on. **Edit my profile**, at the foot of
81
+ the dialog, shows the customer's photo and measurements; they edit the
82
+ measurements there, in place, without leaving the dialog, and retake the
83
+ photo or sign out from it too. The dialog can be
82
84
  reopened after closing; the try-on button becomes **View try-on** once a result
83
85
  exists, and the button's size, the dialog's size and the cart button always
84
86
  name the same size — a measurement edit updates all of them at once.
@@ -165,17 +167,29 @@ address, or body measurements.
165
167
  #### `onAddToCart`
166
168
 
167
169
  The widget knows a customer's size; only you know your cart. Supply
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.
170
+ `onAddToCart` and the dialog draws an **Add size X to cart** button under the
171
+ customer's size. Leave it out and there is no cart control at all.
172
+
173
+ When the customer is between two neighbouring sizes, the dialog says so ("Your
174
+ size: between M and L") and lets them pick which one goes in the cart: the
175
+ smaller for a closer fit, the larger for a looser one, with the recommended size
176
+ preselected. The button follows their choice, and any new recommendation (edited
177
+ measurements, another colour) resets it. Without `onAddToCart` there is nothing
178
+ to pick for, so the dialog shows the one recommended size and says the same
179
+ advice in words.
170
180
 
171
181
  It is called with one `intent` and must **resolve** (never reject) to an
172
182
  outcome:
173
183
 
174
184
  ```js
175
- onAddToCart: async ({ buttonId, size, sizeRun }) => {
176
- // buttonId — the containerId of the button this is about
177
- // size — the size the customer chose, e.g. "M"
178
- // sizeRun — every size the garment's chart offers, e.g. ["S", "M", "L"]
185
+ onAddToCart: async ({ buttonId, size, sizeRun, recommendedSize, recommendationId }) => {
186
+ // buttonId — the containerId of the button this is about
187
+ // size — the size to add: the customer's choice, e.g. "L"
188
+ // sizeRun — every size the garment's chart offers, e.g. ["S", "M", "L"]
189
+ // recommendedSize — the size the widget recommended, e.g. "M". It differs
190
+ // from `size` only when the customer picked the other of
191
+ // two neighbouring sizes
192
+ // recommendationId — the id of the recommendation on screen, or null
179
193
  const variant = resolveVariant(buttonId, size);
180
194
  if (!variant) return { ok: false, message: 'That size is not available in this colour.' };
181
195
  await addLineToCart(variant.id);
@@ -191,6 +205,13 @@ onAddToCart: async ({ buttonId, size, sizeRun }) => {
191
205
  | `quantity` | `ok: true` | Optional. How many of this line the cart now holds, for a repeat add |
192
206
  | `notice` | `ok: true` | Optional. A caveat when the add was adjusted on the way in (short stock, a cart limit) |
193
207
 
208
+ `recommendedSize` and `recommendationId` are new in this release, and only
209
+ added beside the fields you already read. A handler that reads `size` alone
210
+ keeps working and adds what the customer chose. Keep `recommendationId` with the
211
+ line item if you want to match a purchase to the recommendation behind it. The
212
+ widget records each recommendation in the background and nothing waits for
213
+ that record, so it may arrive after the add or not at all.
214
+
194
215
  Two rules the widget keeps for you: nothing is stated in the past tense until
195
216
  you have resolved `{ ok: true }`, and nothing reaches your handler without a
196
217
  click on the button — opening the dialog, a new result landing, and changing