Skip to content

Commit 08c9a58

Browse files
committed
feat(tab-button): make usage of the new tokens to style badge
1 parent 35bca0a commit 08c9a58

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

core/src/components/tab-button/tab-button.common.scss

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@use "../../themes/ionic/ionic.globals.scss" as globals;
21
@import "../../themes/mixins";
2+
@import "./tab-button.common.vars";
33

44
:host {
55
/**
@@ -158,39 +158,47 @@
158158
:host ::slotted(ion-badge[vertical]:empty) {
159159
@include padding(0, 0);
160160

161-
width: globals.$ion-scale-200;
162-
height: globals.$ion-scale-200;
161+
width: $tab-button-badge-size-emtpy;
162+
height: $tab-button-badge-size-emtpy;
163163
}
164164

165165
:host ::slotted(ion-badge[vertical]) {
166-
@include position($start: 50%);
167-
168-
transform: translateX(globals.$ion-scale-300);
166+
@include position($start: $tab-button-badge-start-position);
169167
}
170168

171169
:host ::slotted(ion-badge[vertical="top"]) {
172-
top: globals.$ion-scale-0;
170+
top: $tab-button-badge-top-position;
173171
}
174172

175-
:host ::slotted(ion-badge[vertical="bottom"]) {
176-
@include position($top: 50%);
173+
:host ::slotted(ion-badge[vertical="top"]:empty) {
174+
top: $tab-button-badge-top-position-empty;
175+
}
177176

178-
transform: translate(globals.$ion-scale-300, calc(globals.$ion-scale-200 * -1));
177+
:host ::slotted(ion-badge[vertical="bottom"]) {
178+
@include position($top: $tab-button-badge-bottom-position);
179179
}
180180

181181
:host ::slotted(ion-badge[vertical="bottom"]:empty) {
182-
transform: translate(globals.$ion-scale-300, calc(globals.$ion-scale-100 * -1));
182+
@include position($top: $tab-button-badge-bottom-position-empty);
183183
}
184184

185185
:host ::slotted(ion-badge[vertical]:not(:empty)) {
186-
@include padding(2px, 4px, 4px, 4px);
186+
@include padding(
187+
$tab-button-badge-padding-top,
188+
$tab-button-badge-padding-end,
189+
$tab-button-badge-padding-bottom,
190+
$tab-button-badge-padding-start
191+
);
187192

188-
min-width: globals.$ion-scale-400;
189-
height: globals.$ion-scale-400;
193+
display: flex;
194+
195+
align-items: center;
196+
justify-content: center;
190197

191-
font-size: globals.$ion-font-size-300;
198+
min-width: $tab-button-badge-size;
199+
height: $tab-button-badge-size;
192200

193-
line-height: 1;
201+
font-size: $tab-button-badge-font-size;
194202
}
195203

196204
// Tab Button: Layout

core/src/components/tab-button/tab-button.ionic.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,17 @@
9494
// --------------------------------------------------
9595

9696
:host ::slotted(ion-badge[vertical="top"]) {
97-
top: calc(globals.$ion-scale-200 * -1);
97+
--badge-top-position: calc(#{globals.$ion-scale-200} * -1);
9898
}
9999

100-
:host ::slotted(ion-badge[vertical]:not(:empty)) {
101-
@include padding(3px, 4px, 4px, 4px);
100+
:host ::slotted(ion-badge[vertical="top"]:empty) {
101+
--badge-top-position-empty: calc(#{globals.$ion-scale-100} * -1);
102+
}
103+
104+
:host ::slotted(ion-badge[vertical="bottom"]) {
105+
--badge-bottom-position: calc(50% - #{globals.$ion-scale-250});
106+
}
107+
108+
:host ::slotted(ion-badge[vertical="bottom"]:empty) {
109+
--badge-bottom-position: calc(50% - #{globals.$ion-scale-200});
102110
}

core/src/components/tab-button/tab-button.ios.vars.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "../../themes/native/native.globals.ios";
2+
@import "./tab-button.common.vars";
23

34
// iOS Tabs
45
// --------------------------------------------------

0 commit comments

Comments
 (0)