Skip to content

Commit 84826f8

Browse files
feat: ✨ 修复Text组件设置color属性后lines失效的问题
Closes: #477
1 parent 95735be commit 84826f8

File tree

5 files changed

+21
-52
lines changed

5 files changed

+21
-52
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// #vue组件中html代码格式化样式
3737
}
3838
},
39-
"typescript.tsdk": "node_modules\\typescript\\lib",
39+
"typescript.tsdk": "node_modules/typescript/lib",
4040
"i18n-ally.localesPaths": [
4141
"src/uni_modules/wot-design-uni/locale",
4242
"src/uni_modules/wot-design-uni/locale/lang"
Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,37 @@
11
@import '../common/abstracts/variable';
22
@import '../common/abstracts/mixin';
33

4-
@mixin text-type-style($normalColor) {
5-
color: $normalColor;
64

7-
&.is-bold {
8-
font-weight: bold;
9-
}
10-
11-
&.is-lines-1,
12-
&.is-lines-2,
13-
&.is-lines-3,
14-
&.is-lines-4,
15-
&.is-lines-5 {
16-
display: -webkit-box !important;
17-
overflow: hidden;
18-
text-overflow: ellipsis;
19-
word-break: break-all;
20-
-webkit-box-orient: vertical !important;
21-
}
22-
23-
&.is-lines-1 {
24-
@include multiEllipsis(1);
25-
}
26-
27-
&.is-lines-2 {
28-
line-clamp: 2;
29-
@include multiEllipsis(2);
30-
31-
}
32-
33-
&.is-lines-3 {
34-
@include multiEllipsis(3);
35-
36-
}
375

38-
&.is-lines-4 {
39-
@include multiEllipsis(4);
6+
@include b(text) {
407

8+
@include when(bold) {
9+
font-weight: bold;
4110
}
4211

43-
&.is-lines-5 {
44-
@include multiEllipsis(5);
45-
12+
@for $i from 1 through 5 {
13+
&.is-lines-#{$i} {
14+
@include multiEllipsis($i);
15+
}
4616
}
47-
}
4817

49-
@include b(text) {
5018
@include when(default) {
51-
@include text-type-style($-text-info-color);
19+
color: $-text-info-color;
5220
}
5321

5422
@include when(primary) {
55-
@include text-type-style($-text-primary-color);
23+
color: $-text-primary-color;
5624
}
5725

5826
@include when(error) {
59-
@include text-type-style($-text-error-color);
27+
color: $-text-error-color;
6028
}
6129

6230
@include when(warning) {
63-
@include text-type-style($-text-warning-color);
31+
color: $-text-warning-color;
6432
}
6533

6634
@include when(success) {
67-
@include text-type-style($-text-success-color);
35+
color: $-text-success-color;
6836
}
6937
}

src/uni_modules/wot-design-uni/components/wd-text/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ExtractPropTypes } from 'vue'
22
import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'
33

4-
export type TextType = 'default' | 'primary' | 'success' | 'warning' | 'danger'
4+
export type TextType = 'default' | 'primary' | 'success' | 'warning' | 'error'
55

66
export const textProps = {
77
...baseProps,
@@ -68,13 +68,13 @@ export const textProps = {
6868
* 类型:string
6969
* 默认值:''
7070
*/
71-
prefix: makeStringProp(''),
71+
prefix: String,
7272
/**
7373
* 后置插槽
7474
* 类型:string
7575
* 默认值:''
7676
*/
77-
suffix: makeStringProp(''),
77+
suffix: String,
7878
/**
7979
* 文本显示的行数,如果设置,超出此行数,将会显示省略号。最大值为5。
8080
*/

src/uni_modules/wot-design-uni/components/wd-text/wd-text.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<text @click="handleClick" :class="rootClass" :style="rootStyle">
3-
<slot name="prefix">{{ props.prefix }}</slot>
3+
<slot v-if="$slots.prefix || prefix" name="prefix">{{ prefix }}</slot>
44
<text>{{ formattedText }}</text>
5-
<slot name="suffix">{{ props.suffix }}</slot>
5+
<slot v-if="$slots.suffix || suffix" name="suffix">{{ suffix }}</slot>
66
</text>
77
</template>
88

src/uni_modules/wot-design-uni/global.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* @Author: weisheng
33
* @Date: 2023-09-25 17:28:12
4-
* @LastEditTime: 2024-07-05 14:37:28
4+
* @LastEditTime: 2024-07-31 23:10:28
55
* @LastEditors: weisheng
66
* @Description:
7-
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\global.d.ts
7+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/global.d.ts
88
* 记得注释
99
*/
1010
import '@vue/runtime-core'
@@ -100,6 +100,7 @@ declare module '@vue/runtime-core' {
100100
WdSkeleton: typeof import('./components/wd-skeleton/wd-skeleton.vue')['default']
101101
WdIndexBar: typeof import('./components/wd-index-bar/wd-index-bar.vue')['default']
102102
WdIndexAnchor: typeof import('./components/wd-index-anchor/wd-index-anchor.vue')['default']
103+
WdText: typeof import('./components/wd-text/wd-text.vue')['default']
103104
}
104105
}
105106

0 commit comments

Comments
 (0)