0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Hsla composition (#790)

* update theme colors to hsla

* Add light navbar bg color

* remove duplicate color assignments in Note.astro

* clean up

Clean up css variables and document use of hsla colors
This commit is contained in:
Jesus Gil 2021-07-21 18:02:45 -05:00 committed by GitHub
parent 1085542d9d
commit ba6b47eda7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 83 deletions

View file

@ -11,7 +11,7 @@
.token.plain-text,
[class*='language-bash'] span.token,
[class*='language-shell'] span.token {
color: var(--color-gray-200);
color: hsla(var(--color-gray-90), 1);
}
[class*='language-bash'] span.token,
@ -23,7 +23,7 @@
.token.comment,
[class*='language-bash'] span.token.comment,
[class*='language-shell'] span.token.comment {
color: var(--color-gray-400);
color: hsla(var(--color-gray-70), 1);
}
.token.selector,
@ -46,7 +46,7 @@
.token.hexcode,
.token.class-name,
.token.attr-name {
color: var(--color-yellow);
color: hsla(var(--color-yellow), 1);
}
.token.atrule,
@ -56,14 +56,14 @@
.token.pseudo-class,
.token.pseudo-element,
.token.string {
color: var(--color-green);
color: hsla(var(--color-green), 1);
}
.token.symbol,
.token.function,
.token.id,
.token.important {
color: var(--color-blue);
color: hsla(var(--color-blue), 1);
}
.token.important,
@ -78,7 +78,7 @@
}
.token.inserted {
color: var(--color-green);
color: hsla(var(--color-green), 1);
}
.token.keyword {
@ -87,10 +87,10 @@
}
.token.operator {
color: var(--color-gray-300);
color: hsla(var(--color-gray-70), 1);
}
.token.attr-value .token.attr-equals,
.token.punctuation {
color: var(--color-gray-200);
color: hsla(var(--color-gray-80), 1);
}

View file

@ -311,7 +311,7 @@ button {
gap: 0.25em;
padding: 0.33em 0.67em;
border-radius: 99em;
background-color: var(--color-gray-800);
background-color: hsla(215, 28%, 17%, 1);
}
#theme-toggle > label:focus-within {
@ -387,7 +387,7 @@ h2.heading {
}
.header-link:focus-within {
color: var(--theme-text-light);
border-left-color: var(--color-gray-600);
border-left-color: hsla(var(--color-gray-40), 1);
}
.header-link svg {
opacity: 0.6;
@ -447,7 +447,7 @@ h2.heading {
font-weight: 600;
margin: 0;
line-height: 1;
color: var(--color-white);
color: hsla(var(--color-base-white), 100%, 1);
text-decoration: none;
transform: translateX(-8px) scale(0.8);
}
@ -472,12 +472,12 @@ h2.heading {
.logo a:hover,
.logo a:focus {
background: rgba(var(--theme-accent-rgb), 0.6);
background: hsla(var(--color-orange), 0.6);
}
.logo a:hover svg,
.logo a:focus svg {
color: var(--color-white);
color: hsla(var(--color-base-white), 100%, 1);
}
.logo h1 {

View file

@ -7,62 +7,79 @@
'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco,
'Courier New', Courier, monospace;
--color-white: #fff;
--color-black: #000014;
/*
* Variables with --color-base prefix define
* the hue, and saturation values to be used for
* hsla colors.
*
* ex:
*
* --color-base-{color}: {hue}, {saturation};
*
*/
--color-gray-50: #f9fafb;
--color-gray-100: #f3f4f6;
--color-gray-200: #e5e7eb;
--color-gray-300: #d1d5db;
--color-gray-400: #9ca3af;
--color-gray-500: #6b7280;
--color-gray-600: #4b5563;
--color-gray-700: #374151;
--color-gray-800: #1f2937;
--color-gray-900: #111827;
--color-gray-950: #090e18;
--color-base-white: 0, 0%;
--color-base-black: 240, 100%;
--color-base-gray: 215, 14%;
--color-base-blue: 212, 100%;
--color-base-blue-dark: 212, 72%;
--color-base-green: 158, 79%;
--color-base-orange: 22, 100%;
--color-base-purple: 269, 79%;
--color-base-red: 351, 100%;
--color-base-yellow: 41, 100%;
--color-blue: #3894ff;
--color-blue-dark: #1c5fac;
--color-blue-rgb: 56, 148, 255;
--color-green: #17c083;
--color-green-rgb: 23, 192, 131;
--color-orange: #ff5d01;
--color-orange-rgb: 255, 93, 1;
--color-purple: #882de7;
--color-purple-rgb: 136, 45, 231;
--color-red: #ff1639;
--color-red-rgb: 255, 22, 57;
--color-yellow: #ffbe2d;
--color-yellow-rgb: 255, 190, 45;
/*
* Color palettes are made using --color-base
* variables, along with a lightness value to
* define different variants.
*
*/
--color-gray-5: var(--color-base-gray), 5%;
--color-gray-10: var(--color-base-gray), 10%;
--color-gray-20: var(--color-base-gray), 20%;
--color-gray-30: var(--color-base-gray), 30%;
--color-gray-40: var(--color-base-gray), 40%;
--color-gray-50: var(--color-base-gray), 50%;
--color-gray-60: var(--color-base-gray), 60%;
--color-gray-70: var(--color-base-gray), 70%;
--color-gray-80: var(--color-base-gray), 80%;
--color-gray-90: var(--color-base-gray), 90%;
--color-gray-95: var(--color-base-gray), 95%;
--color-blue: var(--color-base-blue), 61%;
--color-blue-dark: var(--color-base-blue-dark), 39%;
--color-green: var(--color-base-green), 42%;
--color-orange: var(--color-base-orange), 50%;
--color-purple: var(--color-base-purple), 54%;
--color-red: var(--color-base-red), 54%;
--color-yellow: var(--color-base-yellow), 59%;
}
:root {
color-scheme: light;
--theme-accent: var(--color-orange);
--theme-text-accent: var(--color-orange);
--theme-accent-rgb: var(--color-orange-rgb);
--theme-accent: hsla(var(--color-orange), 1);
--theme-text-accent: hsla(var(--color-orange), 1);
--theme-accent-opacity: 0.1;
--theme-divider: var(--color-gray-100);
--theme-text: var(--color-gray-800);
--theme-text-light: var(--color-gray-600);
--theme-text-lighter: var(--color-gray-400);
--theme-bg: var(--color-white);
--theme-bg-hover: var(--color-gray-50);
--theme-bg-offset: var(--color-gray-100);
--theme-bg-accent: rgba(var(--theme-accent-rgb), var(--theme-accent-opacity));
--theme-code-inline-bg: var(--color-gray-100);
--theme-divider: hsla(var(--color-gray-95), 1);
--theme-text: hsla(var(--color-gray-10), 1);
--theme-text-light: hsla(var(--color-gray-40), 1);
/* @@@: not used anywhere */
--theme-text-lighter: hsla(var(--color-gray-80), 1);
--theme-bg: hsla(var(--color-base-white), 100%, 1);
--theme-bg-hover: hsla(var(--color-gray-95), 1);
--theme-bg-offset: hsla(var(--color-gray-90), 1);
--theme-bg-accent: hsla(var(--color-orange), var(--theme-accent-opacity));
--theme-code-inline-bg: hsla(var(--color-gray-95), 1);
--theme-code-inline-text: var(--theme-text);
--theme-code-bg: var(--color-gray-700);
--theme-code-text: var(--color-gray-100);
--theme-navbar-bg: var(--color-gray-700);
--theme-code-bg: hsla(217, 19%, 27%, 1);
--theme-code-text: hsla(var(--color-gray-95), 1);
--theme-navbar-bg: hsla(217, 19%, 27%, 1);
--theme-navbar-height: 3.5rem;
--theme-sidebar-offset: var(--theme-navbar-height);
--theme-selection-color: var(--color-orange);
--theme-selection-bg: rgba(
var(--color-orange-rgb),
var(--theme-accent-opacity)
);
--theme-selection-color: hsla(var(--color-orange), 1);
--theme-selection-bg: hsla(var(--color-orange), var(--theme-accent-opacity));
}
body {
@ -77,26 +94,23 @@ body {
:root.theme-dark {
color-scheme: dark;
--theme-accent-opacity: 0.4;
--theme-accent: var(--color-orange);
--theme-text-accent: var(--color-orange);
--theme-accent-rgb: var(--color-orange-rgb);
--theme-divider: var(--color-gray-950);
--theme-text: var(--color-gray-200);
--theme-text-light: var(--color-gray-300);
--theme-text-lighter: var(--color-gray-600);
--theme-bg: var(--color-gray-800);
--theme-bg-hover: var(--color-gray-600);
--theme-bg-offset: var(--color-gray-950);
--theme-code-inline-bg: var(--color-gray-900);
--theme-code-inline-text: var(--color-white);
--theme-code-bg: var(--color-gray-950);
--theme-code-text: var(--color-white);
--theme-navbar-bg: var(--color-gray-900);
--theme-selection-color: var(--color-white);
--theme-selection-bg: rgba(
var(--color-purple-rgb),
var(--theme-accent-opacity)
);
--theme-accent: hsla(var(--color-orange), 1);
--theme-text-accent: hsla(var(--color-orange), 1);
--theme-divider: hsla(var(--color-gray-10), 1);
--theme-text: hsla(var(--color-gray-90), 1);
--theme-text-light: hsla(var(--color-gray-80), 1);
/* @@@: not used anywhere */
--theme-text-lighter: hsla(var(--color-gray-40), 1);
--theme-bg: hsla(215, 28%, 17%, 1);
--theme-bg-hover: hsla(var(--color-gray-40), 1);
--theme-bg-offset: hsla(var(--color-gray-5), 1);
--theme-code-inline-bg: hsla(var(--color-gray-10), 1);
--theme-code-inline-text: hsla(var(--color-base-white), 100%, 1);
--theme-code-bg: hsla(var(--color-gray-5), 1);
--theme-code-text: hsla(var(--color-base-white), 100%, 1);
--theme-navbar-bg: hsla(221, 39%, 11%, 1);
--theme-selection-color: hsla(var(--color-base-white), 100%, 1);
--theme-selection-bg: hsla(var(--color-purple), var(--theme-accent-opacity));
}
::selection {

View file

@ -35,14 +35,11 @@ const { type = 'tip', title } = Astro.props;
.note.type-tip {
--color: var(--color-green);
--color-rgb: var(--color-green-rgb);
}
.note.type-warning {
--color: var(--color-yellow);
--color-rgb: var(--color-yellow-rgb);
}
.note.type-error {
--color: var(--color-red);
--color-rgb: var(--color-red-rgb);
}
</style>

View file

@ -84,7 +84,7 @@ const {currentPage} = Astro.props;
}
:global(:root.theme-dark) .nav-link a[aria-current="page"] {
color: var(--color-white);
color: hsla(var(--color-base-white), 100%, 1);
}
@media (min-width: 60em) {