REFACTOR: move shadow vars to css custom props (#22094)

This commit is contained in:
Kris 2023-06-13 16:38:31 -04:00 committed by GitHub
parent dae3970bad
commit e0f848c2ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 59 additions and 84 deletions

View File

@ -135,4 +135,13 @@
--gold: #{$gold}; --gold: #{$gold};
--silver: #{$silver}; --silver: #{$silver};
--bronze: #{$bronze}; --bronze: #{$bronze};
--shadow-modal: 0 8px 60px rgba(0, 0, 0, #{$shadow-opacity-modal});
--shadow-composer: 0 -1px 40px rgba(0, 0, 0, #{$shadow-opacity-composer});
--shadow-menu-panel: 0 12px 12px rgba(0, 0, 0, #{$shadow-opacity-menu-panel});
--shadow-card: 0 4px 14px rgba(0, 0, 0, #{$shadow-opacity-card});
--shadow-dropdown: 0 2px 3px 0 rgba(0, 0, 0, #{$shadow-opacity-dropdown});
--shadow-header: 0 2px 4px -1px rgba(0, 0, 0, #{$shadow-opacity-header});
--shadow-footer-nav: 0 0 2px 0 rgba(0, 0, 0, #{$shadow-opacity-footer-nav});
--shadow-focus-danger: 0 0 6px 0 var(--danger);
} }

View File

@ -380,7 +380,7 @@ $mobile-breakpoint: 700px;
width: 460px; width: 460px;
right: 0; right: 0;
z-index: z("dropdown"); z-index: z("dropdown");
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
margin-top: -2px; margin-top: -2px;
background-color: var(--secondary); background-color: var(--secondary);
padding: 12px 12px 5px; padding: 12px 12px 5px;

View File

@ -961,7 +961,7 @@ table.permalinks {
height: calc(100vh - 450px); height: calc(100vh - 450px);
min-height: 200px; min-height: 200px;
width: 100%; width: 100%;
box-shadow: shadow("footer-nav"); box-shadow: var(--shadow-footer-nav);
border-radius: 4px; border-radius: 4px;
} }

View File

@ -521,7 +521,7 @@
} }
} }
&:hover { &:hover {
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
} }
} }
} }

View File

@ -36,7 +36,7 @@ html.composer-open {
transition: height 250ms ease, background 250ms ease, transform 250ms ease, transition: height 250ms ease, background 250ms ease, transform 250ms ease,
max-width 250ms ease, padding-bottom 250ms ease; max-width 250ms ease, padding-bottom 250ms ease;
background-color: var(--secondary); background-color: var(--secondary);
box-shadow: shadow("composer"); box-shadow: var(--shadow-composer);
.reply-area { .reply-area {
display: flex; display: flex;
@ -426,7 +426,7 @@ html.composer-open {
width: 300px; width: 300px;
background-color: var(--secondary); background-color: var(--secondary);
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("dropdown-lite"); box-shadow: var(--shadow-dropdown);
border-radius: 8px; border-radius: 8px;
ul { ul {

View File

@ -5,7 +5,7 @@ $d-popover-border: var(--primary-low);
color: var(--primary); color: var(--primary);
background: $d-popover-background; background: $d-popover-background;
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("menu-panel"); box-shadow: var(--shadow-menu-panel);
} }
.tippy-box[data-placement^="top"] .tippy-svg-arrow > svg { .tippy-box[data-placement^="top"] .tippy-svg-arrow > svg {

View File

@ -37,7 +37,7 @@
position: relative; position: relative;
background-color: var(--secondary); background-color: var(--secondary);
animation: fade-in 250ms both; animation: fade-in 250ms both;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
min-width: 40vw; min-width: 40vw;
} }

View File

@ -198,7 +198,7 @@ textarea {
&:focus:required:invalid:focus { &:focus:required:invalid:focus {
border-color: var(--danger); border-color: var(--danger);
box-shadow: shadow("focus-danger"); box-shadow: var(--shadow-focus-danger);
} }
} }

View File

@ -46,7 +46,7 @@
transition: all 0.25s; transition: all 0.25s;
&:hover { &:hover {
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
border-color: var(--primary-low-mid-or-secondary-high); border-color: var(--primary-low-mid-or-secondary-high);
} }
} }

View File

@ -10,7 +10,7 @@
width: 100%; width: 100%;
z-index: z("header"); z-index: z("header");
background-color: var(--header_background); background-color: var(--header_background);
box-shadow: shadow("header"); box-shadow: var(--shadow-header);
backface-visibility: hidden; /** do magic for scrolling performance **/ backface-visibility: hidden; /** do magic for scrolling performance **/
> .wrap { > .wrap {

View File

@ -1,7 +1,7 @@
.menu-panel.slide-in { .menu-panel.slide-in {
position: fixed; position: fixed;
right: 0; right: 0;
box-shadow: shadow("header"); box-shadow: var(--shadow-header);
.panel-body { .panel-body {
width: 100%; width: 100%;
@ -21,7 +21,7 @@
.menu-panel { .menu-panel {
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("menu-panel"); box-shadow: var(--shadow-menu-panel);
background-color: var(--secondary); background-color: var(--secondary);
z-index: z("header"); z-index: z("header");
padding: 0.5em; padding: 0.5em;

View File

@ -18,7 +18,7 @@
margin: 0 auto; margin: 0 auto;
max-width: var(--modal-max-width); max-width: var(--modal-max-width);
background-color: var(--secondary); background-color: var(--secondary);
box-shadow: shadow("modal"); box-shadow: var(--shadow-modal);
.select-kit { .select-kit {
width: 220px; width: 220px;
@ -44,7 +44,7 @@
overflow: auto; overflow: auto;
height: auto; height: auto;
background-color: var(--secondary); background-color: var(--secondary);
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
background-clip: padding-box; background-clip: padding-box;
} }
@ -208,7 +208,7 @@
position: absolute; position: absolute;
top: 70%; top: 70%;
padding: 5px 10px; padding: 5px 10px;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
z-index: 5; z-index: 5;
background-color: var(--secondary); background-color: var(--secondary);
max-height: 150px; max-height: 150px;

View File

@ -3,7 +3,7 @@
width: 14em; width: 14em;
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
z-index: z("dropdown"); z-index: z("dropdown");
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
ul { ul {
margin: 0; margin: 0;

View File

@ -495,7 +495,7 @@
background: var(--primary-very-low); background: var(--primary-very-low);
color: var(--primary-high); color: var(--primary-high);
font-size: var(--font-down-2); font-size: var(--font-down-2);
box-shadow: shadow("dropdown-lite"); box-shadow: var(--shadow-dropdown);
margin-left: 50%; margin-left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
border-radius: 4px; border-radius: 4px;

View File

@ -26,7 +26,7 @@
.sidebar-more-section-links-details-content { .sidebar-more-section-links-details-content {
background-color: var(--d-sidebar-background); background-color: var(--d-sidebar-background);
transition: background-color 0.25s; transition: background-color 0.25s;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
margin: 0 calc(var(--d-sidebar-row-horizontal-padding) * 2 / 3); margin: 0 calc(var(--d-sidebar-row-horizontal-padding) * 2 / 3);

View File

@ -34,7 +34,7 @@ body.static-login {
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
text-align: center; text-align: center;
padding: 2em; padding: 2em;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
border-radius: 5px; border-radius: 5px;
display: grid; display: grid;
place-items: center; place-items: center;

View File

@ -54,7 +54,7 @@ $discourse-tooltip-border: var(--primary-medium);
max-width: 250px; max-width: 250px;
font-size: var(--font-down-1); font-size: var(--font-down-1);
color: var(--primary); color: var(--primary);
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
line-height: 1.4em; line-height: 1.4em;
} }
} }

View File

@ -556,7 +556,7 @@ aside.quote {
z-index: z("dropdown"); z-index: z("dropdown");
background-color: var(--secondary); background-color: var(--secondary);
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
flex-direction: column; flex-direction: column;
&.animated { &.animated {
@ -1394,7 +1394,7 @@ span.mention {
margin-left: 8px; margin-left: 8px;
background-color: var(--primary-low); background-color: var(--primary-low);
color: var(--primary); color: var(--primary);
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
} }
} }
} }

View File

@ -69,7 +69,7 @@ $topic-progress-height: 42px;
overflow-y: auto; overflow-y: auto;
z-index: z("timeline"); z-index: z("timeline");
padding: 10px 10px 35px 10px; padding: 10px 10px 35px 10px;
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
background: var(--tertiary-low); background: var(--tertiary-low);
.close { .close {

View File

@ -201,7 +201,7 @@
border-radius: var(--d-border-radius); border-radius: var(--d-border-radius);
&:hover, &:hover,
&:focus { &:focus {
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
outline: 1px solid #000; outline: 1px solid #000;
} }
&[href] { &[href] {

View File

@ -7,6 +7,6 @@
color: var(--primary); color: var(--primary);
background: var(--secondary); background: var(--secondary);
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("menu-panel"); box-shadow: var(--shadow-menu-panel);
overflow-wrap: break-word; overflow-wrap: break-word;
} }

View File

@ -30,7 +30,7 @@ body.footer-nav-visible {
.footer-nav { .footer-nav {
background-color: rgba(var(--header_background-rgb), 0.9); background-color: rgba(var(--header_background-rgb), 0.9);
box-shadow: shadow("footer-nav"); box-shadow: var(--shadow-footer-nav);
height: var(--footer-nav-height); height: var(--footer-nav-height);
position: fixed; position: fixed;
bottom: calc(var(--footer-nav-height) * -1); bottom: calc(var(--footer-nav-height) * -1);

View File

@ -58,7 +58,7 @@ a.hashtag {
.hashtag-autocomplete { .hashtag-autocomplete {
max-height: 13.5em; max-height: 13.5em;
overflow-y: auto; overflow-y: auto;
box-shadow: shadow("dropdown-lite"); box-shadow: var(--shadow-dropdown);
border-radius: 8px; border-radius: 8px;
&__fadeout { &__fadeout {

View File

@ -37,7 +37,7 @@
.user-card, .user-card,
.group-card { .group-card {
width: var(--card-width); width: var(--card-width);
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
color: var(--primary); color: var(--primary);
background: var(--secondary) center center; background: var(--secondary) center center;
background-size: cover; background-size: cover;

View File

@ -171,3 +171,12 @@ $hljs-attribute: dark-light-choose(
$hljs-symbol: dark-light-choose(unquote("#990073"), unquote("#fbe")) !default; $hljs-symbol: dark-light-choose(unquote("#990073"), unquote("#fbe")) !default;
$hljs-bg: dark-light-choose(unquote("#f8f8f8"), unquote("#333")) !default; $hljs-bg: dark-light-choose(unquote("#f8f8f8"), unquote("#333")) !default;
$hljs-builtin-name: dark-light-choose($tertiary-high, $tertiary-hover) !default; $hljs-builtin-name: dark-light-choose($tertiary-high, $tertiary-hover) !default;
// shadow opacity variables
$shadow-opacity-modal: dark-light-choose(0.6, 1) !default;
$shadow-opacity-composer: dark-light-choose(0.12, 0.35) !default;
$shadow-opacity-menu-panel: dark-light-choose(0.15, 0.35) !default;
$shadow-opacity-card: dark-light-choose(0.15, 0.5) !default;
$shadow-opacity-dropdown: dark-light-choose(0.2, 0.35) !default;
$shadow-opacity-header: dark-light-choose(0.25, 0.45) !default;
$shadow-opacity-footer-nav: dark-light-choose(0.2, 0.4) !default;

View File

@ -132,49 +132,6 @@ $z-layers: (
@return map-deep-get($z-layers, $layers...); @return map-deep-get($z-layers, $layers...);
} }
// Box-shadow
// --------------------------------------------------
$box-shadow-light: (
"modal": 0 8px 60px rgba(0, 0, 0, 0.6),
"composer": 0 -1px 40px rgba(0, 0, 0, 0.12),
"menu-panel": 0 12px 12px rgba(0, 0, 0, 0.15),
"card": 0 4px 14px rgba(0, 0, 0, 0.15),
"dropdown": 0 2px 3px 0 rgba(0, 0, 0, 0.2),
"dropdown-lite": 0px 2px 12px 0px rgba(0, 0, 0, 0.1),
"header": 0 2px 4px -1px rgba(0, 0, 0, 0.25),
"footer-nav": 0 0 2px 0 rgba(0, 0, 0, 0.25),
"kbd": (
0 2px 0 rgba(0, 0, 0, 0.2),
0 0 0 1px dark-light-choose(#fff, #000) inset,
),
"focus": 0 0 3px 0 $tertiary,
"focus-danger": 0 0 6px 0 $danger,
);
// do not add a dark shadow without a light equivilant
$box-shadow-dark: (
"modal": 0 8px 60px rgba(0, 0, 0, 1),
"composer": 0 -1px 40px rgba(0, 0, 0, 0.35),
"menu-panel": 0 8px 12px rgba(0, 0, 0, 0.35),
"card": 0 4px 14px rgba(0, 0, 0, 0.5),
"dropdown": 0 2px 3px 0 rgba(0, 0, 0, 0.35),
"dropdown-lite": 0px 2px 12px 0px rgba(0, 0, 0, 0.25),
);
@function shadow($key) {
@if is-light-color-scheme() {
@return map-get($box-shadow-light, $key);
} @else {
$shadow-dark: map-get($box-shadow-dark, $key);
@if $shadow-dark != null {
@return $shadow-dark;
} @else {
@return map-get($box-shadow-light, $key);
}
}
}
// Color utilities // Color utilities
// -------------------------------------------------- // --------------------------------------------------

View File

@ -20,7 +20,7 @@
&.bad { &.bad {
background: var(--danger-medium); background: var(--danger-medium);
color: white; color: white;
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
} }
&.hide, &.hide,
&.good { &.good {

View File

@ -15,7 +15,7 @@
.select-kit-body { .select-kit-body {
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
background-clip: padding-box; background-clip: padding-box;
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
} }
.select-kit-row { .select-kit-row {

View File

@ -40,7 +40,7 @@
border-radius: 0; border-radius: 0;
border: none; border: none;
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
background: var(--secondary); background: var(--secondary);
max-width: 600px; max-width: 600px;
} }

View File

@ -9,7 +9,7 @@
max-height: 0; max-height: 0;
overflow: hidden; overflow: hidden;
transition: max-height 0.3s; transition: max-height 0.3s;
box-shadow: shadow("header"); box-shadow: var(--shadow-header);
z-index: z("header") - 10; z-index: z("header") - 10;
.update-prompt-main-content { .update-prompt-main-content {

View File

@ -2,7 +2,7 @@
border: 1px solid var(--primary-low); border: 1px solid var(--primary-low);
padding: 5px; padding: 5px;
background: var(--secondary); background: var(--secondary);
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
z-index: z("dropdown"); z-index: z("dropdown");
position: absolute; position: absolute;

View File

@ -55,7 +55,7 @@
left: 0; left: 0;
right: 0; right: 0;
border-top: 1px solid var(--primary-low); border-top: 1px solid var(--primary-low);
box-shadow: shadow("composer"); box-shadow: var(--shadow-composer);
padding: 20px 0px; padding: 20px 0px;
z-index: z("fullscreen"); z-index: z("fullscreen");
@media screen and (max-height: 425px) { @media screen and (max-height: 425px) {

View File

@ -89,7 +89,7 @@
overflow-y: auto; overflow-y: auto;
z-index: z("composer", "dropdown") + 1; z-index: z("composer", "dropdown") + 1;
padding: 1.5em; padding: 1.5em;
box-shadow: shadow("dropdown"); box-shadow: var(--shadow-dropdown);
background: var(--highlight-bg); background: var(--highlight-bg);
&.urgent { &.urgent {

View File

@ -417,7 +417,7 @@
} }
.invite-form, .invite-form,
.invite-success { .invite-success {
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
} }
} }

View File

@ -547,7 +547,7 @@ blockquote {
width: 200px; width: 200px;
position: fixed; position: fixed;
z-index: z("dropdown") + 1; // 1 higher than .select-posts z-index: z("dropdown") + 1; // 1 higher than .select-posts
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
padding: 0.714em; padding: 0.714em;
margin-bottom: 5px; margin-bottom: 5px;
right: 10px; right: 10px;

View File

@ -127,7 +127,7 @@
.select-kit-body { .select-kit-body {
padding: 0.5rem; padding: 0.5rem;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
border: 1px solid var(--primary-300); border: 1px solid var(--primary-300);
} }

View File

@ -114,7 +114,7 @@
margin: 0; margin: 0;
flex-wrap: wrap; flex-wrap: wrap;
border-bottom: 1px solid var(--primary-low); border-bottom: 1px solid var(--primary-low);
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
position: absolute; position: absolute;
width: 100%; width: 100%;
z-index: z("dropdown"); z-index: z("dropdown");
@ -180,7 +180,7 @@
text-align: center; text-align: center;
padding: 1rem; padding: 1rem;
width: 100%; width: 100%;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
background: var(--secondary); background: var(--secondary);
margin: 0; margin: 0;
box-sizing: border-box; box-sizing: border-box;

View File

@ -8,7 +8,7 @@
right: 0; right: 0;
height: 50vh; height: 50vh;
width: 100%; width: 100%;
box-shadow: shadow("card"); box-shadow: var(--shadow-card);
z-index: z("header") + 2; z-index: z("header") + 2;
max-width: 100vw; max-width: 100vw;
box-sizing: border-box; box-sizing: border-box;