Skip to content

Commit 5ccd986

Browse files
authored
refactor(theme): [scroll-text] refactor scroll-text、scrollbar、tall-storage、top-box theme vars (#2292)
1 parent 831d4cd commit 5ccd986

File tree

8 files changed

+62
-68
lines changed

8 files changed

+62
-68
lines changed

packages/theme/src/scroll-text/index.less

+12-22
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
.@{scroll-text-prefix-cls} {
1919
&__wrapper {
20-
.component-css-vars-scroll-text();
20+
.inject-ScrollText-vars();
2121
}
2222

2323
width: 300px;
24-
height: var(--ti-scroll-text-height);
25-
line-height: var(--ti-scroll-text-height);
26-
background: var(--ti-scroll-text-bg-color);
27-
margin: var(--ti-scroll-text-margin-vertical) var(--ti-scroll-text-margin-horizontal);
24+
height: var(--tv-ScrollText-height);
25+
line-height: var(--tv-ScrollText-height);
26+
background: var(--tv-ScrollText-bg-color);
27+
margin: 0 auto;
2828
overflow: hidden;
2929

3030
& &__content {
@@ -50,16 +50,6 @@
5050
animation-timing-function: linear;
5151
justify-content: center;
5252

53-
// 兼容ie10-ie11
54-
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
55-
display: inline-block;
56-
}
57-
58-
// 兼容edge
59-
@supports (-ms-ime-align: auto) {
60-
display: inline-block;
61-
}
62-
6353
&.left {
6454
animation-name: moveLeft;
6555
}
@@ -106,12 +96,12 @@
10696
width: fit-content;
10797
min-width: 100%;
10898

109-
>div.left {
99+
> div.left {
110100
min-width: 100%;
111101
animation-name: moveLeftWidthAdapt;
112102
}
113103

114-
>div.right {
104+
> div.right {
115105
min-width: 100%;
116106
animation-name: moveRightWidthAdapt;
117107
}
@@ -163,25 +153,25 @@
163153
0% {
164154
transform: translateX(100%);
165155
}
166-
156+
167157
50% {
168158
transform: translateX(0);
169159
}
170-
160+
171161
100% {
172162
transform: translateX(-100%);
173163
}
174164
}
175-
165+
176166
@keyframes moveRightWidthAdapt {
177167
0% {
178168
transform: translateX(-100%);
179169
}
180-
170+
181171
50% {
182172
transform: translateX(0);
183173
}
184-
174+
185175
100% {
186176
transform: translateX(100%);
187177
}

packages/theme/src/scroll-text/vars.less

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
*
1111
*/
1212

13-
.component-css-vars-scroll-text() {
14-
--ti-scroll-text-height: var(--ti-common-size-height-small, 24px);
15-
--ti-scroll-text-bg-color: #f1f1f1;
16-
--ti-scroll-text-margin-vertical: 0;
17-
--ti-scroll-text-margin-horizontal: auto;
13+
.inject-ScrollText-vars() {
14+
--tv-ScrollText-height: var(--tv-size-height-xs);
15+
--tv-ScrollText-bg-color: var(--tv-color-bg);
1816
}

packages/theme/src/scrollbar/index.less

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@scrollbar-prefix-cls: ~'@{css-prefix}scrollbar';
1717

1818
.@{scrollbar-prefix-cls} {
19-
.component-css-vars-scrollbar();
19+
.inject-Scrollbar-vars();
2020

2121
overflow: hidden;
2222
position: relative;
@@ -45,12 +45,12 @@
4545
width: 0;
4646
height: 0;
4747
cursor: pointer;
48-
border-radius: var(--ti-scrollbar-thumb-border-radius);
49-
background-color: var(--ti-scrollbar-thumb-bg-color);
48+
border-radius: var(--tv-Scrollbar-thumb-border-radius);
49+
background-color: var(--tv-Scrollbar-thumb-bg-color);
5050
transition: 0.3s background-color;
5151

5252
&:hover {
53-
background-color: var(--ti-scrollbar-thumb-hover-bg-color);
53+
background-color: var(--tv-Scrollbar-thumb-hover-bg-color);
5454
}
5555
}
5656

@@ -63,9 +63,9 @@
6363
transition: opacity 120ms ease-out;
6464

6565
&.is-vertical {
66-
width: var(--ti-scrollbar-vertical-width);
66+
width: var(--tv-Scrollbar-vertical-width);
6767
top: 2px;
68-
right: var(--ti-scrollbar-vertical-right);
68+
right: var(--tv-Scrollbar-vertical-right);
6969

7070
& > div {
7171
width: 100%;

packages/theme/src/scrollbar/vars.less

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
*
2323
*/
2424

25-
.component-css-vars-scrollbar() {
25+
.inject-Scrollbar-vars() {
2626
// 垂直滚动条距离右侧距离
27-
--ti-scrollbar-vertical-right: 4px;
27+
--tv-Scrollbar-vertical-right: var(--tv-space-sm);
2828
// 垂直滚动条宽度
29-
--ti-scrollbar-vertical-width: 8px;
29+
--tv-Scrollbar-vertical-width: var(--tv-space-md);
3030
// 垂直滚动条滑块背景色
31-
--ti-scrollbar-thumb-bg-color: var(--ti-common-scrollbar-thumb-bg-color, #dbdbdb);
31+
--tv-Scrollbar-thumb-bg-color: var(--tv-color-bg-scrollbar-thumb);
3232
// 垂直滚动条滑块悬浮时背景色
33-
--ti-scrollbar-thumb-hover-bg-color: var(--ti-common-scrollbar-thumb-bg-color, #dbdbdb);
33+
--tv-Scrollbar-thumb-hover-bg-color: var(--tv-color-bg-scrollbar-thumb-hover);
3434
// 垂直滚动条滑块圆角
35-
--ti-scrollbar-thumb-border-radius: var(--ti-common-scrollbar-thumb-border-radius, 4px);
35+
--tv-Scrollbar-thumb-border-radius: var(--tv-border-radius-scrollbar-thumb);
3636
}

packages/theme/src/tall-storage/index.less

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
@storage-item-prefix-cls: ~'@{css-prefix}storage-item';
2020

2121
.@{tall-storage-prefix-cls} {
22-
.component-css-vars-tall-storage();
22+
.inject-TallStorage-vars();
2323

2424
position: relative;
2525

2626
.@{storage-list-style-prefix-cls} {
2727
position: absolute;
28-
background-color: var(--ti-tall-storage-bg-color);
29-
box-shadow: var(--ti-common-shadow-2-down);
30-
border-radius: var(--ti-tall-storage-border-radius);
28+
background-color: var(--tv-TallStorage-bg-color);
29+
box-shadow: var(--tv-TallStorage-box-shadow);
30+
border-radius: var(--tv-TallStorage-border-radius);
3131
width: 100%;
3232
box-sizing: border-box;
3333
z-index: 10;
@@ -36,18 +36,18 @@
3636
padding: 0;
3737
list-style: none;
3838
overflow-y: auto;
39-
max-height: calc(var(--ti-tall-storage-item-height) * 5);
39+
max-height: calc(var(--tv-TallStorage-item-height) * 5);
4040

4141
.@{storage-item-prefix-cls} {
42-
height: var(--ti-tall-storage-item-height);
43-
line-height: var(--ti-tall-storage-item-height);
42+
height: var(--tv-TallStorage-item-height);
43+
line-height: var(--tv-TallStorage-item-height);
4444
padding: 0 8px;
4545
white-space: nowrap;
4646

4747
&:hover,
4848
&.item-hover {
4949
cursor: pointer;
50-
background-color: var(--ti-tall-storage-item-bg-color);
50+
background-color: var(--tv-TallStorage-item-bg-color);
5151
}
5252
}
5353
}

packages/theme/src/tall-storage/vars.less

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@
1010
*
1111
*/
1212

13-
.component-css-vars-tall-storage() {
14-
--ti-tall-storage-bg-color: var(--ti-common-color-light, #ffffff);
15-
--ti-tall-storage-border-radius: var(--ti-common-border-radius-normal, 6px);
16-
--ti-tall-storage-item-height: var(--ti-common-size-height-normal, 32px);
17-
--ti-tall-storage-item-bg-color: var(--ti-common-color-hover-background, #f5f5f5);
13+
.inject-TallStorage-vars() {
14+
// 背景颜色
15+
--tv-TallStorage-bg-color: var(--tv-color-bg-secondary);
16+
// 圆角
17+
--tv-TallStorage-border-radius: var(--tv-border-radius-md);
18+
// 选项高度
19+
--tv-TallStorage-item-height: var(--tv-size-height-md);
20+
// 选项背景颜色
21+
--tv-TallStorage-item-bg-color: var(--tv-color-bg);
22+
// 阴影
23+
--tv-TallStorage-box-shadow: var(--tv-shadow-2-down);
1824
}

packages/theme/src/top-box/index.less

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
@top-box-prefix-cls: ~'@{css-prefix}top-box';
1919

2020
.@{top-box-prefix-cls} {
21-
.component-css-vars-top-box();
21+
.inject-TopBox-vars();
2222

2323
position: fixed;
2424
top: 20px;
2525
left: 50%;
2626
transform: translateX(-50%);
2727
width: 400px;
2828
max-height: 600px;
29-
background: var(--ti-top-box-bg-color);
29+
background: var(--tv-TopBox-bg-color);
3030
padding: 24px;
3131
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
3232
transition:
@@ -35,7 +35,7 @@
3535
top 0.4s;
3636

3737
& &__icon {
38-
font-size: var(--ti-top-box-icon-font-size, 24px);
38+
font-size: var(--tv-TopBox-icon-font-size);
3939
vertical-align: middle;
4040
}
4141

@@ -74,23 +74,23 @@
7474
}
7575

7676
&--success &__icon {
77-
fill: var(--ti-top-box-success-icon-color);
77+
fill: var(--tv-TopBox-success-icon-color);
7878
}
7979

8080
&--error &__icon {
81-
fill: var(--ti-top-box-error-icon-color);
81+
fill: var(--tv-TopBox-error-icon-color);
8282
}
8383

8484
&--warning &__icon {
85-
fill: var(--ti-top-box-warning-icon-color);
85+
fill: var(--tv-TopBox-warning-icon-color);
8686
}
8787

8888
&--help &__icon {
89-
fill: var(--ti-top-box-help-icon-color);
89+
fill: var(--tv-TopBox-help-icon-color);
9090
}
9191

9292
&--info &__icon {
93-
fill: var(--ti-top-box-info-icon-color);
93+
fill: var(--tv-TopBox-info-icon-color);
9494
}
9595

9696
&-fade-enter,

packages/theme/src/top-box/vars.less

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*
1111
*/
1212

13-
.component-css-vars-top-box() {
14-
--ti-top-box-bg-color: var(--ti-common-color-light, #ffffff);
15-
--ti-top-box-icon-font-size: var(--ti-common-font-size-5, 24px);
16-
--ti-top-box-success-icon-color: var(--ti-common-color-success-normal, #5cb300);
17-
--ti-top-box-error-icon-color: var(--ti-base-color-bg-8, #c7000b);
18-
--ti-top-box-warning-icon-color: var(--ti-common-color-warning-normal, #ff8800);
19-
--ti-top-box-help-icon-color: var(--ti-base-color-brand-6, #191919);
20-
--ti-top-box-info-icon-color: var(--ti-common-color-info-normal, #191919);
13+
.inject-TopBox-vars() {
14+
--tv-TopBox-bg-color: var(--tv-color-bg-secondary);
15+
--tv-TopBox-icon-font-size: 24px;
16+
--tv-TopBox-success-icon-color: var(--tv-color-success-icon);
17+
--tv-TopBox-error-icon-color: var(--tv-color-error-icon);
18+
--tv-TopBox-warning-icon-color: var(--tv-color-warn-icon);
19+
--tv-TopBox-help-icon-color: var(--tv-color-icon-control);
20+
--tv-TopBox-info-icon-color: var(--tv-color-info-icon);
2121
}

0 commit comments

Comments
 (0)