@liujitcn/kratos-taro-app-ui 0.0.18 → 0.0.19

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 公开入口
6
6
 
7
- - `@liujitcn/kratos-taro-app-ui`:版本标识及按需封装的图标。
7
+ - `@liujitcn/kratos-taro-app-ui`:版本标识、按需封装的 NutUI 图标和与 uni-app 对齐的 `UniIcon`。
8
8
  - `@liujitcn/kratos-taro-app-ui/icons`:图标专用入口。
9
9
  - `@liujitcn/kratos-taro-app-ui/styles/theme.scss`:Kratos 与 NutUI 主题变量。
10
10
 
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.18",
10
+ "version": "0.0.19",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "src",
@@ -29,7 +29,7 @@
29
29
  "react": "18.3.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "@liujitcn/kratos-taro-app-core": "^0.0.18"
32
+ "@liujitcn/kratos-taro-app-core": "^0.0.19"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "pnpm pack --pack-destination ../../dist/npm",
@@ -0,0 +1,30 @@
1
+ import { Text } from '@tarojs/components'
2
+ import './styles/uni-icons.scss'
3
+
4
+ /** uni-app uni-icons 中输入器使用的图标字形。 */
5
+ export type UniIconName = 'plusempty' | 'mic' | 'paperplane' | 'left' | 'bars'
6
+
7
+ /** Taro 端复用 uni-app 图标字体的图标组件。 */
8
+ export interface UniIconProps {
9
+ type: UniIconName
10
+ size?: number | string
11
+ color?: string
12
+ }
13
+
14
+ const iconUnicode: Record<UniIconName, string> = {
15
+ plusempty: '\ue67b',
16
+ mic: '\ue671',
17
+ paperplane: '\ue672',
18
+ left: '\ue6b7',
19
+ bars: '\ue627',
20
+ }
21
+
22
+ /** 渲染与 uni-app uni-icons 相同的图标字形。 */
23
+ export default function UniIcon({ type, size = 16, color = '#333' }: UniIconProps) {
24
+ const fontSize = typeof size === 'number' ? `${size}px` : size
25
+ return (
26
+ <Text className='kratos-uni-icon' style={{ fontSize, color }}>
27
+ {iconUnicode[type]}
28
+ </Text>
29
+ )
30
+ }
package/src/icons.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /// <reference path="./types/nutui-icons.d.ts" />
2
2
 
3
+ export { default as UniIcon } from './UniIcon'
4
+
3
5
  export { default as ArrowLeft } from '@nutui/icons-react-taro/dist/es/icons/ArrowLeft.js'
4
6
  export { default as ArrowRight } from '@nutui/icons-react-taro/dist/es/icons/ArrowRight.js'
5
7
  export { default as Category } from '@nutui/icons-react-taro/dist/es/icons/Category.js'
Binary file
@@ -0,0 +1,16 @@
1
+ @font-face {
2
+ font-family: kratos-uni-icons;
3
+ font-style: normal;
4
+ font-weight: normal;
5
+ src: url('../static/fonts/uniicons.ttf') format('truetype');
6
+ }
7
+
8
+ .kratos-uni-icon {
9
+ display: inline-block;
10
+ font-family: kratos-uni-icons;
11
+ font-style: normal;
12
+ font-weight: normal;
13
+ line-height: 1;
14
+ text-align: center;
15
+ text-decoration: none;
16
+ }