Skip to content

Commit 3a141ad

Browse files
committed
feat(tabbar): allow tabbar to have highlight in iOS theme with extra tabbar-highlight class
1 parent 8e89a6a commit 3a141ad

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed

src/core/components/tabs/tabs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,13 @@ const Tab = {
202202
if ($tabLinkEl && $tabLinkEl.length > 0) {
203203
$tabLinkEl.addClass('tab-link-active');
204204
// Material Highlight
205-
if (app.theme !== 'ios' && app.toolbar) {
206-
const $tabbarEl = $tabLinkEl.parents('.tabbar, .tabbar-labels');
207-
if ($tabbarEl.length > 0) {
208-
app.toolbar.setHighlight($tabbarEl);
209-
}
205+
const $tabbarEl = $tabLinkEl.parents('.tabbar, .tabbar-labels');
206+
const hasHighlight =
207+
app.toolbar &&
208+
$tabbarEl.length > 0 &&
209+
($tabbarEl.hasClass('tabbar-highlight') || app.theme !== 'ios');
210+
if (hasHighlight) {
211+
app.toolbar.setHighlight($tabbarEl);
210212
}
211213
}
212214
}

src/core/components/toolbar/toolbar-aurora.less

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
}
1111
.tabbar,
1212
.tabbar-labels {
13-
.tab-link-highlight {
14-
position: absolute;
15-
left: 0;
16-
height: 2px;
17-
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
18-
transition-duration: 300ms;
19-
.ltr({
20-
left: 0;
21-
});
22-
.rtl({
23-
right: 0;
24-
});
25-
}
2613
.toolbar-inner {
2714
padding-left: 0;
2815
padding-right: 0;

src/core/components/toolbar/toolbar-md.less

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@
2626
overflow: hidden;
2727
position: relative;
2828
}
29-
.tab-link-highlight {
30-
position: absolute;
31-
left: 0;
32-
height: 2px;
33-
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
34-
transition-duration: 300ms;
35-
.ltr({
36-
left: 0;
37-
});
38-
.rtl({
39-
right: 0;
40-
});
41-
}
4229
}
4330

4431
.tabbar-labels {

src/core/components/toolbar/toolbar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { nextFrame, bindMethods } from '../../shared/utils';
44
const Toolbar = {
55
setHighlight(tabbarEl) {
66
const app = this;
7-
if (app.theme === 'ios') return;
8-
97
const $tabbarEl = $(tabbarEl);
8+
if (app.theme === 'ios' && !$tabbarEl.hasClass('tabbar-highlight')) return;
109

1110
if (
1211
$tabbarEl.length === 0 ||

src/core/components/toolbar/toolbar.less

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@
153153
height: var(--f7-tabbar-icon-size);
154154
line-height: var(--f7-tabbar-icon-size);
155155
}
156+
.tab-link-highlight {
157+
position: absolute;
158+
left: 0;
159+
height: 2px;
160+
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
161+
transition-duration: 300ms;
162+
.ltr({
163+
left: 0;
164+
});
165+
.rtl({
166+
right: 0;
167+
});
168+
}
156169
}
157170
.tabbar-labels {
158171
--f7-toolbar-height: var(--f7-tabbar-labels-height);

0 commit comments

Comments
 (0)