Skip to content

Commit 378fba8

Browse files
authored
Refactor badge styles, remove Bootstrap styles (#2169)
1 parent b0a62b7 commit 378fba8

File tree

9 files changed

+246
-120
lines changed

9 files changed

+246
-120
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tabler/core": patch
3+
"preview": patch
4+
---
5+
6+
Refactor badge styles, remove Bootstrap styles

core/scss/_bootstrap-components.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
@import "bootstrap/scss/accordion";
1818
@import "bootstrap/scss/breadcrumb";
1919
@import "bootstrap/scss/pagination";
20-
@import "bootstrap/scss/badge";
2120
@import "bootstrap/scss/alert";
2221
@import "bootstrap/scss/progress";
2322
@import "bootstrap/scss/list-group";

core/scss/_variables.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ $h5-line-height: 1rem !default;
9797
$h6-font-size: 0.625rem !default;
9898
$h6-line-height: 1rem !default;
9999

100-
$small-font-size: 85.714285% !default;
100+
$font-size-reative-xs: .71428571em !default;
101+
$font-size-reative-sm: .85714285em !default;
102+
$font-size-reative-md: 1em !default;
101103

102104
$font-sizes: (
103105
1: $h1-font-size,
@@ -309,7 +311,7 @@ $icon-color: var(--#{$prefix}gray-400) !default;
309311

310312
// Code
311313
$code-color: var(--#{$prefix}gray-600) !default;
312-
$code-font-size: $small-font-size !default;
314+
$code-font-size: $font-size-reative-sm !default;
313315
$code-line-height: 1.25rem !default;
314316
$code-bg: var(--#{$prefix}bg-surface-secondary) !default;
315317

@@ -553,13 +555,15 @@ $breadcrumb-variants: (
553555
) !default;
554556

555557
// Badges
556-
$badge-font-size: $code-font-size !default;
558+
$badge-font-size: $font-size-reative-sm !default;
559+
$badge-font-size-sm: $font-size-reative-xs !default;
560+
$badge-font-size-lg: $font-size-reative-md !default;
557561
$badge-line-height: $code-line-height !default;
558562
$badge-font-weight: var(--#{$prefix}font-weight-medium) !default;
559563
$badge-padding-y: 0.25em !default;
560564
$badge-padding-x: 0.5em !default;
561-
$badge-empty-size: 0.5rem !default;
562-
$badge-color: var(--#{$prefix}gray-500) !default;
565+
$badge-empty-size: 10px !default;
566+
$badge-color: var(--#{$prefix}secondary) !default;
563567
$badge-bg-color: var(--#{$prefix}bg-surface-secondary) !default;
564568

565569
// Buttons
@@ -605,8 +609,8 @@ $btn-box-shadow: var(--#{$prefix}box-shadow-input) !default;
605609

606610
// Cards
607611
$card-title-spacer-y: 1.25rem !default;
608-
$card-box-shadow: var(--#{$prefix}shadow-card) !default;
609-
$card-hover-box-shadow: var(--#{$prefix}shadow-card-hover) !default;
612+
$card-box-shadow: var(--#{$prefix}box-shadow-card) !default;
613+
$card-hover-box-shadow: var(--#{$prefix}box-shadow-card-hover) !default;
610614

611615
$card-bg: var(--#{$prefix}bg-surface) !default;
612616
$card-bg-hover: $white !default;

core/scss/ui/_badges.scss

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
.badge {
2+
--#{$prefix}badge-padding-x: #{$badge-padding-x};
3+
--#{$prefix}badge-padding-y: #{$badge-padding-y};
4+
--#{$prefix}badge-font-size: #{$badge-font-size};
5+
--#{$prefix}badge-font-weight: #{$badge-font-weight};
6+
--#{$prefix}badge-color: #{$badge-color};
7+
--#{$prefix}badge-border-radius: #{$badge-border-radius};
8+
--#{$prefix}badge-icon-size: 1em;
9+
--#{$prefix}badge-line-height: 1;
10+
display: inline-flex;
11+
padding: var(--#{$prefix}badge-padding-y) var(--#{$prefix}badge-padding-x);
12+
font-weight: var(--#{$prefix}badge-font-weight);
13+
font-size: var(--#{$prefix}badge-font-size);
14+
color: var(--#{$prefix}badge-color);
15+
text-align: center;
16+
white-space: nowrap;
217
justify-content: center;
318
align-items: center;
19+
gap: .25rem;
420
background: $badge-bg-color;
521
overflow: hidden;
622
user-select: none;
723
border: var(--#{$prefix}border-width) var(--#{$prefix}border-style) transparent;
8-
min-width: 1.25rem;
9-
font-weight: $headings-font-weight;
10-
letter-spacing: .04em;
24+
border-radius: var(--#{$prefix}badge-border-radius);
25+
min-width: calc(1em + var(--#{$prefix}badge-padding-y) * 2 + 2px);
26+
letter-spacing: 0.04em;
1127
vertical-align: bottom;
28+
line-height: var(--#{$prefix}badge-line-height);
1229

1330
@at-root a#{&} {
1431
color: $card-bg;
1532
}
1633

17-
.avatar {
18-
box-sizing: content-box;
19-
width: 1.25rem;
20-
height: 1.25rem;
21-
margin: 0 .5rem 0 -.5rem;
22-
}
23-
2434
.icon {
2535
width: 1em;
2636
height: 1em;
27-
font-size: 1rem;
37+
font-size: var(--#{$prefix}badge-icon-size);
2838
stroke-width: 2;
2939
}
3040
}
3141

32-
.badge:empty,
33-
.badge-empty {
42+
.badge:empty,
43+
.badge-dot {
3444
display: inline-block;
3545
width: $badge-empty-size;
3646
height: $badge-empty-size;
@@ -76,4 +86,28 @@
7686

7787
.badge-blink {
7888
animation: blink 2s infinite;
89+
}
90+
91+
//
92+
// Badge sizes
93+
//
94+
.badge-sm {
95+
--#{$prefix}badge-font-size: #{$badge-font-size-sm};
96+
--#{$prefix}badge-icon-size: 1em;
97+
--#{$prefix}badge-padding-y: 2px;
98+
--#{$prefix}badge-padding-x: 0.25rem;
99+
}
100+
101+
.badge-lg {
102+
--#{$prefix}badge-font-size: #{$badge-font-size-lg};
103+
--#{$prefix}badge-icon-size: 1em;
104+
--#{$prefix}badge-padding-y: 0.25rem;
105+
--#{$prefix}badge-padding-x: 0.5rem;
106+
}
107+
108+
//
109+
// Badge with only icon
110+
//
111+
.badge-icononly {
112+
--#{$prefix}badge-padding-x: 0;
79113
}

core/scss/ui/_buttons.scss

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
justify-content: center;
2121
white-space: nowrap;
2222
box-shadow: var(--#{$prefix}btn-box-shadow);
23+
position: relative;
2324

2425
.icon {
2526
width: var(--#{$prefix}btn-icon-size);
@@ -224,6 +225,7 @@
224225
// Action button
225226
//
226227
.btn-action {
228+
--#{$prefix}border-color: transparent;
227229
padding: 0;
228230
border: 0;
229231
color: var(--#{$prefix}secondary);
@@ -234,6 +236,7 @@
234236
justify-content: center;
235237
border-radius: var(--#{$prefix}border-radius);
236238
background: transparent;
239+
box-shadow: none;
237240

238241
&:after {
239242
content: none;
@@ -253,14 +256,6 @@
253256
&.show {
254257
color: var(--#{$prefix}primary);
255258
}
256-
257-
.icon {
258-
margin: 0;
259-
width: 1.25rem;
260-
height: 1.25rem;
261-
font-size: 1.25rem;
262-
stroke-width: 1;
263-
}
264259
}
265260

266261
.btn-actions {

core/scss/ui/_dropdowns.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
align-items: center;
2020
margin: 0;
2121
line-height: $line-height-base;
22+
gap: .5rem;
2223
}
2324

2425
.dropdown-item-icon {

preview/eleventy.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ export default function (eleventyConfig) {
522522
return string.split(' ').map(word => word.charAt(0)).join('');
523523
})
524524

525+
eleventyConfig.addFilter("uc_first", function capitalizeFirstLetter(string) {
526+
return string.charAt(0).toUpperCase() + string.slice(1);
527+
})
528+
525529
eleventyConfig.addFilter("size", function (elem) {
526530
if (elem instanceof Object) {
527531
return Object.keys(elem).length;

preview/pages/_includes/ui/tag.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% elsif include.payment %}
1111
{% include "ui/payment.html" provider=include.payment size="xxs" class="tag-payment" %}
1212
{% elsif include.status %}
13-
{% include "ui/badge.html" color=include.status class="tag-status badge-empty" text="" %}
13+
{% include "ui/badge.html" color=include.status class="tag-status badge-dot" text="" %}
1414
{% elsif include.legend %}
1515
<span class="legend bg-{{ include.legend }}"></span>
1616
{% elsif include.checkbox %}

0 commit comments

Comments
 (0)