Skip to content

Commit 0043050

Browse files
authored
Replace Less z-index (@zi-*) variables with CSS variables (#895)
* Replace Less `@zi-*` vars with CSS vars * Hardcode zi-modals-background value Addresses #895
1 parent e0ae8d2 commit 0043050

15 files changed

+48
-46
lines changed

docs/assets/less/stacks-documentation.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@
406406
&:after {
407407
content: "";
408408
position: absolute;
409-
z-index: @zi-active;
409+
z-index: var(--zi-active);
410410
top: calc(50% - 2px);
411411
right: @su12 - @su2;
412412
border-style: solid;

lib/css/atomic/_stacks-misc.less

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,18 @@
250250
// ============================================================================
251251
// $ Z-INDEX
252252
// ----------------------------------------------------------------------------
253-
.z-hide { z-index: @zi-hide !important; }
254-
.z-base { z-index: @zi-base !important; }
255-
.z-active { z-index: @zi-active !important; }
256-
.z-selected { z-index: @zi-selected !important; }
257-
.z-dropdown { z-index: @zi-dropdown !important; }
258-
.z-popover { z-index: @zi-popovers !important; }
259-
.z-tooltip { z-index: @zi-tooltips !important; }
260-
.z-banner { z-index: @zi-banners !important; }
261-
.z-nav { z-index: @zi-navigation !important; }
262-
.z-nav-fixed { z-index: @zi-navigation-fixed !important; }
263-
.z-modal { z-index: @zi-modals !important; }
264-
.z-modal-bg { z-index: @zi-modals-background !important; }
253+
.z-hide { z-index: var(--zi-hide) !important; }
254+
.z-base { z-index: var(--zi-base) !important; }
255+
.z-active { z-index: var(--zi-active) !important; }
256+
.z-selected { z-index: var(--zi-selected) !important; }
257+
.z-dropdown { z-index: var(--zi-dropdown) !important; }
258+
.z-popover { z-index: var(--zi-popovers) !important; }
259+
.z-tooltip { z-index: var(--zi-tooltips) !important; }
260+
.z-banner { z-index: var(--zi-banners) !important; }
261+
.z-nav { z-index: var(--zi-navigation) !important; }
262+
.z-nav-fixed { z-index: var(--zi-navigation-fixed) !important; }
263+
.z-modal { z-index: var(--zi-modals) !important; }
264+
.z-modal-bg { z-index: var(--zi-modals-background) !important; }
265265

266266
// ============================================================================
267267
// $ OUTLINE

lib/css/components/_stacks-banners.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// ----------------------------------------------------------------------------
3030
.s-banner {
3131
position: fixed;
32-
z-index: @zi-navigation-fixed - 1; // Tuck below topbar
32+
z-index: calc(var(--zi-navigation-fixed) - 1); // Tuck below topbar
3333
top: 0;
3434
right: 0;
3535
left: 0;
@@ -59,7 +59,7 @@
5959

6060
// If you want to put the banner above the topbar
6161
&.is-pinned {
62-
z-index: @zi-navigation-fixed + 1;
62+
z-index: calc(var(--zi-navigation-fixed) + 1);
6363
-webkit-transform: translate3d(0, 0, 0);
6464
transform: translate3d(0, 0, 0);
6565
}

lib/css/components/_stacks-button-groups.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
// When the button is active or selected, it should pop above its siblings
4747
&.is-selected {
48-
z-index: @zi-selected;
48+
z-index: var(--zi-selected);
4949
}
5050

5151
.highcontrast-mode({
@@ -60,7 +60,7 @@
6060
});
6161

6262
&:active {
63-
z-index: @zi-active;
63+
z-index: var(--zi-active);
6464
}
6565

6666
#stacks-internals #screen-sm({

lib/css/components/_stacks-buttons.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
&:after {
9696
content: "";
9797
position: absolute;
98-
z-index: @zi-active;
98+
z-index: var(--zi-active);
9999
top: calc(50% - 2px);
100100
right: 0.8em;
101101
border-style: solid;

lib/css/components/_stacks-inputs.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fieldset {
265265
&:after {
266266
content: "";
267267
position: absolute;
268-
z-index: @zi-selected;
268+
z-index: var(--zi-selected);
269269
right: 13px;
270270
border-color: currentColor transparent;
271271
border-style: solid;

lib/css/components/_stacks-links.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ a,
102102
&:after {
103103
content: "";
104104
position: absolute;
105-
z-index: @zi-active;
105+
z-index: var(--zi-active);
106106
top: calc(50% - 2px);
107107
right: 0;
108108
border-style: solid;

lib/css/components/_stacks-modals.less

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
display: flex;
1818
visibility: hidden;
1919
position: fixed;
20-
z-index: @zi-hide; // Make sure it's also below everything so we can't interact with it.
20+
z-index: var(--zi-hide); // Make sure it's also below everything so we can't interact with it.
2121

2222
// This fills the entire viewport without having to worry about size.
2323
top: 0;
@@ -35,7 +35,7 @@
3535
&[aria-hidden="false"],
3636
&[aria-hidden="false"] .s-modal--dialog {
3737
visibility: visible;
38-
z-index: @zi-modals;
38+
z-index: var(--zi-modals);
3939
opacity: 1;
4040
transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
4141
transition: opacity 100ms @te-smooth 10ms, z-index 0s 0s, visibility 0s 0s, transform 100ms @te-smooth 10ms, transform 100ms @te-smooth 10ms; // Transition in
@@ -45,7 +45,7 @@
4545
.s-modal--dialog {
4646
overflow-y: auto;
4747
visibility: hidden;
48-
z-index: @zi-hide; // Make sure it's also below everything so we can't interact with it.
48+
z-index: var(--zi-hide); // Make sure it's also below everything so we can't interact with it.
4949
max-width: 600px;
5050
max-height: 100%;
5151
padding: @su24;

lib/css/components/_stacks-navigation.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
&:after {
7373
content: "";
7474
position: absolute;
75-
z-index: @zi-active;
75+
z-index: var(--zi-active);
7676
top: calc(50% - 2px);
7777
right: 0.9em;
7878
border-style: solid;

lib/css/components/_stacks-notices.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
left: @su8;
216216
right: @su8;
217217
opacity: 0;
218-
z-index: @zi-modals + 1; // Toasts should appear above modals
218+
z-index: calc(var(--zi-modals) + 1); // Toasts should appear above modals
219219
transform: translate3d(0, -66px, 0);
220220
transition: transform 100ms @te-smooth-slow 0s, opacity 60ms @te-smooth-slow 0ms, visibility 0s 150ms;
221221
pointer-events: none;

0 commit comments

Comments
 (0)