Theme
A region that steps into one of the project's themes for everything it hosts. The Theme paints the ground, sets the ink and publishes the shadow its ground casts — and nothing else: the air around and inside it is the page's. Nothing inside it knows which theme it is in — every component reads its colour chains, and the theme fills the theme station.
Themes
Every theme of the project. The same heading, text and button take each theme's ground, ink and button colours, in all four appearance modes.
---
import Theme from "tsugite/Theme/Theme.astro";
import Heading from "tsugite/Heading/Heading.astro";
import Text from "tsugite/Text/Text.astro";
import LinkButton from "tsugite/Button/LinkButton.astro";
import { THEME_KEYS } from "tsugite/theme-default/themes.color.tokens.js";
---
{/* name is a key of the project's themes. Nothing inside knows which: the heading, the text
and the button read their colour chains, and the theme fills the theme station. The air
is the page's — a Theme owns no layout. */}
{THEME_KEYS.map((name) => (
<Theme name={name} class="example-ground">
<Heading element="h3" size="5" text={name} />
<Text text="Everything in here reads this theme." />
<LinkButton href="#themes" size="sm">Read on</LinkButton>
</Theme>
))}
<style>
.example-ground {
display: grid;
gap: var(--size-md);
justify-items: start;
padding: var(--size-2xl) var(--site-offset);
}
</style>A theme inside a theme
Every theme fills every slot of the theme station, so a nested theme keeps its own values and nothing of the outer one shows through.
theme-1
theme-2, inside: its own ground, ink and button.
{/* A theme inside a theme keeps its own values: every theme fills every slot, so nothing of
the outer one shows through. */}
<Theme name="theme-1" class="example-ground">
<Heading element="h3" size="5" text="theme-1" />
<Theme name="theme-2" class="example-ground">
<Text text="theme-2, inside: its own ground, ink and button." />
</Theme>
</Theme>
<style>
.example-ground {
display: grid;
gap: var(--size-md);
padding: var(--size-xl);
}
</style>Side by side
A Theme assumes nothing about its width. Two can share a row, 50/50 or any split; the split is the page's arrangement.
---
import Theme from "tsugite/Theme/Theme.astro";
import Heading from "tsugite/Heading/Heading.astro";
import Text from "tsugite/Text/Text.astro";
import LinkButton from "tsugite/Button/LinkButton.astro";
---
{/* A Theme assumes nothing about its width: two can share a row, 50/50 or any split. The
split is the page's arrangement. */}
<div class="split">
<Theme name="theme-1" class="example-ground">
<Heading element="h3" size="5" text="theme-1" />
<LinkButton href="#side-by-side" size="sm">Read on</LinkButton>
</Theme>
<Theme name="theme-3" class="example-ground">
<Heading element="h3" size="5" text="theme-3" />
<LinkButton href="#side-by-side" size="sm">Read on</LinkButton>
</Theme>
</div>
<style>
.split {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
}
.example-ground {
display: grid;
gap: var(--size-md);
justify-items: start;
padding: var(--size-xl);
}
</style>The ground's shadow
A Theme publishes the shadow its ground casts, resolved where it is painted. A card on it casts that ink, even when the card is in another theme, and mixes in a glow of its own surface.
On theme-2: its ink.
A theme-4 card on theme-3: the ground's ink, and a glow of theme-4.
{/* A Theme publishes the shadow it casts (--ground-shadow-n, per shadow of the ramp), resolved
where it is painted.
A card lying on it casts that ink — even a card in another theme — and mixes in
a glow of its own surface. The nearest Theme wins. */}
<Theme name="theme-2" class="example-ground">
<Card shadow="shadow-2">
<Text text="On theme-2: its ink." />
</Card>
</Theme>
<Theme name="theme-3" class="example-ground">
<Card shadow="shadow-2" data-theme="theme-4">
<Text text="A theme-4 card on theme-3: the ground's ink, and a glow of theme-4." />
</Card>
</Theme>
<style>
.example-ground {
padding: var(--size-2xl) var(--site-offset);
}
</style>Only the project's themes exist
A Theme needs a name, and only the project's themes exist. A key it does not have is refused in development rather than rendered as a guess.
{/* Only the project's themes exist, and a Theme needs one. Either way it is refused in
development rather than rendered as a guess. */}
<Theme name="theme-9">
<Text text="Never shown." />
</Theme>Test bench
The Theme fixture, mounted unchanged.
Theme
Themes
theme-3
Mode-stable by its table: the same in light and dark.
Nesting
theme-1
A theme inside a theme keeps its own values: it fills every slot.