@wristfit/react
v0.1.1
Published
React component for Wristfit's watch try-on: the shopper's own wrist, the watch on it at its true size
Maintainers
Readme
@wristfit/react
Wristfit's watch try-on as a React component: the shopper sets their wrist size, a 3D arm is built to it, and the watch goes on it at its true size, with how it fits ("good fit", "bold", …).
The try-on itself is served by Wristfit, so fixes and new features reach your site without a package update. This package loads its script and gives it a typed React API.
npm install @wristfit/reactimport { WristfitTryOn } from "@wristfit/react";
<WristfitTryOn
watch={{
image: "/images/watch-front.jpg", // an <img>, a canvas, a Blob or an address on your own site
diameterMm: 40,
lugToLugMm: 47, // where you know them; measured or estimated otherwise
thicknessMm: 11.2,
dialMm: 33, // a round dial's opening, inside the bezel
strap: "metal",
clasp: { kind: "folding" },
}}
onFit={fit => console.log(fit.verdict, fit.lugToLugMm)}
/>The picture is the watch front-on on a plain background, crown at 3 o'clock, as shops photograph them. It is read on
your page's side (Wristfit's frame can't read another site's pictures) and sent to the try-on as image data; nothing is
stored. Pass a new watch object to show another watch (memoise it so a re-render doesn't resend it), and wristMm
when your page knows the shopper's wrist.
Without React, load the script and mount it:
<script src="https://wristfit-app.vercel.app/widget.js"></script>
<div id="try-on"></div>
<script>
Wristfit.mount("#try-on", { watch: { image: document.querySelector("#product-photo"), diameterMm: 40 } });
</script>or in one line, after the product photo:
<script src="https://wristfit-app.vercel.app/widget.js" data-image="#product-photo" data-diameter="40" data-strap="metal" async></script>(data-lug-to-lug, data-thickness, data-lug-width and data-dial take the other sizes in mm.)
Events: ready, fit and error, as callbacks and as bubbling DOM events (wristfit:fit, …) on the element it is
mounted in.
