Skip to content

Commit b05fc9e

Browse files
committed
fix: more css refactoring
1 parent 65881a5 commit b05fc9e

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/MetricsCards/MetricsCards.scss

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@
2828
@include pseudo-base($side, var(--tab-filler-size));
2929
}
3030

31+
// Utility mixins for common patterns
32+
33+
@mixin tab-border-base($color) {
34+
border: var(--tab-border-width) solid $color;
35+
border-bottom: none;
36+
border-radius: var(--g-border-radius-s) var(--g-border-radius-s) 0 0;
37+
}
38+
39+
@mixin tab-edge-filler($side) {
40+
&.tenant-metrics-cards__link-container_active::after {
41+
@include pseudo-active-filler($side);
42+
}
43+
44+
&:not(.tenant-metrics-cards__link-container_active)::after {
45+
@include pseudo-inactive-filler($side);
46+
}
47+
48+
&:not(.tenant-metrics-cards__link-container_active)::before {
49+
@include pseudo-background-fill($side);
50+
}
51+
}
52+
3153
.tenant-metrics-cards {
3254
// CSS Variables for consistent design system
3355
--tab-border-width: 1px;
@@ -40,6 +62,16 @@
4062
--z-tab-active: 102;
4163
--g-border-radius-xxl: 12px;
4264

65+
// Fallback for browsers without :has() support
66+
@supports not selector(:has(*)) {
67+
&__link-container:not(:last-child) {
68+
padding-right: var(--tab-adjusted-spacing);
69+
70+
border-right: var(--tab-border-width) solid var(--g-color-line-generic);
71+
border-bottom-right-radius: var(--g-border-radius-xxl);
72+
}
73+
}
74+
4375
&__link {
4476
text-decoration: none;
4577

@@ -62,83 +94,47 @@
6294
border-top: var(--tab-border-width) solid var(--g-color-base-background);
6395
border-bottom: var(--tab-border-width) solid var(--g-color-line-generic);
6496
background: var(--g-color-base-background);
65-
}
66-
67-
// Filler for the first and last cards
68-
// As they dont have left and right neighbors
69-
&__link-container:first-child {
70-
margin-left: 0;
7197

72-
&.tenant-metrics-cards__link-container_active::after {
73-
@include pseudo-active-filler(left);
98+
// Reset edge padding for first/last elements
99+
&:first-child {
100+
margin-left: 0;
74101
}
75102

76-
&:not(.tenant-metrics-cards__link-container_active)::after {
77-
@include pseudo-inactive-filler(left);
103+
&:first-child {
104+
padding-left: 0;
105+
@include tab-edge-filler(left);
78106
}
79107

80-
&:not(.tenant-metrics-cards__link-container_active)::before {
81-
@include pseudo-background-fill(left);
82-
}
83-
}
84-
85-
&__link-container:last-child {
86-
margin-right: 0;
87-
88-
&.tenant-metrics-cards__link-container_active::after {
89-
@include pseudo-active-filler(right);
90-
}
91-
92-
&:not(.tenant-metrics-cards__link-container_active)::after {
93-
@include pseudo-inactive-filler(right);
94-
}
95-
96-
&:not(.tenant-metrics-cards__link-container_active)::before {
97-
@include pseudo-background-fill(right);
108+
&:last-child {
109+
margin-right: 0;
110+
padding-right: 0;
111+
@include tab-edge-filler(right);
98112
}
99113
}
100114

101115
&__link {
102116
display: block;
103-
104-
border: var(--tab-border-width) solid var(--g-color-base-background);
105-
border-bottom: none;
106-
border-radius: var(--g-border-radius-s) var(--g-border-radius-s) 0 0;
107-
}
108-
109-
&__link-container_active &__link {
110-
display: block;
111-
112-
padding-bottom: var(--tab-border-compensation);
113-
114-
border: var(--tab-border-width) solid var(--g-color-line-generic);
115-
border-bottom: none;
116-
border-radius: var(--g-border-radius-s) var(--g-border-radius-s) 0 0;
117+
@include tab-border-base(var(--g-color-base-background));
117118
}
118119

120+
// Active state styling
119121
&__link-container_active {
120122
z-index: var(--z-tab-active);
121123

122124
padding: 0;
123125

124-
border-bottom: 0 !important;
126+
border-bottom: 0;
125127
background: var(--g-color-base-background);
126128

127129
transform: translateY(var(--tab-lift-offset));
128-
}
129-
130-
&__link-container:first-child {
131-
padding-left: 0;
132-
}
133130

134-
&__link-container:last-child {
135-
padding-right: 0;
136-
}
137-
138-
&__link-container:not(:has(+ &__link-container_active)) {
139-
padding-right: 0;
131+
.tenant-metrics-cards__link {
132+
padding-bottom: var(--tab-border-compensation);
133+
@include tab-border-base(var(--g-color-line-generic));
134+
}
140135
}
141136

137+
// Adjacent tab styling (modern browsers with :has() support)
142138
&__link-container:has(+ &__link-container_active) {
143139
padding-right: var(--tab-adjusted-spacing);
144140

@@ -152,4 +148,9 @@
152148
border-left: var(--tab-border-width) solid var(--g-color-line-generic);
153149
border-bottom-left-radius: var(--g-border-radius-xxl);
154150
}
151+
152+
// Reset padding for specific cases
153+
&__link-container:not(:has(+ &__link-container_active)) {
154+
padding-right: 0;
155+
}
155156
}

0 commit comments

Comments
 (0)