@faslet/react-widget

中文文档
0.4.0发布于 2024/11/04MITTypeScriptCommonJS零依赖近 30 天下载 9329

The Faslet Size Me Up widget for eCommerce platforms

原始使用文档
文档目录3 节
  1. Usage
  2. Examples
  3. Development

Faslet React Widget

Usage

To use this component in your app, pull down this component with

npm install @faslet/react-widget

Widget (Product page)

Example usage with shop id Faslet Demo

import { FasletWidget } from '@faslet/react-widget';

function ExampleProductPage() {

    // Get the product variants and colors
    const colors = [{ id: 'red', name: 'Magnificent Red'},{ id: 'blue', name: 'Dashing Blue'}];
    const variants = [
        {variantId: 'variant-1', sizeLabel: 'S', inStock: true, sku: 'sku-1', colorId: 'red', price: 11.99, imageUrl: 'https://placekitten.com/300/500' },
        {variantId: 'variant-2', sizeLabel: 'S', inStock: true, sku: 'sku-2', colorId: 'blue', price: 11.99, imageUrl: 'https://placekitten.com/300/500' },
        {variantId: 'variant-3', sizeLabel: 'M', inStock: true, sku: 'sku-3', colorId: 'red', price: 11.99, imageUrl: 'https://placekitten.com/300/500' },
        {variantId: 'variant-4', sizeLabel: 'M', inStock: false, sku: 'sku-4', colorId: 'blue', price: 11.99, imageUrl: 'https://placekitten.com/300/500' },
        {variantId: 'variant-5', sizeLabel: 'L', inStock: false, sku: 'sku-5', colorId: 'red', price: 11.99, imageUrl: 'https://placekitten.com/300/500' },
        {variantId: 'variant-6', sizeLabel: 'L', inStock: false, sku: 'sku-6', colorId: 'blue', price: 11.99, imageUrl: 'https://placekitten.com/300/500' }
    ];
    
    // Render the widget
    return  (
        <>
            <FasletWidget
                productId="product-1"
                shopId="Faslet Demo"
                brandId="Faslet Demo Brand"
                productImageUrl="https://placekitten.com/100/150"
                productName="Jacket"
                colors={colors}
                variants={variants}
                onAddToCart={addToCart}
                onResult={handleResult}
            />
        </>
    );
}


Order Tracking (After checkout/Thank You page)

Example usage with shop id Faslet Demo

import { useFasletOrderTracking } from '@faslet/react-widget';

export function ExampleThankYouPage() {
    const productsInOrder = [
        {
            productId: 'product-1',
            variantId: 'variant-1',
            productName: 'Jacket',
            variantName: 'Red Jacket/S',
            priceTimesQuantity: 100,
            quantity: 1,
            sku: 'sku-1'
        }, {
            productId: 'product-1',
            variantId: 'variant-2',
            productName: 'Jacket',
            variantName: 'Blue Jacket/S',
            priceTimesQuantity: 200,
            quantity: 2,
            sku: 'sku-2'
        }
    ];

    useFasletOrderTracking('Faslet Demo', 'Order-1', 'paid', productsInOrder)

    return (<p>Thank you for your order!</p>);
}

Examples

The examples are built with Create-React-App. From the examples folder:

npm install
npm start

And then in your browser, navigate to:

http://localhost:3000/

for the Widget example and

http://localhost:3000/thank-you

for the Order Tracking example. Note that Order tracking only sends events, which you would see in the network tab of your browser's dev-tools.

Development

This project uses npm. First run install before starting development:

npm install

版本与发布记录

@faslet/react-widget 共发布 10 个版本,首次发布于 2022/03/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.0latest2024/11/042 年前
0.3.02024/07/222 年前
0.2.22024/07/092 年前
0.2.12022/10/264 年前
0.2.02022/09/154 年前
0.1.02022/03/104 年前

关于 @faslet/react-widget 的常见问题

@faslet/react-widget 是什么?

The Faslet Size Me Up widget for eCommerce platforms

如何安装 @faslet/react-widget?

在项目目录运行 npm install @faslet/react-widget,或使用 pnpm add / yarn add / bun add。

@faslet/react-widget 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@faslet/react-widget 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@faslet/react-widget 可以商用吗?

@faslet/react-widget 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@faslet/react-widget 的下载量有多少?

根据 npm 官方下载统计,@faslet/react-widget 在 2026/10/15 – 2026/11/13 这 30 天内被下载 9,329 次,日均约 311 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@faslet/react-widget 还在维护吗?

最新版本 0.4.0 发布于 2024/11/04(2 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。