npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@anker-in/campaign-ui

v0.5.22

Published

Campaign UI components and utilities for Anker projects

Readme

@anker-in/campaign-ui

Anker 营销活动页(Campaign)React 组件库,内置积分(Credits)、会员弹窗(MemberPopup)、注册验证(Registration)、AI 对话(Chat / LiveChatWidget)等能力,配套 Shopify/Headless 数据层封装(src/lib)。

本仓库已从 headless-ui monorepo 中独立拆出,不再依赖 workspace,作为单独的包仓库维护和发布。

安装

pnpm add @anker-in/campaign-ui

需要同时安装 peer 依赖:

pnpm add @anker-in/headless-ui crypto-js

目录结构

src/
  components/   业务组件:credits / registration / memberPopup / chat / LiveChatWidget
  templates/    页面级模板:Credits
  lib/          Shopify、购物车、注册等数据层封装(原 @anker-in/lib,现作为源码依赖内置)
  styles/       全局及各组件样式(global.css / chat.css / livechat.css)

快速上手

Chat 组件

// 添加默认样式文件(不添加则是完全无样式组件)
import '@anker-in/campaign-ui/chat.css'

import { Chat } from '@anker-in/campaign-ui'

<Chat
  title="Chat title"
  runtimeUrl="https://xxx.xxx.com"
  shopify_domain="xxx.myshopify.com"
/>

LiveChatWidget 组件

import { LiveChatWidget } from '@anker-in/campaign-ui'
import '@anker-in/campaign-ui/livechat.css'

<LiveChatWidget
  apiBaseUrl="https://beta-api-livechat.anker.com"
  site="www.eufy.com"
  channel_code="web_homepage"
  welcomeMessage="你好!我是 AI 助手"
/>

支持自定义渲染器、品牌色、Logo 等,详见组件内 Storybook 文档(src/stories/LiveChatWidget.stories.tsx)。

Credits(积分)

import { CreditsProvider, CreditsBanner, CreditsBenefits, CreditsRedeemList } from '@anker-in/campaign-ui'

也可直接使用页面级模板:

import { Credits } from '@anker-in/campaign-ui'

MemberPopup(会员弹窗)/ Registration(注册验证)

import { MemberPopup, useMemberPopupContext } from '@anker-in/campaign-ui'
import { useRegistration } from '@anker-in/campaign-ui'

productCardRender 自定义产品卡片渲染

详见 PRODUCTCARDRENDER_GUIDE.md

Tailwind 配置

组件内部使用 cmp- 前缀的 Tailwind class(避免与宿主项目冲突),需要在宿主项目 Tailwind 配置中合并本包的 preset:

// tailwind.config.ts
import campaignUiPreset from '@anker-in/campaign-ui/tailwind.config'

export default {
  presets: [campaignUiPreset],
  // ...
}

本地开发

pnpm install

pnpm run dev          # tsup watch + css watch
pnpm run build        # 构建 ESM/CJS + 类型声明 + CSS
pnpm run type-check    # tsc --noEmit
pnpm run lint          # eslint(不含 src/lib)

发布

pnpm run build
npm publish