@yakit-libs/yakit-ui-icons 0.1.3 → 0.2.1
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/README.md +47 -5
- package/dist/IconBase.d.ts +9 -0
- package/dist/browser/colorful/index.js +2 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/outline/index.js +2 -0
- package/dist/browser/registry.js +2 -0
- package/dist/browser/solid/index.js +2 -0
- package/dist/colorful/catalog.d.ts +2379 -0
- package/dist/colorful/index.d.ts +297 -0
- package/dist/colorful/index.js +300 -0
- package/dist/colorful/types.d.ts +4 -0
- package/dist/createIcon-CNgBwNTZ.js +70 -0
- package/dist/createIcon.d.ts +4 -3
- package/dist/figmaNameCatalog.d.ts +915 -771
- package/dist/icon.css +29 -0
- package/dist/index-BNKEE7u2.js +962 -0
- package/dist/index-BxhwHLct.js +1864 -0
- package/dist/{index-C7cW06K3.js → index-DdgxZZCf.js} +413 -425
- package/dist/index.d.ts +3 -1
- package/dist/index.js +944 -632
- package/dist/loading/index.d.ts +4 -3
- package/dist/outline/index.d.ts +351 -346
- package/dist/outline/index.js +319 -311
- package/dist/registry.d.ts +19 -10
- package/dist/registry.js +3028 -295
- package/dist/solid/index.d.ts +256 -255
- package/dist/solid/index.js +257 -257
- package/dist/types.d.ts +14 -4
- package/package.json +20 -2
- package/dist/createIcon-DLie83v6.js +0 -21
- package/dist/index-DXCBgsiK.js +0 -940
package/README.md
CHANGED
|
@@ -1,31 +1,71 @@
|
|
|
1
1
|
# @yakit-libs/yakit-ui-icons
|
|
2
2
|
|
|
3
|
-
Yakit UI 的 React-
|
|
3
|
+
Yakit UI 的 React 图标包。它不依赖组件库或 CSS-in-JS 运行时,颜色 token 由运行时依赖 `@yakit-libs/color` 提供。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpm add @yakit-libs/yakit-ui-icons react
|
|
8
|
+
pnpm add @yakit-libs/yakit-ui-icons @yakit-libs/color@1.4.1 react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
`@yakit-libs/color@1.4.1` 通过 JavaScript 生成颜色变量,不再提供 `dist/index.css`。在应用的浏览器入口初始化主题:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { applyThemeColors, getColors } from "@yakit-libs/color/preview";
|
|
15
|
+
|
|
16
|
+
const theme = "light";
|
|
17
|
+
applyThemeColors(theme, getColors(theme));
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
这段初始化只能在浏览器生命周期执行;SSR 或静态主题可以在构建阶段使用 `@yakit-libs/color/css` 或 `yakit-color-css` 生成主题 CSS。图标包本身不会隐式操作 `document`,因此 Node SSR 与按图标摇树仍然可用。未初始化颜色变量时,默认色会回退到 Figma 的 `#353639`。
|
|
21
|
+
|
|
11
22
|
## 使用
|
|
12
23
|
|
|
13
24
|
```tsx
|
|
14
|
-
import {
|
|
25
|
+
import { HomeSolid, HomeOutlined } from "@yakit-libs/yakit-ui-icons";
|
|
15
26
|
|
|
16
27
|
export const HomeEntry = () => (
|
|
17
28
|
<button type="button">
|
|
18
29
|
<HomeOutlined aria-hidden size={16} />
|
|
19
|
-
<
|
|
30
|
+
<HomeSolid aria-label="首页" size={16} />
|
|
20
31
|
</button>
|
|
21
32
|
);
|
|
22
33
|
```
|
|
23
34
|
|
|
35
|
+
所有默认图标都会渲染为与 Yakit 原 Ant Design 4.8 自定义图标兼容的结构:
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<span role="img" class="anticon yakit-icon consumer-class">
|
|
39
|
+
<svg aria-hidden="true" focusable="false">...</svg>
|
|
40
|
+
</span>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`className`、`style`、事件、ARIA 属性和 `ref<HTMLSpanElement>` 属于外层 `span`;`size` 设置内层 SVG 的宽高。确需修改 SVG 表现属性时使用 `svgProps`,该入口不会接受内层事件、ARIA、焦点、ref 或内容注入。`color="currentColor"` 不产生内联颜色,可继续继承现有 Yakit/Ant 样式。
|
|
44
|
+
|
|
45
|
+
浏览器条件入口会自动关联静态 `icon.css`,根入口和 `/outline`、`/solid`、`/colorful` 多次导入时由打包器合并为一份样式;Node SSR 使用无 CSS 的通用入口,不会访问 DOM 或尝试加载 CSS 模块。无法识别 package `browser` condition 的自定义构建环境可显式导入 `@yakit-libs/yakit-ui-icons/icon.css`。
|
|
46
|
+
|
|
47
|
+
多色、品牌、头像和状态类图标同样从根入口导出。它们会保留 Figma 定义的固定色、渐变与局部主题色;注册表中的 `paintMode` 可用于区分 `literal`、`mixed` 和 `currentColor` 行为。
|
|
48
|
+
|
|
49
|
+
Outline 与 Solid 的主色默认使用 `var(--Colors-Use-Neutral-Text-1-Title, #353639)`。消费者仍可以通过 `color`、`style.color`、`color="inherit"` 或局部覆盖 CSS 变量改变颜色:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
<HomeOutlined color="#2f87ff" />
|
|
53
|
+
<HomeSolid style={{ color: "#10b981" }} />
|
|
54
|
+
<span
|
|
55
|
+
style={{
|
|
56
|
+
"--Colors-Use-Neutral-Text-1-Title": "#7b51f7",
|
|
57
|
+
} as React.CSSProperties}
|
|
58
|
+
>
|
|
59
|
+
<HomeOutlined />
|
|
60
|
+
</span>
|
|
61
|
+
```
|
|
62
|
+
|
|
24
63
|
也可以按图标家族导入:
|
|
25
64
|
|
|
26
65
|
```tsx
|
|
27
66
|
import { HomeOutlined } from "@yakit-libs/yakit-ui-icons/outline";
|
|
28
|
-
import {
|
|
67
|
+
import { HomeSolid } from "@yakit-libs/yakit-ui-icons/solid";
|
|
68
|
+
import * as ColorfulIcons from "@yakit-libs/yakit-ui-icons/colorful";
|
|
29
69
|
```
|
|
30
70
|
|
|
31
71
|
完整注册表是显式的重入口,仅在图标浏览器等需要枚举所有图标的场景使用:
|
|
@@ -33,3 +73,5 @@ import { HomeFilled } from "@yakit-libs/yakit-ui-icons/solid";
|
|
|
33
73
|
```tsx
|
|
34
74
|
import { iconRegistry } from "@yakit-libs/yakit-ui-icons/registry";
|
|
35
75
|
```
|
|
76
|
+
|
|
77
|
+
带渐变、遮罩或裁剪的图标通过 React `useId()` 隔离 SVG fragment ID。一个页面存在多个独立 React root 时,每个 root 必须使用不同的 `identifierPrefix`;同一组 SSR 与 hydration 必须使用完全相同的 prefix。跨 root 重用 prefix 可能产生 DOM ID 冲突,`useId()` 本身不提供该跨 root 保证。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ComponentType, type SVGProps } from 'react';
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
type SvgIcon = ComponentType<SVGProps<SVGSVGElement>>;
|
|
4
|
+
interface IconBaseProps extends IconProps {
|
|
5
|
+
defaultColor: string;
|
|
6
|
+
Svg: SvgIcon;
|
|
7
|
+
}
|
|
8
|
+
export declare const IconBase: import("react").ForwardRefExoticComponent<IconBaseProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
export {};
|