Skip to content

Commit 25023e4

Browse files
committed
refactor(floatbar): [floatbar] refactor theme vars
1 parent bc0ffc5 commit 25023e4

File tree

5 files changed

+43
-58
lines changed

5 files changed

+43
-58
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<tiny-floatbar class="custom">
33
<ul>
4-
<li><a>Default-A</a></li>
5-
<li><a>B</a></li>
6-
<li><a>C</a></li>
7-
<li><a>D</a></li>
4+
<li><a>本地引入</a></li>
5+
<li><a>按需引入</a></li>
6+
<li><a>搜索引入</a></li>
7+
<li><a>完整引入</a></li>
88
</ul>
99
</tiny-floatbar>
1010
</template>
@@ -16,10 +16,10 @@ import { Floatbar as TinyFloatbar } from '@opentiny/vue'
1616
<style scoped>
1717
.custom {
1818
position: static;
19-
width: 200px;
20-
background-color: rgb(222, 184, 135);
19+
width: 120px;
20+
background-color: #dbdbdb;
2121
}
22-
.custom li:hover a {
23-
color: #fff;
22+
.custom li:hover {
23+
background: #fff;
2424
}
2525
</style>

examples/sites/demos/pc/app/floatbar/custom-style.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ test('自定义样式', async ({ page }) => {
55
await page.goto('floatbar#custom-style')
66

77
const floatbar = page.locator('.tiny-float-bar')
8-
const item = page.getByRole('listitem').filter({ hasText: 'Default-A' })
8+
const item = page.getByRole('listitem').filter({ hasText: '本地引入' })
99
await expect(floatbar).toHaveClass(/custom/)
10-
await expect(floatbar).toHaveCSS('background-color', 'rgb(222, 184, 135)')
10+
await expect(floatbar).toHaveCSS('background-color', 'rgb(219, 219, 219)')
1111
await item.hover()
12-
await expect(item).toHaveCSS('background-color', 'rgba(24, 144, 255, 0.06)')
13-
await expect(item.locator('a')).toHaveCSS('color', 'rgb(255, 255, 255)')
12+
await expect(item).toHaveCSS('background-color', 'rgb(255, 255, 255)')
13+
await expect(item.locator('a')).toHaveCSS('color', 'rgb(25, 25, 25)')
1414
})

examples/sites/demos/pc/app/floatbar/custom-style.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<tiny-floatbar class="custom">
33
<ul>
4-
<li><a>Default-A</a></li>
5-
<li><a>B</a></li>
6-
<li><a>C</a></li>
7-
<li><a>D</a></li>
4+
<li><a>本地引入</a></li>
5+
<li><a>按需引入</a></li>
6+
<li><a>搜索引入</a></li>
7+
<li><a>完整引入</a></li>
88
</ul>
99
</tiny-floatbar>
1010
</template>
@@ -22,10 +22,10 @@ export default {
2222
<style scoped>
2323
.custom {
2424
position: static;
25-
width: 200px;
26-
background-color: rgb(222, 184, 135);
25+
width: 120px;
26+
background-color: #dbdbdb;
2727
}
28-
.custom li:hover a {
29-
color: #fff;
28+
.custom li:hover {
29+
background: #fff;
3030
}
3131
</style>

packages/theme/src/floatbar/index.less

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,43 @@
1717
@float-bar-prefix-cls: ~'@{css-prefix}float-bar';
1818

1919
.@{float-bar-prefix-cls} {
20-
.component-css-vars-floatbar();
20+
.inject-Floatbar-vars();
2121

2222
position: fixed;
2323
top: 50%;
2424
right: 10px;
2525
z-index: 99999;
26-
border: 1px solid var(--ti-float-bar-border-color);
27-
box-shadow: var(--ti-float-bar-box-shadow);
28-
border-radius: var(--ti-float-bar-border-radius);
26+
box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.08);;
27+
border-radius: var(--tv-Float-bar-border-radius);
2928
overflow: hidden;
30-
background: var(--ti-float-bar-list-bg-color);
29+
background: var(--tv-Float-bar-list-bg-color);
3130

3231
ul {
33-
padding: var(--ti-float-bar-ul-padding-vertical) var(--ti-float-bar-ul-padding-horizontal);
3432
li {
3533
display: block;
36-
color: var(--ti-float-bar-list-text-color);
37-
font-size: var(--ti-float-bar-font-size);
38-
min-width: var(--ti-float-bar-list-item-min-width);
39-
min-height: var(--ti-float-bar-list-item-min-height);
40-
line-height: var(--ti-float-bar-list-line-height);
34+
color: var(--tv-Float-bar-list-text-color);
35+
font-size: var(--tv-Float-bar-font-size);
36+
min-width: 014px;
37+
min-height: 32px;
38+
line-height: 32px;
4139
text-align: center;
42-
margin: var(--ti-float-bar-li-margin-vertical) var(--ti-float-bar-li-margin-horizontal);
40+
margin: var(--tv-Float-bar-li-margin-vertical) 0;
41+
padding: 0 24px;
4342

4443
&:hover {
45-
background: var(--ti-float-bar-list-hover-bg-color);
44+
background: rgba(0, 0, 0, 0.05)
4645
}
4746

4847
a {
4948
width: 100%;
5049
height: 100%;
51-
color: var(--ti-float-bar-list-text-color);
50+
color: var(--tv-Float-bar-list-text-color);
5251
cursor: pointer;
5352
outline: none;
5453

5554
&:hover,
5655
&:focus {
57-
color: var(--ti-float-bar-list-hover-text-color);
56+
color: var(--tv-Float-bar-list-hover-text-color);
5857
text-decoration: none;
5958
}
6059
}

packages/theme/src/floatbar/vars.less

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,19 @@
1010
*
1111
*/
1212

13-
.component-css-vars-floatbar() {
14-
// 浮动块边框色
15-
--ti-float-bar-border-color: unset;
13+
.inject-Floatbar-vars() {
14+
1615
// 浮动块圆角
17-
--ti-float-bar-border-radius: var(--ti-common-border-radius-4, 8px);
16+
--tv-Float-bar-border-radius: var(--tv-border-radius-lg);
1817
// 浮动块字号
19-
--ti-float-bar-font-size: var(--ti-common-font-size-base, 14px);
18+
--tv-Float-bar-font-size: var(--tv-font-size-md);
2019
// 浮动块背景色
21-
--ti-float-bar-list-bg-color: var(--ti-common-color-bg-navigation, #ffffff);
22-
// 浮动块阴影:
23-
--ti-float-bar-box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.08);
20+
--tv-Float-bar-list-bg-color: var(--tv-color-bg-secondary);
2421
// ul,li边距
25-
--ti-float-bar-ul-padding-vertical: var(--ti-common-space-2x, 8px);
26-
--ti-float-bar-ul-padding-horizontal: var(--ti-common-space-0, 0px);
27-
--ti-float-bar-li-margin-vertical: var(--ti-common-space-2x, 8px);
28-
--ti-float-bar-li-margin-horizontal: var(--ti-common-space-0, 0px);
29-
30-
// 列表项最小高度
31-
--ti-float-bar-list-item-min-height: var(--ti-common-size-height-normal, 32px);
32-
// 列表项最小宽度
33-
--ti-float-bar-list-item-min-width: var(--ti-common-size-width-normal, 104px);
34-
// 列表项行高
35-
--ti-float-bar-list-line-height: var(--ti-common-size-height-normal, 32px);
22+
--tv-Float-bar-li-margin-vertical: var(--tv-space-md);
23+
3624
// 列表项文本色
37-
--ti-float-bar-list-text-color: var(--ti-common-color-text-primary, #191919);
25+
--tv-Float-bar-list-text-color: var(--tv-color-text);
3826
// 列表项悬浮文本色
39-
--ti-float-bar-list-hover-text-color: var(--ti-common-color-primary-normal, #191919);
40-
// 列表项悬浮背景色
41-
--ti-float-bar-list-hover-bg-color: rgba(0, 0, 0, 0.05);
27+
--tv-Float-bar-list-hover-text-color: var(--tv-color-text);
4228
}

0 commit comments

Comments
 (0)