@atooyu/uxto-ui 1.1.1 → 1.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.
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -3
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +6 -6
- package/package.json +1 -1
- package/src/components/u-icon/u-icon.vue +51 -5
package/dist/style.css
CHANGED
|
@@ -321,25 +321,25 @@ to {
|
|
|
321
321
|
.u-modal__button--confirm[data-v-9552a05f] {
|
|
322
322
|
color: #00a29a;
|
|
323
323
|
font-weight: 500;
|
|
324
|
-
}.u-icon[data-v-
|
|
324
|
+
}.u-icon[data-v-535b2661] {
|
|
325
325
|
display: inline-flex;
|
|
326
326
|
align-items: center;
|
|
327
327
|
justify-content: center;
|
|
328
328
|
font-style: normal;
|
|
329
329
|
line-height: 1;
|
|
330
330
|
}
|
|
331
|
-
.u-icon--spin[data-v-
|
|
332
|
-
animation: u-icon-spin-
|
|
331
|
+
.u-icon--spin[data-v-535b2661] {
|
|
332
|
+
animation: u-icon-spin-535b2661 1s linear infinite;
|
|
333
333
|
}
|
|
334
|
-
.u-icon__inner[data-v-
|
|
334
|
+
.u-icon__inner[data-v-535b2661] {
|
|
335
335
|
font-family: inherit;
|
|
336
336
|
line-height: 1;
|
|
337
337
|
}
|
|
338
|
-
.u-icon__svg[data-v-
|
|
338
|
+
.u-icon__svg[data-v-535b2661] {
|
|
339
339
|
display: block;
|
|
340
340
|
object-fit: contain;
|
|
341
341
|
}
|
|
342
|
-
@keyframes u-icon-spin-
|
|
342
|
+
@keyframes u-icon-spin-535b2661 {
|
|
343
343
|
from {
|
|
344
344
|
transform: rotate(0deg);
|
|
345
345
|
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
v-if="isSvgIcon && iconSrc"
|
|
11
11
|
class="u-icon__svg"
|
|
12
12
|
:src="iconSrc"
|
|
13
|
-
:style="
|
|
13
|
+
:style="svgStyle"
|
|
14
14
|
mode="aspectFit"
|
|
15
15
|
/>
|
|
16
16
|
<!-- Emoji/文字模式 -->
|
|
@@ -48,7 +48,7 @@ const isSvgIcon = computed(() => {
|
|
|
48
48
|
|
|
49
49
|
// 获取图标 SVG 资源
|
|
50
50
|
const iconSrc = computed(() => {
|
|
51
|
-
return getIcon(props.name)
|
|
51
|
+
return getIcon(props.name) || ''
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
// 尺寸转换为 px
|
|
@@ -57,6 +57,38 @@ const sizePx = computed(() => {
|
|
|
57
57
|
return size + 'px'
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
+
// 将颜色转换为 CSS filter
|
|
61
|
+
const colorToFilter = (color: string): string => {
|
|
62
|
+
// 预定义颜色的 filter 值
|
|
63
|
+
const colorMap: Record<string, string> = {
|
|
64
|
+
'#ff9500': 'invert(58%) sepia(97%) saturate(1833%) hue-rotate(351deg) brightness(101%) contrast(101%)',
|
|
65
|
+
'#12b6af': 'invert(47%) sepia(85%) saturate(475%) hue-rotate(131deg) brightness(92%) contrast(92%)',
|
|
66
|
+
'#333333': 'invert(20%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)',
|
|
67
|
+
'#666666': 'invert(45%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)',
|
|
68
|
+
'#999999': 'invert(70%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)',
|
|
69
|
+
'#ffffff': 'invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)',
|
|
70
|
+
'#ff4d4f': 'invert(46%) sepia(98%) saturate(1925%) hue-rotate(335deg) brightness(101%) contrast(101%)',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 检查是否有预定义的 filter
|
|
74
|
+
const lowerColor = color.toLowerCase()
|
|
75
|
+
if (colorMap[lowerColor]) {
|
|
76
|
+
return colorMap[lowerColor]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 动态计算 filter(简化版本,适用于纯色图标)
|
|
80
|
+
// 将 hex 转换为 RGB
|
|
81
|
+
const hex = color.replace('#', '')
|
|
82
|
+
const r = parseInt(hex.substring(0, 2), 16)
|
|
83
|
+
const g = parseInt(hex.substring(2, 4), 16)
|
|
84
|
+
const b = parseInt(hex.substring(4, 6), 16)
|
|
85
|
+
|
|
86
|
+
// 使用 invert + sepia + hue-rotate 组合
|
|
87
|
+
// 这是一个近似方案
|
|
88
|
+
const hue = Math.atan2(Math.sqrt(3) * (g - b), 2 * r - g - b) * 180 / Math.PI
|
|
89
|
+
return `invert(1) sepia(1) saturate(10000%) hue-rotate(${hue}deg)`
|
|
90
|
+
}
|
|
91
|
+
|
|
60
92
|
// 图标样式
|
|
61
93
|
const iconStyle = computed(() => {
|
|
62
94
|
const size = typeof props.size === 'number' ? props.size : parseInt(props.size)
|
|
@@ -65,13 +97,27 @@ const iconStyle = computed(() => {
|
|
|
65
97
|
width: size + 'px',
|
|
66
98
|
height: size + 'px'
|
|
67
99
|
}
|
|
68
|
-
|
|
69
|
-
//
|
|
100
|
+
|
|
101
|
+
// SVG 图标通过 filter 设置颜色
|
|
102
|
+
if (props.color && isSvgIcon.value) {
|
|
103
|
+
style.filter = colorToFilter(props.color)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 非 SVG 图标设置颜色
|
|
70
107
|
if (props.color && !isSvgIcon.value) {
|
|
71
108
|
style.color = props.color
|
|
72
109
|
}
|
|
110
|
+
|
|
73
111
|
return style
|
|
74
112
|
})
|
|
113
|
+
|
|
114
|
+
// SVG 图标样式
|
|
115
|
+
const svgStyle = computed(() => {
|
|
116
|
+
return {
|
|
117
|
+
width: sizePx.value,
|
|
118
|
+
height: sizePx.value
|
|
119
|
+
}
|
|
120
|
+
})
|
|
75
121
|
</script>
|
|
76
122
|
|
|
77
123
|
<script lang="ts">
|
|
@@ -114,4 +160,4 @@ export default {
|
|
|
114
160
|
transform: rotate(360deg);
|
|
115
161
|
}
|
|
116
162
|
}
|
|
117
|
-
</style>
|
|
163
|
+
</style>
|