@test-icons/react 0.0.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/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@test-icons/react",
3
+ "version": "0.0.1",
4
+ "description": "test icon library - react components",
5
+ "main": "src/index.ts",
6
+ "files": [
7
+ "src"
8
+ ],
9
+ "license": "MIT",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ }
13
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file ACane 拐杖
3
+ * @author Auto Generated by HaierIcons
4
+ */
5
+
6
+ /* tslint:disable: max-line-length */
7
+ /* eslint-disable max-len */
8
+ import React from 'react';
9
+ import {ISvgIconProps, IconWrapper} from '../runtime';
10
+
11
+ export default IconWrapper(
12
+ 'a-cane',
13
+ true,
14
+ (props: ISvgIconProps) => (
15
+ <svg
16
+ width={props.size}
17
+ height={props.size}
18
+ viewBox="0 0 48 48"
19
+ fill="none"
20
+ >
21
+ <path
22
+ d="M19.5576 44.7684C19.5576 44.7684 32.468 20.4873 33.6417 18.28C34.8154 16.0726 37.4535 8.98102 30.3899 5.22524C23.3263 1.46947 19.1571 7.18063 17.7486 9.82948"
23
+ stroke={props.colors[0]}
24
+ strokeWidth={props.strokeWidth}
25
+ strokeLinecap={props.strokeLinecap}
26
+ strokeLinejoin={props.strokeLinejoin}
27
+ />
28
+ </svg>
29
+ )
30
+ );
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file Abdominal 腹部
3
+ * @author Auto Generated by HaierIcons
4
+ */
5
+
6
+ /* tslint:disable: max-line-length */
7
+ /* eslint-disable max-len */
8
+ import React from 'react';
9
+ import {ISvgIconProps, IconWrapper} from '../runtime';
10
+
11
+ export default IconWrapper(
12
+ 'abdominal',
13
+ false,
14
+ (props: ISvgIconProps) => (
15
+ <svg
16
+ width={props.size}
17
+ height={props.size}
18
+ viewBox="0 0 48 48"
19
+ fill="none"
20
+ >
21
+ <path
22
+ d="M7.89926 5C10.7371 8.01931 12.156 11.9408 12.156 16.7645C12.156 24 5.9995 29.5382 4.969 33.5C4.282 36.1412 3.95884 39.3078 3.9995 43"
23
+ stroke={props.colors[0]}
24
+ strokeWidth={props.strokeWidth}
25
+ strokeLinecap={props.strokeLinecap}
26
+ />
27
+ <path
28
+ d="M39.256 5C36.4182 8.01931 34.9992 11.9408 34.9992 16.7645C34.9992 24 41.1558 29.5382 42.1863 33.5C42.8733 36.1412 43.1964 39.3078 43.1558 43"
29
+ stroke={props.colors[0]}
30
+ strokeWidth={props.strokeWidth}
31
+ strokeLinecap={props.strokeLinecap}
32
+ />
33
+ <path
34
+ d="M6.24414 30.8369C12.7693 34.9668 18.6949 37.0317 24.0211 37.0317C29.3472 37.0317 34.9799 34.9668 40.9192 30.8369"
35
+ stroke={props.colors[0]}
36
+ strokeWidth={props.strokeWidth}
37
+ strokeLinecap={props.strokeLinecap}
38
+ />
39
+ <path
40
+ d="M24 31C25.3807 31 26.5 29.8807 26.5 28.5C26.5 27.1193 25.3807 26 24 26C22.6193 26 21.5 27.1193 21.5 28.5C21.5 29.8807 22.6193 31 24 31Z"
41
+ fill={props.colors[0]}
42
+ />
43
+ </svg>
44
+ )
45
+ );
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file index 引用出口
3
+ * @author Auto Generated by HaierIcons
4
+ */
5
+
6
+ export {default as ACane} from './icons/ACane';
7
+ export {default as Abdominal} from './icons/Abdominal';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file index 样式文件
3
+ * @author Auto Generated by HaierIcons
4
+ */
5
+
6
+ .hi-icon {
7
+ display: inline-block;
8
+ color: inherit;
9
+ font-style: normal;
10
+ line-height: 0;
11
+ text-align: center;
12
+ text-transform: none;
13
+ vertical-align: -0.125em;
14
+ text-rendering: optimizeLegibility;
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale;
17
+
18
+ &-spin svg {
19
+ animation: hi-icon-spin 1s infinite linear;
20
+ }
21
+ }
22
+
23
+ @keyframes hi-icon-spin {
24
+ 100% {
25
+ -webkit-transform: rotate(360deg);
26
+ transform: rotate(360deg)
27
+ }
28
+ }
29
+
30
+ @-webkit-keyframes hi-icon-spin {
31
+ 100% {
32
+ -webkit-transform: rotate(360deg);
33
+ transform: rotate(360deg)
34
+ }
35
+ }
36
+
@@ -0,0 +1,268 @@
1
+ /**
2
+ * @file runtime 运行时
3
+ * @author Auto Generated by HaierIcons
4
+ */
5
+
6
+ import React, {HTMLAttributes, ReactElement, createContext, useContext, useMemo} from 'react';
7
+
8
+ // 描边连接类型
9
+ export type StrokeLinejoin = 'miter' | 'round' | 'bevel';
10
+
11
+ // 描边端点类型
12
+ export type StrokeLinecap = 'butt' | 'round' | 'square';
13
+
14
+ // 主题
15
+ export type Theme = 'outline' | 'filled' | 'two-tone' | 'multi-color';
16
+
17
+
18
+ // 包裹前的图标属性
19
+ export interface ISvgIconProps {
20
+
21
+ // 当前图标的唯一Id
22
+ id: string;
23
+
24
+ // 图标尺寸大小,默认1em
25
+ size: number | string;
26
+
27
+ // 描边宽度
28
+ strokeWidth: number;
29
+
30
+ // 描边端点类型
31
+ strokeLinecap: StrokeLinecap;
32
+
33
+ // 描边连接线类型
34
+ strokeLinejoin: StrokeLinejoin;
35
+
36
+ // 换肤的颜色数组
37
+ colors: string[];
38
+ }
39
+
40
+ // 图标配置属性
41
+ export interface IIconConfig {
42
+
43
+ // 图标尺寸大小,默认1em
44
+ size: number | string;
45
+
46
+ // 描边宽度
47
+ strokeWidth: number;
48
+
49
+ // 描边端点类型
50
+ strokeLinecap: StrokeLinecap;
51
+
52
+ // 描边连接线类型
53
+ strokeLinejoin: StrokeLinejoin;
54
+
55
+ // CSS前缀
56
+ prefix: string;
57
+
58
+ // RTL是否开启
59
+ rtl: boolean;
60
+
61
+ // 默认主题
62
+ theme: Theme;
63
+
64
+ // 主题默认颜色
65
+ colors: {
66
+
67
+ outline: {
68
+ fill: string;
69
+ background: string;
70
+ };
71
+
72
+ filled: {
73
+ fill: string;
74
+ background: string;
75
+ };
76
+
77
+ twoTone: {
78
+ fill: string;
79
+ twoTone: string;
80
+ };
81
+
82
+ multiColor: {
83
+ outStrokeColor: string;
84
+ outFillColor: string;
85
+ innerStrokeColor: string;
86
+ innerFillColor: string;
87
+ };
88
+ };
89
+ }
90
+
91
+ // 图标基础属性
92
+ export interface IIconBase {
93
+
94
+ // 图标尺寸大小,默认1em
95
+ size?: number | string;
96
+
97
+ // 描边宽度
98
+ strokeWidth?: number;
99
+
100
+ // 描边端点类型
101
+ strokeLinecap?: StrokeLinecap;
102
+
103
+ // 描边连接线类型
104
+ strokeLinejoin?: StrokeLinejoin;
105
+
106
+ // 默认主题
107
+ theme?: Theme;
108
+
109
+ // 填充色
110
+ fill?: string | string[];
111
+ }
112
+
113
+ // 安全的类型合并
114
+ export type Intersection<T, K> = T & Omit<K, keyof T>;
115
+
116
+ // 包裹后的图标非扩展属性
117
+ export interface IIcon extends IIconBase {
118
+ spin?: boolean;
119
+ }
120
+
121
+ // 包裹后的图标属性
122
+ export type IIconProps = Intersection<IIcon, HTMLAttributes<HTMLSpanElement>>;
123
+
124
+ // 包裹前的图标
125
+ export type IconRender = (props: ISvgIconProps) => ReactElement;
126
+
127
+ // 包裹后的图标
128
+ export type Icon = (props: IIconProps) => ReactElement;
129
+
130
+ // 默认属性
131
+ export const DEFAULT_ICON_CONFIGS: IIconConfig = {
132
+ size: '1em',
133
+ strokeWidth: 4,
134
+ strokeLinecap: 'round',
135
+ strokeLinejoin: 'round',
136
+ rtl: false,
137
+ theme: 'outline',
138
+ colors: {
139
+ outline: {
140
+ fill: '#333',
141
+ background: 'transparent'
142
+ },
143
+ filled: {
144
+ fill: '#333',
145
+ background: '#FFF'
146
+ },
147
+ twoTone: {
148
+ fill: '#333',
149
+ twoTone: '#2F88FF'
150
+ },
151
+ multiColor: {
152
+ outStrokeColor: '#333',
153
+ outFillColor: '#2F88FF',
154
+ innerStrokeColor: '#FFF',
155
+ innerFillColor: '#43CCF8'
156
+ }
157
+ },
158
+ prefix: 'hi'
159
+ };
160
+
161
+ function guid(): string {
162
+ return 'icon-' + (((1 + Math.random()) * 0x100000000) | 0).toString(16).substring(1);
163
+ }
164
+
165
+ // 属性转换函数
166
+ export function IconConverter(id: string, icon: IIconBase, config: IIconConfig): ISvgIconProps {
167
+
168
+ const fill = typeof icon.fill === 'string' ? [icon.fill] : icon.fill || [];
169
+ const colors: string[] = [];
170
+
171
+ const theme: Theme = icon.theme || config.theme;
172
+
173
+ switch (theme) {
174
+ case 'outline':
175
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
176
+ colors.push('transparent');
177
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
178
+ colors.push('transparent');
179
+ break;
180
+ case 'filled':
181
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
182
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
183
+ colors.push('#FFF');
184
+ colors.push('#FFF');
185
+ break;
186
+ case 'two-tone':
187
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
188
+ colors.push(typeof fill[1] === 'string' ? fill[1] : config.colors.twoTone.twoTone);
189
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
190
+ colors.push(typeof fill[1] === 'string' ? fill[1] : config.colors.twoTone.twoTone);
191
+ break;
192
+ case 'multi-color':
193
+ colors.push(typeof fill[0] === 'string' ? fill[0] : 'currentColor');
194
+ colors.push(typeof fill[1] === 'string' ? fill[1] : config.colors.multiColor.outFillColor);
195
+ colors.push(typeof fill[2] === 'string' ? fill[2] : config.colors.multiColor.innerStrokeColor);
196
+ colors.push(typeof fill[3] === 'string' ? fill[3] : config.colors.multiColor.innerFillColor);
197
+ break;
198
+ }
199
+
200
+ return {
201
+ size: icon.size || config.size,
202
+ strokeWidth: icon.strokeWidth || config.strokeWidth,
203
+ strokeLinecap: icon.strokeLinecap || config.strokeLinecap,
204
+ strokeLinejoin: icon.strokeLinejoin || config.strokeLinejoin,
205
+ colors,
206
+ id
207
+ };
208
+ }
209
+
210
+ // 图标配置Context
211
+ const IconContext = createContext(DEFAULT_ICON_CONFIGS);
212
+
213
+ // 图标配置Provider
214
+ export const IconProvider = IconContext.Provider;
215
+
216
+ // 图标Wrapper
217
+ export function IconWrapper(name: string, rtl: boolean, render: IconRender): Icon {
218
+
219
+ return (props: IIconProps) => {
220
+
221
+ const {
222
+ size,
223
+ strokeWidth,
224
+ strokeLinecap,
225
+ strokeLinejoin,
226
+ theme,
227
+ fill,
228
+ className,
229
+ spin,
230
+ ...extra
231
+ } = props;
232
+
233
+ const config = useContext(IconContext);
234
+
235
+ const id = useMemo(guid, []);
236
+
237
+ const svgProps = IconConverter(id, {
238
+ size,
239
+ strokeWidth,
240
+ strokeLinecap,
241
+ strokeLinejoin,
242
+ theme,
243
+ fill
244
+ }, config);
245
+
246
+ const cls: string[] = ['hi-icon'];
247
+
248
+ cls.push('hi-icon' + '-' + name);
249
+
250
+ if (rtl && config.rtl) {
251
+ cls.push('hi-icon-rtl');
252
+ }
253
+
254
+ if (spin) {
255
+ cls.push('hi-icon-spin');
256
+ }
257
+
258
+ if (className) {
259
+ cls.push(className);
260
+ }
261
+
262
+ return (
263
+ <span {...extra} className={cls.join(' ')}>
264
+ {render(svgProps)}
265
+ </span>
266
+ );
267
+ };
268
+ }