Skip to content

Commit 4706145

Browse files
authored
feat(Tab): update style compatible with new feature (#5392)
* feat: 增加 UseCache 参数 * refactor: 显示控制逻辑 * refactor: 重构代码 * test: 增加单元测试 * refactor: 更新样式使用 flex 布局 * refactor: 更新脚本
1 parent ce031e4 commit 4706145

File tree

2 files changed

+15
-36
lines changed

2 files changed

+15
-36
lines changed

src/BootstrapBlazor/Components/Tab/Tab.razor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ const resize = tab => {
1313
if (wrap.classList.contains('extend')) {
1414
return
1515
}
16+
17+
const link = wrap.querySelector('.nav-link-bar');
18+
if (link === null) {
19+
return;
20+
}
21+
1622
const scroll = tab.scroll
1723
const lastItem = [...tabNav.querySelectorAll('.tabs-item')].pop()
1824
if (lastItem) {

src/BootstrapBlazor/Components/Tab/Tab.razor.scss

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
.tabs-nav-wrap {
4646
position: relative;
4747
height: var(--bb-tabs-item-height);
48+
display: flex;
49+
align-items: center;
4850

4951
> .dropdown-toggle {
5052
&:after {
@@ -62,17 +64,15 @@
6264
}
6365

6466
.tabs-nav-scroll {
65-
position: absolute;
6667
overflow: hidden;
67-
left: 0;
68-
right: 0;
6968
height: 100%;
7069
border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
70+
flex: 1;
71+
width: 1%;
72+
min-width: 0;
7173
}
7274

7375
.extend .tabs-nav-scroll {
74-
left: var(--bb-tabs-bar-width);
75-
right: calc(2 * var(--bb-tabs-bar-width));
7676
border-radius: 0;
7777
}
7878

@@ -85,7 +85,6 @@
8585

8686
.tabs-nav-wrap {
8787
> .nav-link-bar {
88-
position: absolute;
8988
cursor: pointer;
9089
font-size: 1rem;
9190
color: var(--bs-body-color);
@@ -98,20 +97,14 @@
9897

9998
&.left {
10099
border-width: 0;
101-
left: 0;
102-
top: 0;
103100
}
104101

105102
&.right {
106103
border-width: 0;
107-
right: var(--bb-tabs-bar-width);
108-
top: 0;
109104
}
110105

111106
&.dropdown {
112107
border-width: 0 0 1px 1px;
113-
right: 0;
114-
top: 0;
115108
border-radius: 0 var(--bs-border-radius) 0 0;
116109
}
117110
}
@@ -130,19 +123,13 @@
130123
}
131124

132125
.tabs .of .tabs-nav-scroll {
133-
left: var(--bb-tabs-bar-width);
134-
right: var(--bb-tabs-bar-width);
135126
border-radius: 0;
136127
}
137128

138129
.tabs .of .nav-link-bar {
139130
display: flex;
140131
}
141132

142-
.tabs .of .nav-link-bar.right {
143-
right: 0;
144-
}
145-
146133
.tabs .tabs-active-bar {
147134
position: absolute;
148135
bottom: 0;
@@ -367,6 +354,7 @@
367354

368355
.tabs.tabs-vertical > .tabs-header .tabs-nav-wrap {
369356
height: 100%;
357+
flex-direction: column;
370358
}
371359

372360
.tabs.tabs-vertical > .tabs-header .tabs-nav-wrap:after {
@@ -389,16 +377,9 @@
389377

390378
.tabs.tabs-vertical > .tabs-header .tabs-nav-scroll {
391379
border-radius: 0;
392-
top: 0;
393-
bottom: 0;
394-
height: auto;
395-
}
396-
397-
.tabs.tabs-vertical > .tabs-header .of .tabs-nav-scroll {
398-
top: var(--bb-tabs-bar-height);
399-
bottom: var(--bb-tabs-bar-height);
400-
left: 0;
401-
right: 0;
380+
height: 1%;
381+
min-height: 0;
382+
width: 100%;
402383
}
403384

404385
.tabs.tabs-vertical > .tabs-header .tabs-active-bar {
@@ -477,14 +458,6 @@
477458
width: 100%;
478459
}
479460

480-
.tabs.tabs-vertical > .tabs-header .nav-link-bar.left {
481-
}
482-
483-
.tabs.tabs-vertical > .tabs-header .nav-link-bar.right {
484-
top: auto;
485-
bottom: 0;
486-
}
487-
488461
.tabs.tabs-right > .tabs-header .tabs-active-bar {
489462
right: auto;
490463
left: 0;

0 commit comments

Comments
 (0)