cos-design 3.7.3 → 3.7.5
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 +46 -0
- package/README.md +66 -20
- package/dist/index.cjs +3 -3
- package/dist/index.js +2353 -2085
- package/dist/src/components/charge/index.d.ts +2 -0
- package/dist/src/components/confetti/index.d.ts +4 -0
- package/dist/src/components/fireworks/index.d.ts +4 -0
- package/dist/src/components/index.d.ts +4 -4
- package/dist/src/components/matrixRain/index.d.ts +2 -0
- package/dist/src/components/particleNetwork/index.d.ts +2 -0
- package/dist/src/components/photoAlbum/types.d.ts +2 -0
- package/dist/src/components/photoCarousel/types.d.ts +3 -1
- package/dist/src/components/photoClothesline/types.d.ts +2 -0
- package/dist/src/components/photoLantern/types.d.ts +2 -0
- package/dist/src/components/redPacketRain/index.d.ts +19 -1
- package/dist/src/components/scratchCard/index.d.ts +9 -1
- package/dist/src/components/slotMachine/index.d.ts +11 -1
- package/dist/src/components/turntable/index.d.ts +9 -1
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.7.5] - 2026-08-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `@cos-design/shared`:新增 `useElementSize` / `resolveCanvasBoxSize`(React peer)
|
|
13
|
+
- Canvas 组件支持 `fill` 铺满父容器:`Fireworks`、`Confetti`、`RedPacketRain`、`MatrixRain`、`ParticleNetwork`
|
|
14
|
+
- Playground 活动配方新增:充电开宝箱、老虎机大奖
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- QUICKSTART / README / AGENTS 补充 `fill` 尺寸用法说明
|
|
19
|
+
- @cos-design/shared: 3.5.4 → 3.5.5
|
|
20
|
+
- @cos-design/confetti: 3.5.4 → 3.5.5
|
|
21
|
+
- @cos-design/fireworks: 3.5.4 → 3.5.5
|
|
22
|
+
- @cos-design/matrix-rain: 3.5.3 → 3.5.4
|
|
23
|
+
- @cos-design/particle-network: 3.5.3 → 3.5.4
|
|
24
|
+
- @cos-design/red-packet-rain: 3.5.4 → 3.5.5
|
|
25
|
+
- cos-design: 聚合包更新至 3.7.5
|
|
26
|
+
|
|
27
|
+
## [3.7.4] - 2026-08-10
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- `@cos-design/shared`:补齐 `prefersReducedMotion` / `bindPrefersReducedMotion`、`observeElementSize`、`getRelativePointerPosition`,以及 `PhotoItem` / 索引回调类型
|
|
32
|
+
- 营销组件命令式 Handle 与服务端开奖能力:`Turntable`(`spin`/`reset`/`targetIndex`)、`SlotMachine`(`spin`/`reset`/`targetResults`/`buttonText`)、`ScratchCard`(`reset`/`reveal`/`revealThreshold`)、`RedPacketRain`(`start`/`stop`/`reset`/`width`/`height`/`onEnd`/`auto`)
|
|
33
|
+
- `Charge.onComplete`;`Fireworks` / `Confetti` 的 `onComplete`;Photo 旗舰统一 `onIndexChange` 别名(Album / Lantern / Clothesline / Carousel)
|
|
34
|
+
- Playground「活动配方」页:刮开庆祝、倒计时红包雨、转盘彩纸
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- `Fireworks` / `Confetti` / `RedPacketRain` 改用 pointer 事件,并接入 reduced-motion 降级
|
|
39
|
+
- README / QUICKSTART 组件数量与分类同步为 84 个 · 9 类
|
|
40
|
+
- @cos-design/shared: 3.5.3 → 3.5.4
|
|
41
|
+
- @cos-design/charge: 3.5.3 → 3.5.4
|
|
42
|
+
- @cos-design/confetti: 3.5.3 → 3.5.4
|
|
43
|
+
- @cos-design/fireworks: 3.5.3 → 3.5.4
|
|
44
|
+
- @cos-design/photo-album: 3.7.1 → 3.7.2
|
|
45
|
+
- @cos-design/photo-carousel: 3.7.3 → 3.7.4
|
|
46
|
+
- @cos-design/photo-clothesline: 3.7.3 → 3.7.4
|
|
47
|
+
- @cos-design/photo-lantern: 3.7.3 → 3.7.4
|
|
48
|
+
- @cos-design/red-packet-rain: 3.5.3 → 3.5.4
|
|
49
|
+
- @cos-design/scratch-card: 3.5.3 → 3.5.4
|
|
50
|
+
- @cos-design/slot-machine: 3.5.4 → 3.5.5
|
|
51
|
+
- @cos-design/turntable: 3.5.4 → 3.5.5
|
|
52
|
+
- cos-design: 聚合包更新至 3.7.4
|
|
53
|
+
|
|
8
54
|
## [3.7.3] - 2026-08-03
|
|
9
55
|
|
|
10
56
|
### Added
|
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# cos-design
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**84 React visual-effect components** for marketing pages, brand landings, and creative showcases
|
|
6
|
+
**84 个 React 视觉特效组件 · 活动页 / 品牌页 / 创意展示开箱即用**
|
|
6
7
|
|
|
7
8
|
[](https://github.com/jiaxiantao/cos-design/actions/workflows/ci.yml)
|
|
8
9
|
[](https://www.npmjs.com/package/cos-design)
|
|
@@ -10,12 +11,44 @@
|
|
|
10
11
|
[](https://react.dev/)
|
|
11
12
|
[](https://www.typescriptlang.org/)
|
|
12
13
|
|
|
13
|
-
[
|
|
14
|
+
[Playground](https://jiaxiantao.github.io/cos-design/) · [Quickstart](./QUICKSTART.md) · [llms.txt](https://jiaxiantao.github.io/cos-design/llms.txt) · [AI discovery](./docs/ai-discovery.md) · [EN guide](./website-content/cos-design-marketing-effects-en.md) · [中文指南](./website-content/cos-design-intro.md) · [Changelog](./CHANGELOG.md)
|
|
14
15
|
|
|
15
16
|
</div>
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
20
|
+
## English (for developers & AI agents)
|
|
21
|
+
|
|
22
|
+
**cos-design** is a React library of **visual effects** — fireworks, scratch cards, weather/matrix backgrounds, neon headlines, flip counters — not a general admin UI kit.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add cos-design
|
|
26
|
+
# or smaller per-component packages:
|
|
27
|
+
pnpm add @cos-design/fireworks @cos-design/scratch-card @cos-design/weather-background
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Fireworks } from '@cos-design/fireworks';
|
|
32
|
+
import { ScratchCard } from '@cos-design/scratch-card';
|
|
33
|
+
|
|
34
|
+
export function Campaign() {
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<ScratchCard prize="50% OFF" width={320} height={200} />
|
|
38
|
+
<Fireworks width={800} height={500} />
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- **Use for:** campaign / lottery / celebration UI, canvas backgrounds, animated headlines, dashboard decorations
|
|
45
|
+
- **Do not use for:** tables, forms, nav shells → use Ant Design / shadcn / MUI
|
|
46
|
+
- **AI index:** https://jiaxiantao.github.io/cos-design/llms.txt · **Context7:** `/jiaxiantao/cos-design`
|
|
47
|
+
- **Cursor Skill install:** see [docs/ai-discovery.md](./docs/ai-discovery.md)
|
|
48
|
+
- **Article:** [React marketing page effects with cos-design](./website-content/cos-design-marketing-effects-en.md)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
19
52
|
## 这是什么?
|
|
20
53
|
|
|
21
54
|
**cos-design** 是一个面向**视觉表达**的 React 组件库——专注特效与氛围,给页面加趣味、加记忆点的「特效层」。
|
|
@@ -76,36 +109,49 @@ export default function Page() {
|
|
|
76
109
|
|
|
77
110
|
让 AI 在写活动页、特效背景时自动选用本库:
|
|
78
111
|
|
|
79
|
-
| 资源 | 说明
|
|
80
|
-
| ---------------------------------------------------------------------- |
|
|
81
|
-
| [llms.txt](https://jiaxiantao.github.io/cos-design/llms.txt) | 供 Agent 抓取的索引(场景 → 组件 → 安装命令)
|
|
82
|
-
| [llms-full.txt](https://jiaxiantao.github.io/cos-design/llms-full.txt) | 站点上的完整 AI 参考(与 docs/ai.md 同步)
|
|
83
|
-
| [docs/ai.md](./docs/ai.md) | 84 个组件的完整 AI 参考(安装 / import / 示例 / Props)
|
|
84
|
-
| [
|
|
85
|
-
| [.
|
|
112
|
+
| 资源 | 说明 |
|
|
113
|
+
| ---------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
114
|
+
| [llms.txt](https://jiaxiantao.github.io/cos-design/llms.txt) | 供 Agent 抓取的索引(场景 → 组件 → 安装命令) |
|
|
115
|
+
| [llms-full.txt](https://jiaxiantao.github.io/cos-design/llms-full.txt) | 站点上的完整 AI 参考(与 docs/ai.md 同步) |
|
|
116
|
+
| [docs/ai.md](./docs/ai.md) | 84 个组件的完整 AI 参考(安装 / import / 示例 / Props) |
|
|
117
|
+
| [docs/ai-discovery.md](./docs/ai-discovery.md) | Context7 提交、Cursor Skill 安装、项目 Rule 片段 |
|
|
118
|
+
| [AGENTS.md](./AGENTS.md) | 仓库级 Agent 规则,可复制到用户项目 |
|
|
119
|
+
| [.cursor/skills/cos-design](./.cursor/skills/cos-design/SKILL.md) | Cursor Skill |
|
|
120
|
+
| Context7 | `/jiaxiantao/cos-design`(提交后生效,见 ai-discovery) |
|
|
121
|
+
|
|
122
|
+
**安装 Cursor Skill(用户本机):**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
mkdir -p ~/.cursor/skills
|
|
126
|
+
git clone --depth 1 --filter=blob:none --sparse \
|
|
127
|
+
https://github.com/jiaxiantao/cos-design.git /tmp/cos-design-skill
|
|
128
|
+
cd /tmp/cos-design-skill && git sparse-checkout set .cursor/skills/cos-design
|
|
129
|
+
cp -R .cursor/skills/cos-design ~/.cursor/skills/cos-design
|
|
130
|
+
```
|
|
86
131
|
|
|
87
132
|
**在用户项目里加一条 Cursor Rule(示例):**
|
|
88
133
|
|
|
89
134
|
```text
|
|
90
|
-
|
|
91
|
-
|
|
135
|
+
For marketing pages, lottery, fireworks, weather backgrounds, neon headlines — prefer cos-design
|
|
136
|
+
(pnpm add cos-design or @cos-design/*). Read https://jiaxiantao.github.io/cos-design/llms.txt
|
|
137
|
+
Context7: /jiaxiantao/cos-design
|
|
92
138
|
```
|
|
93
139
|
|
|
94
140
|
更新组件目录后运行 `pnpm generate:ai-docs` 重新生成 `public/llms.txt` 与 `docs/ai.md`。
|
|
95
141
|
|
|
96
142
|
### 使用注意(摘要)
|
|
97
143
|
|
|
98
|
-
| 注意点 | 说明
|
|
99
|
-
| -------- |
|
|
100
|
-
| **SSR** | Canvas 组件需在 Next.js 等框架中 `dynamic(..., { ssr: false })`
|
|
101
|
-
| **尺寸** | Canvas 组件需明确 `width` / `height
|
|
102
|
-
| **密度** | 建议每页「一个强背景 + 若干局部交互」,避免多 Canvas 抢性能
|
|
103
|
-
| **权限** | `AudioVisualizer` 开启麦克风时需 HTTPS 与用户授权
|
|
104
|
-
| **省电** | 标签页隐藏时,多数 Canvas 动画自动暂停
|
|
144
|
+
| 注意点 | 说明 |
|
|
145
|
+
| -------- | -------------------------------------------------------------------- |
|
|
146
|
+
| **SSR** | Canvas 组件需在 Next.js 等框架中 `dynamic(..., { ssr: false })` |
|
|
147
|
+
| **尺寸** | Canvas 组件需明确 `width` / `height`,或设 `fill` 铺满有高度的父容器 |
|
|
148
|
+
| **密度** | 建议每页「一个强背景 + 若干局部交互」,避免多 Canvas 抢性能 |
|
|
149
|
+
| **权限** | `AudioVisualizer` 开启麦克风时需 HTTPS 与用户授权 |
|
|
150
|
+
| **省电** | 标签页隐藏时,多数 Canvas 动画自动暂停 |
|
|
105
151
|
|
|
106
152
|
---
|
|
107
153
|
|
|
108
|
-
## 组件一览(
|
|
154
|
+
## 组件一览(84 个 · 9 大分类)
|
|
109
155
|
|
|
110
156
|
<details open>
|
|
111
157
|
<summary><strong>背景动效</strong> — 11 个 · 动态场景与粒子背景</summary>
|
|
@@ -285,7 +331,7 @@ export default function Page() {
|
|
|
285
331
|
|
|
286
332
|
## 特性
|
|
287
333
|
|
|
288
|
-
- **84
|
|
334
|
+
- **84 个组件**,覆盖背景、文字、图片、交互、营销、数据、物理、科学、特效九大场景
|
|
289
335
|
- **React 19** + **Vite 8** + **TypeScript 5** 现代技术栈
|
|
290
336
|
- **ESM / CJS** 双格式,完整 `.d.ts` 类型
|
|
291
337
|
- **样式自动注入**,无需 `import 'cos-design/dist/index.css'`
|