ThemeText.ets
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@Extend(Text) function info () {
.fontColor('#909399').backgroundColor('#f4f4f5')
.borderColor('#e9e9eb')
}
@Extend(Text) function primary () {
.fontColor('#1890ff').backgroundColor('#e8f4ff')
.borderColor('#d1e9ff')
}
@Extend(Text) function warning () {
.fontColor('#ffba00').backgroundColor('#fff8e6')
.borderColor('#fff1cc')
}
@Extend(Text) function success () {
.fontColor('#13ce66').backgroundColor('#e7faf0')
.borderColor('#d0f5e0')
}
@Extend(Text) function danger () {
.fontColor('#ff4949').backgroundColor('#ffeded')
.borderColor('#ffdbdb')
}
@Component
export default struct ThemeTest {
@Prop theme: string
@Prop textValue: string
build() {
if(this.theme == 'info') {
Text(this.textValue).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).info()
} else if(this.theme == 'primary'){
Text(this.textValue).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).primary()
} else if(this.theme == 'warning'){
Text(this.textValue).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).warning()
} else if(this.theme == 'success'){
Text(this.textValue).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).success()
} else if(this.theme == 'danger'){
Text(this.textValue).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).danger()
}
}
}