From 2a0d1275f73575626666b2b4101c6a427a6a0dad Mon Sep 17 00:00:00 2001 From: Adam Argyle Date: Wed, 30 Oct 2024 08:46:34 -0700 Subject: [PATCH] refactor to use cascade layers --- src/components/biome.astro | 52 ++-- src/components/feature.filmstrip.astro | 73 ++--- src/components/footer.astro | 17 +- src/components/header.primary.astro | 54 ++-- src/components/hero.astro | 94 +++--- src/components/main.aside.astro | 398 +++++++++++++------------ src/components/nav.bento.astro | 76 ++--- src/components/theme.switch.astro | 170 +++++------ src/components/video.astro | 20 +- src/components/youtube.astro | 17 +- src/features/_layout.astro | 150 +++++----- src/pages/index.astro | 94 +++--- src/styles/code.css | 16 + src/styles/global.css | 51 ++-- 14 files changed, 661 insertions(+), 621 deletions(-) create mode 100644 src/styles/code.css diff --git a/src/components/biome.astro b/src/components/biome.astro index d04e9c9..6167784 100644 --- a/src/components/biome.astro +++ b/src/components/biome.astro @@ -23,36 +23,38 @@ const { title, description, features } = Astro.props; diff --git a/src/components/feature.filmstrip.astro b/src/components/feature.filmstrip.astro index d78e614..54afbd1 100644 --- a/src/components/feature.filmstrip.astro +++ b/src/components/feature.filmstrip.astro @@ -5,10 +5,9 @@ import shuffle from "./../util/shuffle"; const { biomes } = Astro.props; // Flatten all Biome features to one flat array -const features = biomes.reduce( - (features, biome) => [...features, ...biome.features], - [] -).map((feature) => feature.title); +const features = biomes + .reduce((features, biome) => [...features, ...biome.features], []) + .map((feature) => feature.title); ---
@@ -38,46 +37,48 @@ const features = biomes.reduce( } } - .feature-grid { - display: grid; - place-content: center; - gap: var(--size-3); - padding-block: var(--size-10) var(--size-13); - max-inline-size: 100vw; - overflow: clip; - - > .row { + @layer components.feature-filmstrip { + .feature-grid { display: grid; - grid-auto-flow: column; - grid-auto-columns: max(10vw, 15ch); + place-content: center; gap: var(--size-3); + padding-block: var(--size-10) var(--size-13); + max-inline-size: 100vw; + overflow: clip; + + > .row { + display: grid; + grid-auto-flow: column; + grid-auto-columns: max(10vw, 15ch); + gap: var(--size-3); - @media (prefers-reduced-motion: no-preference) { - @supports (animation-timeline: view()) { - animation: pan-x linear both; - animation-timeline: view(block); + @media (prefers-reduced-motion: no-preference) { + @supports (animation-timeline: view()) { + animation: pan-x linear both; + animation-timeline: view(block); + } } - } - &:first-of-type { - animation-direction: reverse; - } + &:first-of-type { + animation-direction: reverse; + } - > .card { - aspect-ratio: 3/4; - padding: var(--size-3); - background: var(--surface-3); - border-radius: var(--radius-3); - box-shadow: var(--shadow-1); + > .card { + aspect-ratio: 3/4; + padding: var(--size-3); + background: var(--surface-3); + border-radius: var(--radius-3); + box-shadow: var(--shadow-1); - display: grid; - place-content: center; - place-items: center; - text-align: center; - overflow: clip; + display: grid; + place-content: center; + place-items: center; + text-align: center; + overflow: clip; - font-size: var(--font-size-4); - font-weight: 100; + font-size: var(--font-size-4); + font-weight: 100; + } } } } diff --git a/src/components/footer.astro b/src/components/footer.astro index 16ad105..4401ff9 100644 --- a/src/components/footer.astro +++ b/src/components/footer.astro @@ -1,16 +1,19 @@ --- + ---

It's a good time to be a front-end dev.

-

Lorem ipsum dolor, sit amet consectetur adipisicing elit.

+

Lorem ipsum dolor, sit amet consectetur adipisicing elit.

\ No newline at end of file + diff --git a/src/components/header.primary.astro b/src/components/header.primary.astro index 32ca670..1da7777 100644 --- a/src/components/header.primary.astro +++ b/src/components/header.primary.astro @@ -20,38 +20,40 @@ import ThemeSwitch from "./theme.switch.astro"; diff --git a/src/components/hero.astro b/src/components/hero.astro index 40b6a7d..ab3cac5 100644 --- a/src/components/hero.astro +++ b/src/components/hero.astro @@ -16,64 +16,66 @@ import NavBento from "./nav.bento.astro"; diff --git a/src/components/main.aside.astro b/src/components/main.aside.astro index 9b75048..4dd4564 100644 --- a/src/components/main.aside.astro +++ b/src/components/main.aside.astro @@ -121,251 +121,253 @@ const { biomes } = Astro.props; diff --git a/src/components/youtube.astro b/src/components/youtube.astro index e0b2332..05bd96c 100644 --- a/src/components/youtube.astro +++ b/src/components/youtube.astro @@ -6,7 +6,12 @@ interface Props { title?: string; } -const { id, width = 560, height = 315, title = 'YouTube video player' } = Astro.props; +const { + id, + width = 560, + height = 315, + title = "YouTube video player", +} = Astro.props; const src = `https://www.youtube.com/embed/${id}`; --- @@ -22,9 +27,11 @@ const src = `https://www.youtube.com/embed/${id}`; allowfullscreen> diff --git a/src/features/_layout.astro b/src/features/_layout.astro index c6b791c..af346a8 100644 --- a/src/features/_layout.astro +++ b/src/features/_layout.astro @@ -7,101 +7,103 @@ diff --git a/src/styles/code.css b/src/styles/code.css new file mode 100644 index 0000000..2f514ba --- /dev/null +++ b/src/styles/code.css @@ -0,0 +1,16 @@ +.astro-code { + --astro-code-color-text: var(--text-1); + --astro-code-color-background: var(--surface-2); +} + +[data-theme="light"] .astro-code { + --astro-code-token-function: var(--purple-8); + --astro-code-token-constant: var(--blue-9); + --astro-code-token-keyword: var(--pink-6); +} + +[data-theme="dark"] .astro-code { + --astro-code-token-function: var(--green-3); + --astro-code-token-constant: var(--cyan-2); + --astro-code-token-keyword: var(--pink-4); +} \ No newline at end of file diff --git a/src/styles/global.css b/src/styles/global.css index 5efd5d5..30339b4 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -3,10 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -@import "open-props/style"; /* todo: import only what's needed */ -@import "open-props/normalize"; -@import "open-props/switch/light"; -@import "open-props/switch/dark"; +@layer base, reset, theme, components, utilities; + +@import "open-props/style" layer(base); /* todo: import only what's needed */ +@import "open-props/normalize" layer(reset); +@import "open-props/switch/light" layer(theme); +@import "open-props/switch/dark" layer(theme); + +@import "./code.css" layer(components.code); @font-face { font-family: 'Jersey10'; @@ -19,33 +23,18 @@ navigation: auto; } -:root { - --surface-document: light-dark(white, var(--surface-1)); -} - -html { - background-color: var(--surface-document); -} - -pre { - padding-block: var(--size-3); - padding-inline: var(--size-4); - border-radius: var(--radius-3); -} +@layer components.page { + :root { + --surface-document: light-dark(white, var(--surface-1)); + } -.astro-code { - --astro-code-color-text: var(--text-1); - --astro-code-color-background: var(--surface-2); -} - -[data-theme="light"] .astro-code { - --astro-code-token-function: var(--purple-8); - --astro-code-token-constant: var(--blue-9); - --astro-code-token-keyword: var(--pink-6); -} + html { + background-color: var(--surface-document); + } -[data-theme="dark"] .astro-code { - --astro-code-token-function: var(--green-3); - --astro-code-token-constant: var(--cyan-2); - --astro-code-token-keyword: var(--pink-4); + pre { + padding-block: var(--size-3); + padding-inline: var(--size-4); + border-radius: var(--radius-3); + } } \ No newline at end of file