|
28 | 28 | @include pseudo-base($side, var(--tab-filler-size)); |
29 | 29 | } |
30 | 30 |
|
| 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 | + |
31 | 53 | .tenant-metrics-cards { |
32 | 54 | // CSS Variables for consistent design system |
33 | 55 | --tab-border-width: 1px; |
|
40 | 62 | --z-tab-active: 102; |
41 | 63 | --g-border-radius-xxl: 12px; |
42 | 64 |
|
| 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 | + |
43 | 75 | &__link { |
44 | 76 | text-decoration: none; |
45 | 77 |
|
|
62 | 94 | border-top: var(--tab-border-width) solid var(--g-color-base-background); |
63 | 95 | border-bottom: var(--tab-border-width) solid var(--g-color-line-generic); |
64 | 96 | 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; |
71 | 97 |
|
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; |
74 | 101 | } |
75 | 102 |
|
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); |
78 | 106 | } |
79 | 107 |
|
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); |
98 | 112 | } |
99 | 113 | } |
100 | 114 |
|
101 | 115 | &__link { |
102 | 116 | 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)); |
117 | 118 | } |
118 | 119 |
|
| 120 | + // Active state styling |
119 | 121 | &__link-container_active { |
120 | 122 | z-index: var(--z-tab-active); |
121 | 123 |
|
122 | 124 | padding: 0; |
123 | 125 |
|
124 | | - border-bottom: 0 !important; |
| 126 | + border-bottom: 0; |
125 | 127 | background: var(--g-color-base-background); |
126 | 128 |
|
127 | 129 | transform: translateY(var(--tab-lift-offset)); |
128 | | - } |
129 | | - |
130 | | - &__link-container:first-child { |
131 | | - padding-left: 0; |
132 | | - } |
133 | 130 |
|
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 | + } |
140 | 135 | } |
141 | 136 |
|
| 137 | + // Adjacent tab styling (modern browsers with :has() support) |
142 | 138 | &__link-container:has(+ &__link-container_active) { |
143 | 139 | padding-right: var(--tab-adjusted-spacing); |
144 | 140 |
|
|
152 | 148 | border-left: var(--tab-border-width) solid var(--g-color-line-generic); |
153 | 149 | border-bottom-left-radius: var(--g-border-radius-xxl); |
154 | 150 | } |
| 151 | + |
| 152 | + // Reset padding for specific cases |
| 153 | + &__link-container:not(:has(+ &__link-container_active)) { |
| 154 | + padding-right: 0; |
| 155 | + } |
155 | 156 | } |
0 commit comments