@iquji-web/web-motion 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +69 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,71 @@
1
- # Web motion
1
+ # @iquji-web/web-motion
2
2
 
3
- `@iquji-web/web-motion` 只提供通用 motion 能力,JavaScript、类型声明、必要样式及功能测试随源码交付。
3
+ 简体中文 | [English](README.en.md)
4
4
 
5
- 安装使用本目录锁文件,运行 `bun install --frozen-lockfile` 和 `bun run check`。正式入口只导出 `dist` 中的 JavaScript、类型声明,不要求消费者编译本包源码。
5
+ Iquji Web 动效原语库,基于 Framer Motion 精简封装,提供控制级、浮层级及路由级的标准过渡时长、缓动曲线与 Variants,原生适配操作系统的 `prefers-reduced-motion` 偏好。
6
+
7
+ ---
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm install @iquji-web/web-motion framer-motion
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 核心特性与使用
18
+
19
+ ### 1. Provider 包装
20
+
21
+ 在应用外层配置 `IqujiMotionProvider`:
22
+
23
+ ```tsx
24
+ import { IqujiMotionProvider } from "@iquji-web/web-motion";
25
+
26
+ export function App({ children }) {
27
+ return (
28
+ <IqujiMotionProvider reducedMotion="user">
29
+ {children}
30
+ </IqujiMotionProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ ### 2. 页面与元素进场动效
36
+
37
+ ```tsx
38
+ import { IqujiMotion, iqujiMotionPresets, iqujiMotionVariants } from "@iquji-web/web-motion";
39
+
40
+ export function PageTransition({ children }) {
41
+ return (
42
+ <IqujiMotion.div
43
+ initial={iqujiMotionVariants.route.initial}
44
+ animate={iqujiMotionVariants.route.enter}
45
+ transition={iqujiMotionPresets.route}
46
+ >
47
+ {children}
48
+ </IqujiMotion.div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 预设与时长标准
56
+
57
+ - **控件级 (`control`)**:时长 `0.14s`,用于按钮、选择器微交互。
58
+ - **浮层级 (`overlay`)**:时长 `0.19s`,用于弹窗、抽屉进入与退出。
59
+ - **路由级 (`route`)**:时长 `0.24s`,用于页面切换平滑位移。
60
+
61
+ ---
62
+
63
+ ## 开发与构建
64
+
65
+ ```bash
66
+ bun install --frozen-lockfile
67
+ bun run build # 编译打包到 dist/
68
+ bun run typecheck # 类型校验
69
+ bun run test # 单元测试
70
+ bun run check # 完整校验
71
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iquji-web/web-motion",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [