Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8774ef62ce | ||
|
|
e4f88485f2 | ||
|
|
03a1ce56d8 | ||
|
|
c5d7bdfef0 | ||
|
|
e09effa2ca | ||
|
|
148062ec28 | ||
|
|
3af449e9f9 |
No files matched your search
@@ -21,7 +21,7 @@ archived on 2026-10-23 (nothing imported them).
|
|||||||
|
|
||||||
Shared here: the base HTML skeleton, navbar, sidebar (generic nav-item
|
Shared here: the base HTML skeleton, navbar, sidebar (generic nav-item
|
||||||
list), footer, and the CSS rules that style exactly those elements
|
list), footer, and the CSS rules that style exactly those elements
|
||||||
(`static/style.css` — theme root variables, navbar, `.sidebar .nav-link`
|
(`static/style.css` — theme tokens and the Bootstrap bridge, navbar, `.sidebar .nav-link`
|
||||||
incl. the `#0b82b8` inactive-link color, footer, flash-banner alerts).
|
incl. the `#0b82b8` inactive-link color, footer, flash-banner alerts).
|
||||||
|
|
||||||
Stays in each consuming project: page-specific templates
|
Stays in each consuming project: page-specific templates
|
||||||
@@ -30,46 +30,82 @@ forms, buttons, markdown, ...), and anything else specific to that tool.
|
|||||||
|
|
||||||
## Theming
|
## Theming
|
||||||
|
|
||||||
`static/style.css`'s palette is exposed as `--yw-*` CSS custom properties
|
Two independent axes, both set on `<html>` and resolved on the server:
|
||||||
(`--yw-bg`, `--yw-text`, `--yw-chrome-bg`, `--yw-accent`, `--yw-nav-link`,
|
|
||||||
`--yw-success-*`/`--yw-danger-*`, ...) rather than baked directly into
|
|
||||||
each rule — a documented, reusable theme, not an implementation detail.
|
|
||||||
|
|
||||||
Three themes ship, selected by `PageHeader.Theme` (see `layout.go`),
|
| Axis | `PageHeader` field | Attribute | Values |
|
||||||
which renders as `<html data-theme="...">`:
|
|---|---|---|---|
|
||||||
|
| Mode | `Theme` | `data-theme` | `layout.ThemeDark` (also `""`, unset), `ThemeLight`, `ThemeSystem` (follows `prefers-color-scheme`) |
|
||||||
|
| Colors | `Palette` | `data-palette` | `layout.PaletteDefault` (also `""`), `PaletteGraphite` (grey/violet, after nessajina.tv), `PaletteContrast` (high contrast) |
|
||||||
|
|
||||||
| `Theme` | Look |
|
A consumer that sets neither keeps the original dark look.
|
||||||
|---|---|
|
|
||||||
| `""` (unset) | dark, the bare `:root` block, i.e. what every consumer had before themes existed |
|
|
||||||
| `layout.ThemeDark` (`"dark"`) | dark, the same values |
|
|
||||||
| `layout.ThemeLight` (`"light"`) | light |
|
|
||||||
| `layout.ThemeSystem` (`"system"`) | follows the browser's `prefers-color-scheme` |
|
|
||||||
|
|
||||||
Every block also sets `color-scheme`, so native controls and scrollbars
|
How `static/style.css` does it:
|
||||||
match the palette.
|
|
||||||
|
|
||||||
- The light values appear twice in `static/style.css` (as
|
- **Every color token is written once**, as `--yw-x: light-dark(<light>,
|
||||||
`:root[data-theme="light"]` and inside `@media (prefers-color-scheme:
|
<dark>)`. The mode only sets `color-scheme` (`dark`, `light`, or
|
||||||
light)` for `"system"`). `TestThemeBlocksInSync` fails if the two drift
|
`light dark` for system), so no mode repeats another's values and
|
||||||
apart or if a theme is missing a property.
|
"system" needs no duplicated media-query block. Needs a browser from
|
||||||
- `--yw-nav-link` is `#0b82b8` in every theme. It is a cross-project
|
2024 or later (`light-dark()`, `color-mix()`).
|
||||||
design token (see the meta-repo `AGENTS.md`).
|
- **Triplets and images** (`--yw-*-rgb` for Bootstrap's `rgba(var(...),
|
||||||
- This module does **not** persist a choice (no cookie, localStorage or
|
a)`, and the few `url()` icons Bootstrap swaps in dark mode) can't use
|
||||||
JS). That is the consuming project's job: keep the preference
|
`light-dark()`. They pick with the mode switches `--yw-if-light`/
|
||||||
(e.g. in a cookie set by a POST form), resolve it server-side into
|
`--yw-if-dark`: `var(--yw-if-light, <light>) var(--yw-if-dark,
|
||||||
`Theme` before rendering, and offer the switch itself (e.g. via
|
<dark>)`.
|
||||||
`NavbarRightExtra`). Resolving server-side avoids a flash of the wrong
|
- **A palette is one `:root[data-palette="..."]` block** that lists only
|
||||||
theme without an inline script, so it works under a strict
|
what it changes from the default (bare `:root`) block.
|
||||||
`script-src 'self'` CSP. `yareco` is the reference consumer.
|
- **Bootstrap follows the palette:** its theme-dependent `--bs-*`
|
||||||
- A consumer whose own stylesheet needs theme-dependent colors defines
|
variables (body, emphasis, secondary/tertiary, links, borders, the
|
||||||
its **own** custom properties with the same selector structure
|
`*-subtle`/`*-emphasis` colors, form validation) and the components
|
||||||
(`:root, [data-theme="dark"], [data-theme="system"]` / `[data-theme="light"]`
|
that hard-code its primary blue (`.btn-primary`, `.list-group`,
|
||||||
/ the `prefers-color-scheme: light` media query). Don't redefine
|
`.form-check-input:checked`, focus rings, ...) are mapped onto
|
||||||
`--yw-*` in one consumer's stylesheet: that reskins only that
|
`--yw-*`. Bootstrap's own `data-bs-theme` is not used (it has no
|
||||||
project and makes it drift from everyone else sharing this file.
|
"system" mode without a script); a consumer's local
|
||||||
- **Adding another theme:** add its own `:root[data-theme="..."]` block
|
`data-bs-theme="dark"` on one element still works.
|
||||||
with the same property list, a constant in `layout.go`, and a case in
|
- `TestPaletteTokens` checks that every palette in `layout.Palettes` has
|
||||||
`TestThemeAttribute`.
|
a block, every color is one `light-dark()` pair, every `-rgb` triplet
|
||||||
|
matches its color, and a palette only overrides default tokens.
|
||||||
|
- `--yw-nav-link` is `#0b82b8` in the default palette in both modes (the
|
||||||
|
cross-project design token, see the meta-repo `AGENTS.md`). The other
|
||||||
|
palettes use their own nav-link color: blue would clash with
|
||||||
|
graphite's violet, and it lacks contrast on black.
|
||||||
|
|
||||||
|
Tokens a consumer's own stylesheet can use: `--yw-bg`, `--yw-surface`,
|
||||||
|
`--yw-surface-2`, `--yw-text`, `--yw-text-strong`, `--yw-muted`,
|
||||||
|
`--yw-border`, `--yw-chrome-bg`/`-border`, `--yw-brand`, `--yw-accent`,
|
||||||
|
`--yw-link`/`-hover`, `--yw-primary`, `--yw-on-primary`,
|
||||||
|
`--yw-{success,danger,warning,info}-{bg,border,text}`, plus the `-rgb`
|
||||||
|
triplets of bg/surface/text/accent/link/primary. For its own
|
||||||
|
theme-dependent colors a consumer writes `light-dark()` as well, never
|
||||||
|
redefines `--yw-*` (that would reskin only that project). The older
|
||||||
|
pattern, separate `[data-theme="..."]` blocks, keeps working.
|
||||||
|
|
||||||
|
### Theme/palette menu
|
||||||
|
|
||||||
|
The module can store the visitor's choice itself, without any script
|
||||||
|
(works under a strict `script-src 'self'` CSP):
|
||||||
|
|
||||||
|
```go
|
||||||
|
mux.Handle("POST /appearance", layout.AppearanceHandler(basePath))
|
||||||
|
...
|
||||||
|
hdr := layout.PageHeader{BasePath: basePath, AppearancePath: "/appearance", ...}
|
||||||
|
hdr.ApplyAppearance(r) // Theme/Palette from the cookies, AppearanceBack = current page
|
||||||
|
```
|
||||||
|
|
||||||
|
`AppearancePath` set, the navbar shows a `<details>` dropdown (labels in
|
||||||
|
German when `Lang` starts with `de`) with one POST form whose buttons
|
||||||
|
submit `theme` or `palette`. `AppearanceHandler` stores the choice in
|
||||||
|
the cookies `yw_theme`/`yw_palette` (path `BasePath/`, a year,
|
||||||
|
`HttpOnly`, `SameSite=Lax`) and redirects to `back`, but only to a path
|
||||||
|
inside the UI. Any other method gets 405. `ApplyAppearance` ignores
|
||||||
|
unknown cookie values, so whatever the consumer set before stays the
|
||||||
|
default. A consumer whose middleware wants a CSRF token on every POST
|
||||||
|
puts the hidden field into `AppearanceFormHTML`, which is rendered
|
||||||
|
inside the menu's form. A consumer with its own switch (e.g. `yareco`'s)
|
||||||
|
can keep it and just set `Theme`/`Palette`.
|
||||||
|
|
||||||
|
**Adding a palette:** a `:root[data-palette="..."]` block in
|
||||||
|
`static/style.css`, a constant and an entry in `Palettes` in
|
||||||
|
`appearance.go`. `TestPaletteTokens` reports anything missing.
|
||||||
|
|
||||||
## Consuming this module
|
## Consuming this module
|
||||||
|
|
||||||
@@ -88,7 +124,8 @@ module).
|
|||||||
|
|
||||||
## Migration status
|
## Migration status
|
||||||
|
|
||||||
Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`).
|
Eight projects use it, all on `v0.2.3` (2026-10-29). `yareco` also uses
|
||||||
|
the built-in theme menu; `yakwui` still has its own switch.
|
||||||
|
|
||||||
| Project | Meta-repo | Status |
|
| Project | Meta-repo | Status |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
@@ -99,6 +136,7 @@ Seven projects use it (`yet serve` on `v0.1.7`, the others on `v0.1.6`).
|
|||||||
| `yamase-web` | yamase | migrated |
|
| `yamase-web` | yamase | migrated |
|
||||||
| `yamocir` | yetano | migrated |
|
| `yamocir` | yetano | migrated |
|
||||||
| `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) |
|
| `yet` (`yet serve`) | yetano | built on it (a server-rendered shell whose content area a small JS app fills) |
|
||||||
|
| `yareco` | yetano | built on it (reference consumer for themes) |
|
||||||
|
|
||||||
`yaais` was evaluated too and deliberately NOT migrated: it's a
|
`yaais` was evaluated too and deliberately NOT migrated: it's a
|
||||||
client-rendered SPA (static `index.html` + vanilla JS), not a
|
client-rendered SPA (static `index.html` + vanilla JS), not a
|
||||||
@@ -116,7 +154,7 @@ concurrent-edit conflict during the initial rollout) and can produce a
|
|||||||
force-move an existing tag again for any future change — always cut a
|
force-move an existing tag again for any future change — always cut a
|
||||||
new one, even for a one-line fix.
|
new one, even for a one-line fix.
|
||||||
|
|
||||||
## PageHeader fields (current as of v0.1.10)
|
## PageHeader fields (current as of v0.2.5)
|
||||||
|
|
||||||
`Title`, `AppName` (lowercase product name for `<title>`/footer — not
|
`Title`, `AppName` (lowercase product name for `<title>`/footer — not
|
||||||
`Name`, which collides with a domain type's own `Name` field once
|
`Name`, which collides with a domain type's own `Name` field once
|
||||||
@@ -124,7 +162,8 @@ embedded in the same struct, as yakwui's viewmodel types do), `Lang`
|
|||||||
(`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see
|
(`<html lang>`, defaults to `"en"`), `Theme` (`<html data-theme>`, see
|
||||||
Theming), `Brand`, `BrandInitial`, `Subtitle`,
|
Theming), `Brand`, `BrandInitial`, `Subtitle`,
|
||||||
`BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`,
|
`BasePath`, `NavItems`/`ActiveNav`, `Flash`/`FlashKind`, `Username`,
|
||||||
`LogoutPath` (since v0.1.10 a `<form method="post">` with a submit
|
`Palette`, `AppearancePath`/`AppearanceBack` (since v0.2.0) and
|
||||||
|
`AppearanceFormHTML` (since v0.2.4, see Theming), `LogoutPath` (since v0.1.10 a `<form method="post">` with a submit
|
||||||
button styled like the former link, never a GET link: a logout reachable
|
button styled like the former link, never a GET link: a logout reachable
|
||||||
by GET can be triggered from any foreign page via an `<img>`/link and by
|
by GET can be triggered from any foreign page via an `<img>`/link and by
|
||||||
link prefetchers; the consumer registers the route as `POST` only and
|
link prefetchers; the consumer registers the route as `POST` only and
|
||||||
@@ -136,4 +175,7 @@ brand link, e.g. a mobile sidebar-toggle button),
|
|||||||
`ExtraHeadHTML`/`ExtraBodyHTML`, and `BodyAttrs`/`SidebarAttrs` —
|
`ExtraHeadHTML`/`ExtraBodyHTML`, and `BodyAttrs`/`SidebarAttrs` —
|
||||||
`template.HTMLAttr`, not `template.HTML` — raw extra attributes on
|
`template.HTMLAttr`, not `template.HTML` — raw extra attributes on
|
||||||
`<body>` and the sidebar `<nav>` for a consumer's own client-side
|
`<body>` and the sidebar `<nav>` for a consumer's own client-side
|
||||||
framework state (e.g. yakwui's Alpine.js collapsible sidebar).
|
framework state (e.g. yakwui's Alpine.js collapsible sidebar). A page
|
||||||
|
without a sidebar (a login page) sets `BodyAttrs` to
|
||||||
|
`` ` class="no-sidebar"` ``: since v0.2.5 `static/style.css` then hides
|
||||||
|
the sidebar column and gives `<main>` the full width.
|
||||||
+181
@@ -0,0 +1,181 @@
|
|||||||
|
package layout
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Values for PageHeader.Palette; each has its own block in
|
||||||
|
// static/style.css. "" is PaletteDefault.
|
||||||
|
const (
|
||||||
|
PaletteDefault = "default"
|
||||||
|
PaletteGraphite = "graphite" // grey and violet, after nessajina.tv
|
||||||
|
PaletteContrast = "contrast" // high contrast
|
||||||
|
)
|
||||||
|
|
||||||
|
// Cookies AppearanceHandler sets and ApplyAppearance reads. Scoped to
|
||||||
|
// the consumer's BasePath, so two dashboards on one host keep their own
|
||||||
|
// choice.
|
||||||
|
const (
|
||||||
|
ThemeCookie = "yw_theme"
|
||||||
|
PaletteCookie = "yw_palette"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Choice is one entry of the appearance menu.
|
||||||
|
type Choice struct {
|
||||||
|
ID string
|
||||||
|
Label string // English
|
||||||
|
LabelDE string
|
||||||
|
Symbol string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Themes and Palettes are the choices ApplyAppearance and
|
||||||
|
// AppearanceHandler accept, in menu order.
|
||||||
|
var (
|
||||||
|
Themes = []Choice{
|
||||||
|
{ThemeSystem, "System", "System", "◐"},
|
||||||
|
{ThemeLight, "Light", "Hell", "☀"},
|
||||||
|
{ThemeDark, "Dark", "Dunkel", "☾"},
|
||||||
|
}
|
||||||
|
Palettes = []Choice{
|
||||||
|
{PaletteDefault, "Yetano", "Yetano", ""},
|
||||||
|
{PaletteGraphite, "Graphite", "Graphit", ""},
|
||||||
|
{PaletteContrast, "High contrast", "Hoher Kontrast", ""},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func known(choices []Choice, id string) bool {
|
||||||
|
for _, c := range choices {
|
||||||
|
if c.ID == id {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplyAppearance overrides h.Theme and h.Palette with the visitor's
|
||||||
|
// choice from the cookies AppearanceHandler sets (unknown values are
|
||||||
|
// ignored, so the consumer's own defaults stay), and records the
|
||||||
|
// current page as AppearanceBack for the menu's return trip. Call it
|
||||||
|
// after BasePath is set. Resolving this on the server lets the page
|
||||||
|
// arrive in the right colors without an inline script.
|
||||||
|
func (h *PageHeader) ApplyAppearance(r *http.Request) {
|
||||||
|
if c, err := r.Cookie(ThemeCookie); err == nil && known(Themes, c.Value) {
|
||||||
|
h.Theme = c.Value
|
||||||
|
}
|
||||||
|
if c, err := r.Cookie(PaletteCookie); err == nil && known(Palettes, c.Value) {
|
||||||
|
h.Palette = c.Value
|
||||||
|
}
|
||||||
|
// Only a whole leading BasePath segment is cut: behind
|
||||||
|
// http.StripPrefix the path is already relative, and "/r" must not
|
||||||
|
// eat the start of "/release-notes".
|
||||||
|
path := r.URL.Path
|
||||||
|
if h.BasePath != "" && (path == h.BasePath || strings.HasPrefix(path, h.BasePath+"/")) {
|
||||||
|
path = strings.TrimPrefix(path, h.BasePath)
|
||||||
|
}
|
||||||
|
if path == "" {
|
||||||
|
path = "/"
|
||||||
|
}
|
||||||
|
back := url.URL{Path: path, RawQuery: r.URL.RawQuery}
|
||||||
|
h.AppearanceBack = back.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppearanceHandler stores a theme and/or palette choice from a POST
|
||||||
|
// form (fields "theme", "palette", "back") in cookies and redirects to
|
||||||
|
// back, a BasePath-relative path inside this UI (anything else goes to
|
||||||
|
// the start page, so it is no open redirect). Register it for POST only
|
||||||
|
// at BasePath + PageHeader.AppearancePath; other methods get 405.
|
||||||
|
//
|
||||||
|
// No CSRF token: a foreign page could at worst change the colors.
|
||||||
|
func AppearanceHandler(basePath string) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != http.MethodPost {
|
||||||
|
w.Header().Set("Allow", http.MethodPost)
|
||||||
|
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
theme, palette := r.FormValue("theme"), r.FormValue("palette")
|
||||||
|
if (theme == "" && palette == "") ||
|
||||||
|
(theme != "" && !known(Themes, theme)) ||
|
||||||
|
(palette != "" && !known(Palettes, palette)) {
|
||||||
|
http.Error(w, "unknown theme or palette", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
set := func(name, value string) {
|
||||||
|
http.SetCookie(w, &http.Cookie{Name: name, Value: value, Path: basePath + "/",
|
||||||
|
MaxAge: 365 * 24 * 3600, HttpOnly: true, SameSite: http.SameSiteLaxMode})
|
||||||
|
}
|
||||||
|
if theme != "" {
|
||||||
|
set(ThemeCookie, theme)
|
||||||
|
}
|
||||||
|
if palette != "" {
|
||||||
|
set(PaletteCookie, palette)
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, basePath+localPath(r.FormValue("back")), http.StatusSeeOther)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// localPath returns back if it is a path (with query) inside this UI,
|
||||||
|
// otherwise "/".
|
||||||
|
func localPath(back string) string {
|
||||||
|
u, err := url.Parse(back)
|
||||||
|
if err != nil || u.Scheme != "" || u.Host != "" || u.User != nil ||
|
||||||
|
!strings.HasPrefix(back, "/") || strings.HasPrefix(back, "//") ||
|
||||||
|
strings.ContainsAny(back, "\\\r\n") {
|
||||||
|
return "/"
|
||||||
|
}
|
||||||
|
return back
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppearanceItem is one button of the rendered appearance menu.
|
||||||
|
type AppearanceItem struct {
|
||||||
|
ID, Label, Symbol string
|
||||||
|
Current bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppearanceMenuData is what the navbar template renders the menu from.
|
||||||
|
type AppearanceMenuData struct {
|
||||||
|
Current AppearanceItem // the active theme, shown on the closed menu
|
||||||
|
ThemeHeading, PaletteHeading string
|
||||||
|
Themes, Palettes []AppearanceItem
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppearanceMenu builds the menu's data, labeled in German when Lang
|
||||||
|
// starts with "de", otherwise in English. The navbar template calls it.
|
||||||
|
func (h PageHeader) AppearanceMenu() AppearanceMenuData {
|
||||||
|
de := strings.HasPrefix(h.Lang, "de")
|
||||||
|
items := func(choices []Choice, current string) []AppearanceItem {
|
||||||
|
out := make([]AppearanceItem, len(choices))
|
||||||
|
for i, c := range choices {
|
||||||
|
label := c.Label
|
||||||
|
if de {
|
||||||
|
label = c.LabelDE
|
||||||
|
}
|
||||||
|
out[i] = AppearanceItem{ID: c.ID, Label: label, Symbol: c.Symbol, Current: c.ID == current}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
theme, palette := h.Theme, h.Palette
|
||||||
|
if theme == "" {
|
||||||
|
theme = ThemeDark
|
||||||
|
}
|
||||||
|
if palette == "" {
|
||||||
|
palette = PaletteDefault
|
||||||
|
}
|
||||||
|
m := AppearanceMenuData{
|
||||||
|
Themes: items(Themes, theme),
|
||||||
|
Palettes: items(Palettes, palette),
|
||||||
|
ThemeHeading: "Theme",
|
||||||
|
PaletteHeading: "Palette",
|
||||||
|
}
|
||||||
|
if de {
|
||||||
|
m.ThemeHeading, m.PaletteHeading = "Modus", "Farben"
|
||||||
|
}
|
||||||
|
for _, t := range m.Themes {
|
||||||
|
if t.Current {
|
||||||
|
m.Current = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
package layout
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// paletteBlocks returns the --yw-* declarations of every top-level
|
||||||
|
// :root block in static/style.css that declares palette tokens, keyed by
|
||||||
|
// palette ID (the bare :root block is PaletteDefault).
|
||||||
|
func paletteBlocks(t *testing.T) map[string]map[string]string {
|
||||||
|
t.Helper()
|
||||||
|
css, err := staticFS.ReadFile("static/style.css")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
blocks := map[string]map[string]string{}
|
||||||
|
rxBlock := regexp.MustCompile(`(?m)^(:root[^{]*)\{([^}]*)\}`)
|
||||||
|
rxDecl := regexp.MustCompile(`(?m)^\s*(--yw-[a-z0-9-]+):\s*(.*?);\s*$`)
|
||||||
|
for _, m := range rxBlock.FindAllStringSubmatch(string(css), -1) {
|
||||||
|
sel := strings.TrimSpace(m[1])
|
||||||
|
var id string
|
||||||
|
switch {
|
||||||
|
case sel == ":root":
|
||||||
|
id = PaletteDefault
|
||||||
|
case strings.HasPrefix(sel, `:root[data-palette="`):
|
||||||
|
id = strings.TrimSuffix(strings.TrimPrefix(sel, `:root[data-palette="`), `"]`)
|
||||||
|
default:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
decls := map[string]string{}
|
||||||
|
for _, d := range rxDecl.FindAllStringSubmatch(m[2], -1) {
|
||||||
|
if !strings.HasPrefix(d[1], "--yw-if-") {
|
||||||
|
decls[d[1]] = d[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(decls) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if blocks[id] != nil {
|
||||||
|
t.Fatalf("style.css: palette %q declared twice", id)
|
||||||
|
}
|
||||||
|
blocks[id] = decls
|
||||||
|
}
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
func hexTriplet(h string) string {
|
||||||
|
var r, g, b int
|
||||||
|
fmt.Sscanf(h, "#%02x%02x%02x", &r, &g, &b)
|
||||||
|
return fmt.Sprintf("%d, %d, %d", r, g, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestPaletteTokens checks the palette blocks of static/style.css: every
|
||||||
|
// palette in Palettes has one; each color is one light-dark() pair, so
|
||||||
|
// no mode repeats another's values; each *-rgb triplet matches its
|
||||||
|
// color; a palette only overrides tokens the default declares; and the
|
||||||
|
// default keeps the cross-project nav-link color.
|
||||||
|
func TestPaletteTokens(t *testing.T) {
|
||||||
|
blocks := paletteBlocks(t)
|
||||||
|
for _, p := range Palettes {
|
||||||
|
if blocks[p.ID] == nil {
|
||||||
|
t.Errorf("style.css: no block for palette %q", p.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(blocks) != len(Palettes) {
|
||||||
|
t.Errorf("style.css has %d palette blocks, Palettes lists %d", len(blocks), len(Palettes))
|
||||||
|
}
|
||||||
|
|
||||||
|
rxColor := regexp.MustCompile(`^light-dark\((#[0-9a-f]{6}), (#[0-9a-f]{6})\)$`)
|
||||||
|
rxTriplet := regexp.MustCompile(`^var\(--yw-if-light, (\d+, \d+, \d+)\) var\(--yw-if-dark, (\d+, \d+, \d+)\)$`)
|
||||||
|
def := blocks[PaletteDefault]
|
||||||
|
for id, decls := range blocks {
|
||||||
|
for name, value := range decls {
|
||||||
|
if _, ok := def[name]; !ok {
|
||||||
|
t.Errorf("palette %q: %s is not a default token", id, name)
|
||||||
|
}
|
||||||
|
if base, ok := strings.CutSuffix(name, "-rgb"); ok {
|
||||||
|
tm := rxTriplet.FindStringSubmatch(value)
|
||||||
|
cm := rxColor.FindStringSubmatch(decls[base])
|
||||||
|
if tm == nil || cm == nil {
|
||||||
|
t.Errorf("palette %q: %s = %q needs %s in the same block", id, name, value, base)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if tm[1] != hexTriplet(cm[1]) || tm[2] != hexTriplet(cm[2]) {
|
||||||
|
t.Errorf("palette %q: %s = %q does not match %s = %q", id, name, value, base, decls[base])
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !rxColor.MatchString(value) {
|
||||||
|
t.Errorf("palette %q: %s = %q, want light-dark(#rrggbb, #rrggbb)", id, name, value)
|
||||||
|
}
|
||||||
|
if _, hasRGB := def[name+"-rgb"]; hasRGB {
|
||||||
|
if _, ok := decls[name+"-rgb"]; !ok {
|
||||||
|
t.Errorf("palette %q: overrides %s but not %s-rgb", id, name, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if got, want := def["--yw-nav-link"], "light-dark(#0b82b8, #0b82b8)"; got != want {
|
||||||
|
t.Errorf("default --yw-nav-link = %q, want %q (cross-project design token)", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPaletteAttribute(t *testing.T) {
|
||||||
|
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("NewRenderer: %v", err)
|
||||||
|
}
|
||||||
|
for palette, want := range map[string]string{
|
||||||
|
"": `<html lang="en" data-theme="light">`,
|
||||||
|
PaletteGraphite: `<html lang="en" data-theme="light" data-palette="graphite">`,
|
||||||
|
} {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := r.Page(&buf, "dashboard", PageHeader{Theme: ThemeLight, Palette: palette}); err != nil {
|
||||||
|
t.Fatalf("Page: %v", err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(buf.String(), want) {
|
||||||
|
t.Errorf("palette %q: rendered output missing %q\n---\n%s", palette, want, buf.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestApplyAppearance(t *testing.T) {
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/ui/tasks?f=1", nil)
|
||||||
|
req.AddCookie(&http.Cookie{Name: ThemeCookie, Value: ThemeLight})
|
||||||
|
req.AddCookie(&http.Cookie{Name: PaletteCookie, Value: "nope"})
|
||||||
|
h := PageHeader{BasePath: "/ui", Theme: ThemeSystem, Palette: PaletteContrast}
|
||||||
|
h.ApplyAppearance(req)
|
||||||
|
if h.Theme != ThemeLight {
|
||||||
|
t.Errorf("Theme = %q, want %q from the cookie", h.Theme, ThemeLight)
|
||||||
|
}
|
||||||
|
if h.Palette != PaletteContrast {
|
||||||
|
t.Errorf("Palette = %q, want the consumer default %q (cookie value unknown)", h.Palette, PaletteContrast)
|
||||||
|
}
|
||||||
|
if h.AppearanceBack != "/tasks?f=1" {
|
||||||
|
t.Errorf("AppearanceBack = %q, want %q", h.AppearanceBack, "/tasks?f=1")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Behind http.StripPrefix the path is already relative to BasePath.
|
||||||
|
for path, want := range map[string]string{"/release-notes": "/release-notes", "/r": "/", "/r/x": "/x"} {
|
||||||
|
h := PageHeader{BasePath: "/r"}
|
||||||
|
h.ApplyAppearance(httptest.NewRequest(http.MethodGet, path, nil))
|
||||||
|
if h.AppearanceBack != want {
|
||||||
|
t.Errorf("BasePath /r, path %s: AppearanceBack = %q, want %q", path, h.AppearanceBack, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAppearanceHandler(t *testing.T) {
|
||||||
|
h := AppearanceHandler("/ui")
|
||||||
|
post := func(form url.Values) *httptest.ResponseRecorder {
|
||||||
|
req := httptest.NewRequest(http.MethodPost, "/ui/appearance", strings.NewReader(form.Encode()))
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
h.ServeHTTP(rec, req)
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
|
||||||
|
rec := post(url.Values{"palette": {PaletteGraphite}, "back": {"/tasks?f=1"}})
|
||||||
|
if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/ui/tasks?f=1" {
|
||||||
|
t.Errorf("palette: got %d to %q, want 303 to /ui/tasks?f=1", rec.Code, rec.Header().Get("Location"))
|
||||||
|
}
|
||||||
|
cookies := rec.Result().Cookies()
|
||||||
|
if len(cookies) != 1 || cookies[0].Name != PaletteCookie || cookies[0].Value != PaletteGraphite ||
|
||||||
|
cookies[0].Path != "/ui/" || !cookies[0].HttpOnly {
|
||||||
|
t.Errorf("palette: cookies = %+v", cookies)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, back := range []string{"https://evil.example/", "//evil.example/", "/\\evil.example", "tasks", ""} {
|
||||||
|
rec := post(url.Values{"theme": {ThemeDark}, "back": {back}})
|
||||||
|
if loc := rec.Header().Get("Location"); loc != "/ui/" {
|
||||||
|
t.Errorf("back %q: redirected to %q, want /ui/", back, loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, form := range []url.Values{{}, {"theme": {"pink"}}, {"palette": {"nope"}}} {
|
||||||
|
if rec := post(form); rec.Code != http.StatusBadRequest {
|
||||||
|
t.Errorf("form %v: got %d, want 400", form, rec.Code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rec = httptest.NewRecorder()
|
||||||
|
h.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/ui/appearance?theme=dark", nil))
|
||||||
|
if rec.Code != http.StatusMethodNotAllowed || rec.Header().Get("Allow") != http.MethodPost {
|
||||||
|
t.Errorf("GET: got %d, Allow %q; want 405, POST", rec.Code, rec.Header().Get("Allow"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAppearanceMenu(t *testing.T) {
|
||||||
|
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("NewRenderer: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := r.Page(&buf, "dashboard", PageHeader{Title: "Dashboard"}); err != nil {
|
||||||
|
t.Fatalf("Page: %v", err)
|
||||||
|
}
|
||||||
|
if strings.Contains(buf.String(), "yw-appearance") {
|
||||||
|
t.Errorf("menu rendered without AppearancePath\n---\n%s", buf.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.Reset()
|
||||||
|
data := PageHeader{Title: "Dashboard", Lang: "de", BasePath: "/ui", AppearancePath: "/appearance",
|
||||||
|
AppearanceBack: "/tasks", Theme: ThemeLight, Palette: PaletteGraphite,
|
||||||
|
AppearanceFormHTML: `<input type="hidden" name="csrf_token" value="t0k">`}
|
||||||
|
if err := r.Page(&buf, "dashboard", data); err != nil {
|
||||||
|
t.Fatalf("Page: %v", err)
|
||||||
|
}
|
||||||
|
out := buf.String()
|
||||||
|
for _, want := range []string{
|
||||||
|
`<form method="post" action="/ui/appearance"`,
|
||||||
|
`name="back" value="/tasks"><input type="hidden" name="csrf_token" value="t0k">`,
|
||||||
|
`name="theme" value="light" aria-pressed="true"><span aria-hidden="true">☀</span> Hell</button>`,
|
||||||
|
`name="theme" value="dark" aria-pressed="false">`,
|
||||||
|
`name="palette" value="graphite" aria-pressed="true">Graphit</button>`,
|
||||||
|
`<h6>Farben</h6>`,
|
||||||
|
} {
|
||||||
|
if !strings.Contains(out, want) {
|
||||||
|
t.Errorf("rendered output missing %q\n---\n%s", want, out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ var staticFS embed.FS
|
|||||||
// base/navbar/sidebar/footer templates.
|
// base/navbar/sidebar/footer templates.
|
||||||
const LayoutGlob = "templates/layout/*.tmpl"
|
const LayoutGlob = "templates/layout/*.tmpl"
|
||||||
|
|
||||||
// Values for PageHeader.Theme; each has its own block in static/style.css.
|
// Values for PageHeader.Theme, the color mode; see static/style.css.
|
||||||
const (
|
const (
|
||||||
ThemeDark = "dark"
|
ThemeDark = "dark"
|
||||||
ThemeLight = "light"
|
ThemeLight = "light"
|
||||||
@@ -59,28 +59,41 @@ type PageHeader struct {
|
|||||||
// execution time, not at parse time.
|
// execution time, not at parse time.
|
||||||
AppName string
|
AppName string
|
||||||
Lang string // <html lang="...">; "" defaults to "en"
|
Lang string // <html lang="...">; "" defaults to "en"
|
||||||
// Theme selects which --yw-* token block static/style.css applies,
|
// Theme is the color mode, rendered as <html data-theme="...">:
|
||||||
// rendered as <html data-theme="...">: ThemeDark, ThemeLight or
|
// ThemeDark, ThemeLight or ThemeSystem (follows
|
||||||
// ThemeSystem (follows prefers-color-scheme). "" omits the attribute,
|
// prefers-color-scheme). "" omits the attribute, which is dark, so a
|
||||||
// which resolves to the bare :root values (dark), so a consumer that
|
// consumer that never sets Theme keeps its look.
|
||||||
// never sets Theme keeps its look. Persisting a user's choice is the
|
Theme string
|
||||||
// consumer's concern (see README.md's Theming section).
|
// Palette is the color set, rendered as <html data-palette="...">:
|
||||||
Theme string
|
// PaletteDefault, PaletteGraphite or PaletteContrast; "" is
|
||||||
Brand string // navbar brand text, e.g. "YASTA"
|
// PaletteDefault. ApplyAppearance fills Theme and Palette from the
|
||||||
BrandInitial string // single-letter favicon glyph, e.g. "y"
|
// visitor's cookies (see README.md's Theming section).
|
||||||
Subtitle string
|
Palette string
|
||||||
BasePath string
|
// AppearancePath is the BasePath-relative POST route of
|
||||||
NavItems []NavItem
|
// AppearanceHandler, e.g. "/appearance"; set, the navbar shows the
|
||||||
ActiveNav string
|
// theme/palette menu. AppearanceBack is the BasePath-relative page
|
||||||
Flash string
|
// the menu returns to (ApplyAppearance sets it).
|
||||||
FlashKind string // "ok" or "error"; meaningless if Flash == ""
|
AppearancePath string
|
||||||
Username string
|
AppearanceBack string
|
||||||
LogoutPath string // BasePath-relative, e.g. "/logout"; rendered as a POST form (never a GET link); "" hides it
|
// AppearanceFormHTML is extra markup inside the menu's POST form,
|
||||||
NavbarBeforeBrand template.HTML // extra markup rendered before the brand link, e.g. a mobile sidebar toggle
|
// e.g. a hidden CSRF token field for a consumer whose middleware
|
||||||
NavbarLeftExtra template.HTML // extra markup rendered after Subtitle in the navbar's left group
|
// demands one on every POST.
|
||||||
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group
|
AppearanceFormHTML template.HTML
|
||||||
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head>
|
Brand string // navbar brand text, e.g. "YASTA"
|
||||||
ExtraBodyHTML template.HTML // extra <script> tags appended before </body>
|
BrandInitial string // single-letter favicon glyph, e.g. "y"
|
||||||
|
Subtitle string
|
||||||
|
BasePath string
|
||||||
|
NavItems []NavItem
|
||||||
|
ActiveNav string
|
||||||
|
Flash string
|
||||||
|
FlashKind string // "ok" or "error"; meaningless if Flash == ""
|
||||||
|
Username string
|
||||||
|
LogoutPath string // BasePath-relative, e.g. "/logout"; rendered as a POST form (never a GET link); "" hides it
|
||||||
|
NavbarBeforeBrand template.HTML // extra markup rendered before the brand link, e.g. a mobile sidebar toggle
|
||||||
|
NavbarLeftExtra template.HTML // extra markup rendered after Subtitle in the navbar's left group
|
||||||
|
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group
|
||||||
|
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head>
|
||||||
|
ExtraBodyHTML template.HTML // extra <script> tags appended before </body>
|
||||||
// BodyAttrs/SidebarAttrs are raw extra attributes (include their own
|
// BodyAttrs/SidebarAttrs are raw extra attributes (include their own
|
||||||
// leading space, e.g. ` x-data="{ open: true }"`) spliced into
|
// leading space, e.g. ` x-data="{ open: true }"`) spliced into
|
||||||
// <body...> and the sidebar's <nav...> tag -- an escape hatch for a
|
// <body...> and the sidebar's <nav...> tag -- an escape hatch for a
|
||||||
|
|||||||
@@ -139,46 +139,6 @@ func TestPageUnknown(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestThemeBlocksInSync guards the hand-kept duplication in
|
|
||||||
// static/style.css: every theme declares the same --yw-* properties, and
|
|
||||||
// the "system" media-query block is identical to "light".
|
|
||||||
func TestThemeBlocksInSync(t *testing.T) {
|
|
||||||
css, err := staticFS.ReadFile("static/style.css")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
block := func(selector string) string {
|
|
||||||
s := string(css)
|
|
||||||
i := strings.Index(s, selector+" {")
|
|
||||||
if i < 0 {
|
|
||||||
t.Fatalf("style.css: no block %q", selector)
|
|
||||||
}
|
|
||||||
s = s[i+len(selector)+2:]
|
|
||||||
return s[:strings.Index(s, "}")]
|
|
||||||
}
|
|
||||||
decls := func(b string) (names, full []string) {
|
|
||||||
for _, line := range strings.Split(b, "\n") {
|
|
||||||
line = strings.TrimSpace(line)
|
|
||||||
if line == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
full = append(full, line)
|
|
||||||
names = append(names, strings.SplitN(line, ":", 2)[0])
|
|
||||||
}
|
|
||||||
return names, full
|
|
||||||
}
|
|
||||||
|
|
||||||
darkNames, _ := decls(block(`:root[data-theme="system"]`))
|
|
||||||
lightNames, light := decls(block(`:root[data-theme="light"]`))
|
|
||||||
_, system := decls(block(` :root[data-theme="system"]`))
|
|
||||||
if strings.Join(darkNames, ",") != strings.Join(lightNames, ",") {
|
|
||||||
t.Errorf("dark and light declare different properties:\ndark: %v\nlight: %v", darkNames, lightNames)
|
|
||||||
}
|
|
||||||
if strings.Join(light, "\n") != strings.Join(system, "\n") {
|
|
||||||
t.Errorf("light and prefers-color-scheme: light blocks differ:\nlight: %v\nsystem: %v", light, system)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestLogoutIsPostForm pins the navbar's logout control to a POST form:
|
// TestLogoutIsPostForm pins the navbar's logout control to a POST form:
|
||||||
// a GET link would let any foreign page (an <img>, a link prefetcher)
|
// a GET link would let any foreign page (an <img>, a link prefetcher)
|
||||||
// log the user out.
|
// log the user out.
|
||||||
|
|||||||
+414
-89
@@ -5,106 +5,348 @@
|
|||||||
project's own concern and lives in that project's own stylesheet,
|
project's own concern and lives in that project's own stylesheet,
|
||||||
loaded alongside this one -- see PageHeader.ExtraHeadHTML.
|
loaded alongside this one -- see PageHeader.ExtraHeadHTML.
|
||||||
|
|
||||||
The palette is exposed as --yw-* custom properties, not baked into
|
Theming has two independent axes, both set on <html> (see layout.go):
|
||||||
each rule -- a documented, reusable theme, not an implementation
|
|
||||||
detail. Three values for PageHeader.Theme (see layout.go), rendered
|
|
||||||
as <html data-theme="...">: "dark", "light", and "system" (follows
|
|
||||||
the browser's prefers-color-scheme). Unset Theme (every consumer
|
|
||||||
that never sets it) resolves to the bare :root block, i.e. dark --
|
|
||||||
today's exact look. A consumer's own stylesheet that needs
|
|
||||||
theme-dependent colors mirrors the same selector structure for its
|
|
||||||
own custom properties instead of redefining these -- see README.md's
|
|
||||||
Theming section. */
|
|
||||||
|
|
||||||
/* Dark: the default (bare :root), explicit "dark", and "system" unless
|
- data-theme (PageHeader.Theme): the mode -- "dark", "light" or
|
||||||
the media query below switches it to light. */
|
"system" (follows the browser's prefers-color-scheme). Unset is
|
||||||
:root,
|
dark, the look every consumer had before themes existed. The mode
|
||||||
:root[data-theme="dark"],
|
only sets color-scheme and the --yw-if-* switches below.
|
||||||
:root[data-theme="system"] {
|
- data-palette (PageHeader.Palette): the colors -- "default",
|
||||||
|
"graphite" or "contrast". Unset is "default".
|
||||||
|
|
||||||
|
Every color token is written once, as light-dark(<light>, <dark>), so
|
||||||
|
a palette is one block and no mode duplicates another's values. The
|
||||||
|
palette is exposed as --yw-* custom properties and bridged into
|
||||||
|
Bootstrap's own --bs-* variables further down, so Bootstrap's
|
||||||
|
components (tables, forms, links, ...) follow the theme too. See
|
||||||
|
README.md's Theming section. */
|
||||||
|
|
||||||
|
/* --- Mode --------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* --yw-if-light/--yw-if-dark pick between two values where
|
||||||
|
light-dark() can't: it only takes colors, not the r, g, b triplets
|
||||||
|
Bootstrap builds rgba() from or url() images. The active mode's
|
||||||
|
switch is "initial" (guaranteed-invalid), so var(--yw-if-dark, X)
|
||||||
|
falls back to X; the other one is empty, so its var() adds nothing:
|
||||||
|
--x: var(--yw-if-light, <light>) var(--yw-if-dark, <dark>); */
|
||||||
|
:root {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--yw-bg: #1a1d23;
|
--yw-if-dark: initial;
|
||||||
--yw-text: #d4d8e0;
|
--yw-if-light: ;
|
||||||
--yw-border: #333;
|
|
||||||
--yw-chrome-bg: #14171e;
|
|
||||||
--yw-chrome-border: #272d3a;
|
|
||||||
--yw-accent: #4fc3f7;
|
|
||||||
--yw-accent-rgb: 79, 195, 247;
|
|
||||||
--yw-nav-link: #0b82b8;
|
|
||||||
--yw-nav-link-hover-text: #c8d4e4;
|
|
||||||
--yw-subtitle: #5a7a9a;
|
|
||||||
--yw-subtitle-sep: #333c4a;
|
|
||||||
--yw-footer-text: #4a5a72;
|
|
||||||
--yw-success-bg: #192e22;
|
|
||||||
--yw-success-border: #2a5c3a;
|
|
||||||
--yw-success-text: #7ecf98;
|
|
||||||
--yw-danger-bg: #2e1820;
|
|
||||||
--yw-danger-border: #5c2a32;
|
|
||||||
--yw-danger-text: #e08090;
|
|
||||||
|
|
||||||
--bs-body-bg: var(--yw-bg);
|
|
||||||
--bs-body-color: var(--yw-text);
|
|
||||||
--bs-border-color: var(--yw-border);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Light: explicit "light", and "system" on a light-preferring browser.
|
|
||||||
The two blocks are kept identical by hand -- CSS can't share one
|
|
||||||
declaration block between a plain rule and a media query.
|
|
||||||
--yw-nav-link stays #0b82b8 (a cross-project design token, see the
|
|
||||||
meta-repo AGENTS.md); it reads fine on both backgrounds. */
|
|
||||||
:root[data-theme="light"] {
|
:root[data-theme="light"] {
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
--yw-bg: #f4f6f9;
|
--yw-if-dark: ;
|
||||||
--yw-text: #1f2530;
|
--yw-if-light: initial;
|
||||||
--yw-border: #d3d9e2;
|
}
|
||||||
--yw-chrome-bg: #ffffff;
|
|
||||||
--yw-chrome-border: #dde2ea;
|
|
||||||
--yw-accent: #0a72a3;
|
|
||||||
--yw-accent-rgb: 10, 114, 163;
|
|
||||||
--yw-nav-link: #0b82b8;
|
|
||||||
--yw-nav-link-hover-text: #0a4f72;
|
|
||||||
--yw-subtitle: #5a7088;
|
|
||||||
--yw-subtitle-sep: #c3cad5;
|
|
||||||
--yw-footer-text: #6a7a90;
|
|
||||||
--yw-success-bg: #e5f4ea;
|
|
||||||
--yw-success-border: #a6d4b4;
|
|
||||||
--yw-success-text: #1c5e33;
|
|
||||||
--yw-danger-bg: #fbe9ec;
|
|
||||||
--yw-danger-border: #e6b0b8;
|
|
||||||
--yw-danger-text: #9b2335;
|
|
||||||
|
|
||||||
--bs-body-bg: var(--yw-bg);
|
:root[data-theme="system"] {
|
||||||
--bs-body-color: var(--yw-text);
|
color-scheme: light dark;
|
||||||
--bs-border-color: var(--yw-border);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
:root[data-theme="system"] {
|
:root[data-theme="system"] {
|
||||||
color-scheme: light;
|
--yw-if-dark: ;
|
||||||
--yw-bg: #f4f6f9;
|
--yw-if-light: initial;
|
||||||
--yw-text: #1f2530;
|
|
||||||
--yw-border: #d3d9e2;
|
|
||||||
--yw-chrome-bg: #ffffff;
|
|
||||||
--yw-chrome-border: #dde2ea;
|
|
||||||
--yw-accent: #0a72a3;
|
|
||||||
--yw-accent-rgb: 10, 114, 163;
|
|
||||||
--yw-nav-link: #0b82b8;
|
|
||||||
--yw-nav-link-hover-text: #0a4f72;
|
|
||||||
--yw-subtitle: #5a7088;
|
|
||||||
--yw-subtitle-sep: #c3cad5;
|
|
||||||
--yw-footer-text: #6a7a90;
|
|
||||||
--yw-success-bg: #e5f4ea;
|
|
||||||
--yw-success-border: #a6d4b4;
|
|
||||||
--yw-success-text: #1c5e33;
|
|
||||||
--yw-danger-bg: #fbe9ec;
|
|
||||||
--yw-danger-border: #e6b0b8;
|
|
||||||
--yw-danger-text: #9b2335;
|
|
||||||
|
|
||||||
--bs-body-bg: var(--yw-bg);
|
|
||||||
--bs-body-color: var(--yw-text);
|
|
||||||
--bs-border-color: var(--yw-border);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Palettes ----------------------------------------------------- */
|
||||||
|
|
||||||
|
/* default: the original Yetano look. Also the base every other palette
|
||||||
|
starts from -- a palette block only lists what it changes. Each
|
||||||
|
*-rgb triplet repeats its color for Bootstrap's rgba(var(...), a);
|
||||||
|
TestPaletteTripletsMatch keeps the two in step. --yw-nav-link stays
|
||||||
|
#0b82b8 in both modes (a cross-project design token, see the
|
||||||
|
meta-repo AGENTS.md). */
|
||||||
|
:root {
|
||||||
|
--yw-bg: light-dark(#f4f6f9, #1a1d23);
|
||||||
|
--yw-bg-rgb: var(--yw-if-light, 244, 246, 249) var(--yw-if-dark, 26, 29, 35);
|
||||||
|
--yw-surface: light-dark(#ffffff, #20242c);
|
||||||
|
--yw-surface-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 32, 36, 44);
|
||||||
|
--yw-surface-2: light-dark(#e9edf2, #272c35);
|
||||||
|
--yw-surface-2-rgb: var(--yw-if-light, 233, 237, 242) var(--yw-if-dark, 39, 44, 53);
|
||||||
|
--yw-text: light-dark(#1f2530, #d4d8e0);
|
||||||
|
--yw-text-rgb: var(--yw-if-light, 31, 37, 48) var(--yw-if-dark, 212, 216, 224);
|
||||||
|
--yw-text-strong: light-dark(#000000, #f1f3f6);
|
||||||
|
--yw-text-strong-rgb: var(--yw-if-light, 0, 0, 0) var(--yw-if-dark, 241, 243, 246);
|
||||||
|
--yw-muted: light-dark(#5a6678, #8a94a6);
|
||||||
|
--yw-border: light-dark(#d3d9e2, #333333);
|
||||||
|
--yw-chrome-bg: light-dark(#ffffff, #14171e);
|
||||||
|
--yw-chrome-border: light-dark(#dde2ea, #272d3a);
|
||||||
|
--yw-brand: light-dark(#0a72a3, #4fc3f7);
|
||||||
|
--yw-accent: light-dark(#0a72a3, #4fc3f7);
|
||||||
|
--yw-accent-rgb: var(--yw-if-light, 10, 114, 163) var(--yw-if-dark, 79, 195, 247);
|
||||||
|
--yw-link: light-dark(#0a72a3, #4fc3f7);
|
||||||
|
--yw-link-rgb: var(--yw-if-light, 10, 114, 163) var(--yw-if-dark, 79, 195, 247);
|
||||||
|
--yw-link-hover: light-dark(#085a80, #81d4fa);
|
||||||
|
--yw-link-hover-rgb: var(--yw-if-light, 8, 90, 128) var(--yw-if-dark, 129, 212, 250);
|
||||||
|
--yw-primary: light-dark(#2595c8, #2595c8);
|
||||||
|
--yw-primary-rgb: var(--yw-if-light, 37, 149, 200) var(--yw-if-dark, 37, 149, 200);
|
||||||
|
--yw-on-primary: light-dark(#ffffff, #ffffff);
|
||||||
|
--yw-nav-link: light-dark(#0b82b8, #0b82b8);
|
||||||
|
--yw-nav-link-hover-text: light-dark(#0a4f72, #c8d4e4);
|
||||||
|
--yw-subtitle: light-dark(#5a7088, #5a7a9a);
|
||||||
|
--yw-subtitle-sep: light-dark(#c3cad5, #333c4a);
|
||||||
|
--yw-footer-text: light-dark(#6a7a90, #4a5a72);
|
||||||
|
--yw-success-bg: light-dark(#e5f4ea, #192e22);
|
||||||
|
--yw-success-border: light-dark(#a6d4b4, #2a5c3a);
|
||||||
|
--yw-success-text: light-dark(#1c5e33, #7ecf98);
|
||||||
|
--yw-danger-bg: light-dark(#fbe9ec, #2e1820);
|
||||||
|
--yw-danger-border: light-dark(#e6b0b8, #5c2a32);
|
||||||
|
--yw-danger-text: light-dark(#9b2335, #e08090);
|
||||||
|
--yw-warning-bg: light-dark(#fff4dc, #2e2716);
|
||||||
|
--yw-warning-border: light-dark(#f0d08a, #5c4a1f);
|
||||||
|
--yw-warning-text: light-dark(#7a5300, #e8c76a);
|
||||||
|
--yw-info-bg: light-dark(#e3f3fb, #15283a);
|
||||||
|
--yw-info-border: light-dark(#a8d8ef, #24506b);
|
||||||
|
--yw-info-text: light-dark(#0b5a80, #7fc8ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* graphite: grey and violet, after nessajina.tv -- near-black graphite
|
||||||
|
(#1a1a1a), violet accent (#aa88ff), deep violet (#463a59), and the
|
||||||
|
brand in the logo's brushed silver. */
|
||||||
|
:root[data-palette="graphite"] {
|
||||||
|
--yw-bg: light-dark(#f3f2f5, #1a1a1a);
|
||||||
|
--yw-bg-rgb: var(--yw-if-light, 243, 242, 245) var(--yw-if-dark, 26, 26, 26);
|
||||||
|
--yw-surface: light-dark(#ffffff, #222222);
|
||||||
|
--yw-surface-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 34, 34, 34);
|
||||||
|
--yw-surface-2: light-dark(#ebe9ef, #2a2a2a);
|
||||||
|
--yw-surface-2-rgb: var(--yw-if-light, 235, 233, 239) var(--yw-if-dark, 42, 42, 42);
|
||||||
|
--yw-text: light-dark(#232029, #e2e0e8);
|
||||||
|
--yw-text-rgb: var(--yw-if-light, 35, 32, 41) var(--yw-if-dark, 226, 224, 232);
|
||||||
|
--yw-text-strong: light-dark(#000000, #ffffff);
|
||||||
|
--yw-text-strong-rgb: var(--yw-if-light, 0, 0, 0) var(--yw-if-dark, 255, 255, 255);
|
||||||
|
--yw-muted: light-dark(#6b6675, #888888);
|
||||||
|
--yw-border: light-dark(#d6d2dd, #3a3a40);
|
||||||
|
--yw-chrome-bg: light-dark(#fbfafc, #141414);
|
||||||
|
--yw-chrome-border: light-dark(#e0dce6, #2a2a2a);
|
||||||
|
--yw-brand: light-dark(#463a59, #cfcfd8);
|
||||||
|
--yw-accent: light-dark(#6c4bc4, #aa88ff);
|
||||||
|
--yw-accent-rgb: var(--yw-if-light, 108, 75, 196) var(--yw-if-dark, 170, 136, 255);
|
||||||
|
--yw-link: light-dark(#6c4bc4, #aa88ff);
|
||||||
|
--yw-link-rgb: var(--yw-if-light, 108, 75, 196) var(--yw-if-dark, 170, 136, 255);
|
||||||
|
--yw-link-hover: light-dark(#523599, #c4adff);
|
||||||
|
--yw-link-hover-rgb: var(--yw-if-light, 82, 53, 153) var(--yw-if-dark, 196, 173, 255);
|
||||||
|
--yw-primary: light-dark(#6c4bc4, #7c5ce0);
|
||||||
|
--yw-primary-rgb: var(--yw-if-light, 108, 75, 196) var(--yw-if-dark, 124, 92, 224);
|
||||||
|
--yw-nav-link: light-dark(#7a5fd0, #9a82d6);
|
||||||
|
--yw-nav-link-hover-text: light-dark(#463a59, #d8ccff);
|
||||||
|
--yw-subtitle: light-dark(#6b6675, #8a8494);
|
||||||
|
--yw-subtitle-sep: light-dark(#cfcad6, #3a3a40);
|
||||||
|
--yw-footer-text: light-dark(#7a7584, #6a6670);
|
||||||
|
--yw-info-bg: light-dark(#efe9fb, #241e33);
|
||||||
|
--yw-info-border: light-dark(#cbbcef, #463a59);
|
||||||
|
--yw-info-text: light-dark(#463a59, #c4adff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* contrast: high contrast for readability -- black/white, a bright
|
||||||
|
cyan accent in dark mode, deep blue in light. Not the classic yellow:
|
||||||
|
in these dashboards yellow means "warning", and an accent in that
|
||||||
|
color reads as a status. */
|
||||||
|
:root[data-palette="contrast"] {
|
||||||
|
--yw-bg: light-dark(#ffffff, #000000);
|
||||||
|
--yw-bg-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 0, 0, 0);
|
||||||
|
--yw-surface: light-dark(#ffffff, #0a0a0a);
|
||||||
|
--yw-surface-rgb: var(--yw-if-light, 255, 255, 255) var(--yw-if-dark, 10, 10, 10);
|
||||||
|
--yw-surface-2: light-dark(#f0f0f0, #161616);
|
||||||
|
--yw-surface-2-rgb: var(--yw-if-light, 240, 240, 240) var(--yw-if-dark, 22, 22, 22);
|
||||||
|
--yw-text: light-dark(#000000, #ffffff);
|
||||||
|
--yw-text-rgb: var(--yw-if-light, 0, 0, 0) var(--yw-if-dark, 255, 255, 255);
|
||||||
|
--yw-text-strong: light-dark(#000000, #ffffff);
|
||||||
|
--yw-text-strong-rgb: var(--yw-if-light, 0, 0, 0) var(--yw-if-dark, 255, 255, 255);
|
||||||
|
--yw-muted: light-dark(#333333, #d0d0d0);
|
||||||
|
--yw-border: light-dark(#555555, #8a8a8a);
|
||||||
|
--yw-chrome-bg: light-dark(#ffffff, #000000);
|
||||||
|
--yw-chrome-border: light-dark(#555555, #8a8a8a);
|
||||||
|
--yw-brand: light-dark(#0040a0, #66e0ff);
|
||||||
|
--yw-accent: light-dark(#0040a0, #66e0ff);
|
||||||
|
--yw-accent-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
|
||||||
|
--yw-link: light-dark(#0040a0, #66e0ff);
|
||||||
|
--yw-link-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
|
||||||
|
--yw-link-hover: light-dark(#002a6b, #b3f0ff);
|
||||||
|
--yw-link-hover-rgb: var(--yw-if-light, 0, 42, 107) var(--yw-if-dark, 179, 240, 255);
|
||||||
|
--yw-primary: light-dark(#0040a0, #66e0ff);
|
||||||
|
--yw-primary-rgb: var(--yw-if-light, 0, 64, 160) var(--yw-if-dark, 102, 224, 255);
|
||||||
|
--yw-on-primary: light-dark(#ffffff, #000000);
|
||||||
|
--yw-nav-link: light-dark(#00549e, #a8e6ff);
|
||||||
|
--yw-nav-link-hover-text: light-dark(#000000, #ffffff);
|
||||||
|
--yw-subtitle: light-dark(#333333, #d0d0d0);
|
||||||
|
--yw-subtitle-sep: light-dark(#888888, #8a8a8a);
|
||||||
|
--yw-footer-text: light-dark(#333333, #d0d0d0);
|
||||||
|
--yw-success-text: light-dark(#0a4d1f, #8ff0a8);
|
||||||
|
--yw-danger-text: light-dark(#7a0010, #ffa0ae);
|
||||||
|
--yw-warning-text: light-dark(#5a3d00, #ffe08a);
|
||||||
|
--yw-info-text: light-dark(#003f5c, #a0dcff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Bootstrap bridge --------------------------------------------- */
|
||||||
|
|
||||||
|
/* Bootstrap's theme-dependent variables, taken from the palette. This
|
||||||
|
replaces Bootstrap's own data-bs-theme switch, which has no "follow
|
||||||
|
the system" mode without a script. Same selector weight as
|
||||||
|
Bootstrap's own :root block and loaded after it, so these win. */
|
||||||
|
:root {
|
||||||
|
--bs-body-bg: var(--yw-bg);
|
||||||
|
--bs-body-bg-rgb: var(--yw-bg-rgb);
|
||||||
|
--bs-body-color: var(--yw-text);
|
||||||
|
--bs-body-color-rgb: var(--yw-text-rgb);
|
||||||
|
--bs-emphasis-color: var(--yw-text-strong);
|
||||||
|
--bs-emphasis-color-rgb: var(--yw-text-strong-rgb);
|
||||||
|
--bs-secondary-color: color-mix(in srgb, var(--yw-text) 75%, transparent);
|
||||||
|
--bs-secondary-color-rgb: var(--yw-text-rgb);
|
||||||
|
--bs-secondary-bg: var(--yw-surface-2);
|
||||||
|
--bs-secondary-bg-rgb: var(--yw-surface-2-rgb);
|
||||||
|
--bs-tertiary-color: color-mix(in srgb, var(--yw-text) 50%, transparent);
|
||||||
|
--bs-tertiary-color-rgb: var(--yw-text-rgb);
|
||||||
|
--bs-tertiary-bg: var(--yw-surface);
|
||||||
|
--bs-tertiary-bg-rgb: var(--yw-surface-rgb);
|
||||||
|
--bs-heading-color: inherit;
|
||||||
|
--bs-link-color: var(--yw-link);
|
||||||
|
--bs-link-color-rgb: var(--yw-link-rgb);
|
||||||
|
--bs-link-hover-color: var(--yw-link-hover);
|
||||||
|
--bs-link-hover-color-rgb: var(--yw-link-hover-rgb);
|
||||||
|
--bs-border-color: var(--yw-border);
|
||||||
|
--bs-border-color-translucent: color-mix(in srgb, var(--yw-text) 15%, transparent);
|
||||||
|
--bs-focus-ring-color: color-mix(in srgb, var(--yw-accent) 25%, transparent);
|
||||||
|
--bs-code-color: light-dark(#d63384, #e685b5);
|
||||||
|
--bs-highlight-color: var(--yw-text);
|
||||||
|
--bs-highlight-bg: var(--yw-warning-bg);
|
||||||
|
|
||||||
|
--bs-primary: var(--yw-primary);
|
||||||
|
--bs-primary-rgb: var(--yw-primary-rgb);
|
||||||
|
--bs-primary-text-emphasis: var(--yw-accent);
|
||||||
|
--bs-primary-bg-subtle: color-mix(in srgb, var(--yw-accent) 15%, var(--yw-bg));
|
||||||
|
--bs-primary-border-subtle: color-mix(in srgb, var(--yw-accent) 45%, var(--yw-bg));
|
||||||
|
--bs-secondary-text-emphasis: var(--yw-muted);
|
||||||
|
--bs-secondary-bg-subtle: var(--yw-surface-2);
|
||||||
|
--bs-secondary-border-subtle: var(--yw-border);
|
||||||
|
--bs-success-text-emphasis: var(--yw-success-text);
|
||||||
|
--bs-success-bg-subtle: var(--yw-success-bg);
|
||||||
|
--bs-success-border-subtle: var(--yw-success-border);
|
||||||
|
--bs-danger-text-emphasis: var(--yw-danger-text);
|
||||||
|
--bs-danger-bg-subtle: var(--yw-danger-bg);
|
||||||
|
--bs-danger-border-subtle: var(--yw-danger-border);
|
||||||
|
--bs-warning-text-emphasis: var(--yw-warning-text);
|
||||||
|
--bs-warning-bg-subtle: var(--yw-warning-bg);
|
||||||
|
--bs-warning-border-subtle: var(--yw-warning-border);
|
||||||
|
--bs-info-text-emphasis: var(--yw-info-text);
|
||||||
|
--bs-info-bg-subtle: var(--yw-info-bg);
|
||||||
|
--bs-info-border-subtle: var(--yw-info-border);
|
||||||
|
--bs-light-text-emphasis: light-dark(#495057, #f8f9fa);
|
||||||
|
--bs-light-bg-subtle: light-dark(#fcfcfd, #343a40);
|
||||||
|
--bs-light-border-subtle: light-dark(#e9ecef, #495057);
|
||||||
|
--bs-dark-text-emphasis: light-dark(#495057, #dee2e6);
|
||||||
|
--bs-dark-bg-subtle: light-dark(#ced4da, #1a1d20);
|
||||||
|
--bs-dark-border-subtle: light-dark(#adb5bd, #343a40);
|
||||||
|
|
||||||
|
--bs-form-valid-color: var(--yw-success-text);
|
||||||
|
--bs-form-valid-border-color: var(--yw-success-text);
|
||||||
|
--bs-form-invalid-color: var(--yw-danger-text);
|
||||||
|
--bs-form-invalid-border-color: var(--yw-danger-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bootstrap writes its primary blue straight into these components
|
||||||
|
rather than reading --bs-primary, so they get the palette's here.
|
||||||
|
The default palette's #2595c8 is the button color every consumer's
|
||||||
|
own stylesheet used (as yasta), so those rules can go. */
|
||||||
|
.btn-primary {
|
||||||
|
--bs-btn-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-bg: var(--yw-primary);
|
||||||
|
--bs-btn-border-color: var(--yw-primary);
|
||||||
|
--bs-btn-hover-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-hover-bg: color-mix(in srgb, var(--yw-primary) 85%, #000000);
|
||||||
|
--bs-btn-hover-border-color: color-mix(in srgb, var(--yw-primary) 80%, #000000);
|
||||||
|
--bs-btn-focus-shadow-rgb: var(--yw-primary-rgb);
|
||||||
|
--bs-btn-active-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-active-bg: color-mix(in srgb, var(--yw-primary) 80%, #000000);
|
||||||
|
--bs-btn-active-border-color: color-mix(in srgb, var(--yw-primary) 75%, #000000);
|
||||||
|
--bs-btn-disabled-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-disabled-bg: var(--yw-primary);
|
||||||
|
--bs-btn-disabled-border-color: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-outline-primary {
|
||||||
|
--bs-btn-color: var(--yw-primary);
|
||||||
|
--bs-btn-border-color: var(--yw-primary);
|
||||||
|
--bs-btn-hover-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-hover-bg: var(--yw-primary);
|
||||||
|
--bs-btn-hover-border-color: var(--yw-primary);
|
||||||
|
--bs-btn-focus-shadow-rgb: var(--yw-primary-rgb);
|
||||||
|
--bs-btn-active-color: var(--yw-on-primary);
|
||||||
|
--bs-btn-active-bg: var(--yw-primary);
|
||||||
|
--bs-btn-active-border-color: var(--yw-primary);
|
||||||
|
--bs-btn-disabled-color: var(--yw-primary);
|
||||||
|
--bs-btn-disabled-border-color: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-group {
|
||||||
|
--bs-list-group-active-color: var(--yw-on-primary);
|
||||||
|
--bs-list-group-active-bg: var(--yw-primary);
|
||||||
|
--bs-list-group-active-border-color: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-pills {
|
||||||
|
--bs-nav-pills-link-active-color: var(--yw-on-primary);
|
||||||
|
--bs-nav-pills-link-active-bg: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
--bs-dropdown-link-active-color: var(--yw-on-primary);
|
||||||
|
--bs-dropdown-link-active-bg: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
--bs-pagination-focus-box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--yw-primary) 25%, transparent);
|
||||||
|
--bs-pagination-active-color: var(--yw-on-primary);
|
||||||
|
--bs-pagination-active-bg: var(--yw-primary);
|
||||||
|
--bs-pagination-active-border-color: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress,
|
||||||
|
.progress-stacked {
|
||||||
|
--bs-progress-bar-color: var(--yw-on-primary);
|
||||||
|
--bs-progress-bar-bg: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-check-input:checked {
|
||||||
|
background-color: var(--yw-primary);
|
||||||
|
border-color: var(--yw-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus,
|
||||||
|
.form-select:focus,
|
||||||
|
.form-check-input:focus {
|
||||||
|
border-color: color-mix(in srgb, var(--yw-primary) 50%, var(--yw-bg));
|
||||||
|
box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--yw-primary) 25%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-range::-webkit-slider-thumb { background-color: var(--yw-primary); }
|
||||||
|
.form-range::-moz-range-thumb { background-color: var(--yw-primary); }
|
||||||
|
|
||||||
|
/* The images Bootstrap swaps under data-bs-theme="dark": they carry a
|
||||||
|
fixed color, so each needs both versions. */
|
||||||
|
.form-select {
|
||||||
|
--bs-form-select-bg-img: var(--yw-if-light, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e")) var(--yw-if-dark, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"));
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-switch .form-check-input:not(:checked):not(:focus) {
|
||||||
|
--bs-form-switch-bg: var(--yw-if-light, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e")) var(--yw-if-dark, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.25%29'/%3e%3c/svg%3e"));
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-toggler-icon {
|
||||||
|
--bs-navbar-toggler-icon-bg: var(--yw-if-light, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")) var(--yw-if-dark, url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Light has no filter: the empty value leaves filter at its initial
|
||||||
|
"none". */
|
||||||
|
.btn-close {
|
||||||
|
filter: var(--yw-if-dark, var(--bs-btn-close-white-filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Page ---------------------------------------------------------- */
|
||||||
|
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@@ -143,14 +385,22 @@ body > .container-fluid > .row {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --- Navbar ------------------------------------------------ */
|
/* --- Navbar ------------------------------------------------ */
|
||||||
|
/* Bootstrap's own navbar colors come from the palette (the navbar has
|
||||||
|
no .navbar-dark, which would pin them to white). */
|
||||||
.navbar {
|
.navbar {
|
||||||
|
--bs-navbar-color: var(--yw-subtitle);
|
||||||
|
--bs-navbar-hover-color: var(--yw-accent);
|
||||||
|
--bs-navbar-active-color: var(--yw-accent);
|
||||||
|
--bs-navbar-brand-color: var(--yw-brand);
|
||||||
|
--bs-navbar-brand-hover-color: var(--yw-brand);
|
||||||
|
--bs-navbar-toggler-border-color: var(--yw-chrome-border);
|
||||||
background: var(--yw-chrome-bg) !important;
|
background: var(--yw-chrome-bg) !important;
|
||||||
border-bottom: 1px solid var(--yw-chrome-border);
|
border-bottom: 1px solid var(--yw-chrome-border);
|
||||||
padding: .6rem 1.2rem;
|
padding: .6rem 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-brand {
|
.navbar-brand {
|
||||||
color: var(--yw-accent) !important;
|
color: var(--yw-brand) !important;
|
||||||
letter-spacing: 2.5px;
|
letter-spacing: 2.5px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
@@ -170,6 +420,68 @@ a.navbar-subtitle:hover {
|
|||||||
margin: 0 .5rem;
|
margin: 0 .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Appearance menu (PageHeader.AppearancePath) ------------------- */
|
||||||
|
/* A <details> dropdown: opens and closes without a script, so it works
|
||||||
|
under a strict script-src CSP. Each choice is a submit button of one
|
||||||
|
POST form. */
|
||||||
|
.yw-appearance {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance > summary {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance > summary::-webkit-details-marker {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: calc(100% + .35rem);
|
||||||
|
z-index: 1030;
|
||||||
|
min-width: 12rem;
|
||||||
|
padding: .35rem 0;
|
||||||
|
background: var(--yw-chrome-bg);
|
||||||
|
border: 1px solid var(--yw-chrome-border);
|
||||||
|
border-radius: .375rem;
|
||||||
|
box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu h6 {
|
||||||
|
color: var(--yw-muted);
|
||||||
|
font-size: .72rem;
|
||||||
|
letter-spacing: .08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin: .35rem .9rem .2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu button {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: .3rem .9rem;
|
||||||
|
border: 0;
|
||||||
|
background: none;
|
||||||
|
color: var(--yw-text);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu button:hover {
|
||||||
|
background: color-mix(in srgb, var(--yw-accent) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu button[aria-pressed="true"] {
|
||||||
|
color: var(--yw-accent);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yw-appearance-menu hr {
|
||||||
|
margin: .35rem 0;
|
||||||
|
border-color: var(--yw-chrome-border);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Sidebar ------------------------------------------------ */
|
/* --- Sidebar ------------------------------------------------ */
|
||||||
.sidebar {
|
.sidebar {
|
||||||
background: var(--yw-chrome-bg);
|
background: var(--yw-chrome-bg);
|
||||||
@@ -185,17 +497,30 @@ a.navbar-subtitle:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar .nav-link:hover {
|
.sidebar .nav-link:hover {
|
||||||
background: rgba(var(--yw-accent-rgb), .08);
|
background: color-mix(in srgb, var(--yw-accent) 8%, transparent);
|
||||||
color: var(--yw-nav-link-hover-text);
|
color: var(--yw-nav-link-hover-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar .nav-link.active {
|
.sidebar .nav-link.active {
|
||||||
background: rgba(var(--yw-accent-rgb), .1);
|
background: color-mix(in srgb, var(--yw-accent) 10%, transparent);
|
||||||
color: var(--yw-accent);
|
color: var(--yw-accent);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
border-left: 2px solid var(--yw-accent);
|
border-left: 2px solid var(--yw-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A page without a sidebar (a login page): BodyAttrs ` class="no-sidebar"`.
|
||||||
|
The layout always renders the sidebar column; this hides it and gives
|
||||||
|
<main> the full width. !important: Bootstrap's d-md-block, column and
|
||||||
|
ms-sm-auto classes on those elements are !important or more specific. */
|
||||||
|
body.no-sidebar .sidebar {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.no-sidebar main {
|
||||||
|
width: 100% !important;
|
||||||
|
margin-left: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Alerts (flash banners) ---------------------------------------- */
|
/* --- Alerts (flash banners) ---------------------------------------- */
|
||||||
.alert-success { background: var(--yw-success-bg); border-color: var(--yw-success-border); color: var(--yw-success-text); }
|
.alert-success { background: var(--yw-success-bg); border-color: var(--yw-success-border); color: var(--yw-success-text); }
|
||||||
.alert-danger { background: var(--yw-danger-bg); border-color: var(--yw-danger-border); color: var(--yw-danger-text); }
|
.alert-danger { background: var(--yw-danger-bg); border-color: var(--yw-danger-border); color: var(--yw-danger-text); }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{{define "base"}}<!doctype html>
|
{{define "base"}}<!doctype html>
|
||||||
<html lang="{{if .Lang}}{{.Lang}}{{else}}en{{end}}"{{if .Theme}} data-theme="{{.Theme}}"{{end}}>
|
<html lang="{{if .Lang}}{{.Lang}}{{else}}en{{end}}"{{if .Theme}} data-theme="{{.Theme}}"{{end}}{{if .Palette}} data-palette="{{.Palette}}"{{end}}>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{{define "navbar"}}
|
{{define "navbar"}}
|
||||||
<nav class="navbar navbar-dark navbar-expand">
|
<nav class="navbar navbar-expand">
|
||||||
<div class="container-fluid d-flex justify-content-between align-items-center">
|
<div class="container-fluid d-flex justify-content-between align-items-center">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
{{.NavbarBeforeBrand}}
|
{{.NavbarBeforeBrand}}
|
||||||
@@ -9,7 +9,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
{{if .Username}}<span class="navbar-subtitle">{{.Username}}</span>{{end}}
|
{{if .Username}}<span class="navbar-subtitle">{{.Username}}</span>{{end}}
|
||||||
{{if .LogoutPath}}<form method="post" action="{{.BasePath}}{{.LogoutPath}}" class="d-inline m-0"><button type="submit" class="btn btn-outline-secondary btn-sm">Logout</button></form>{{end}}
|
{{if .AppearancePath}}{{with .AppearanceMenu}}<details class="yw-appearance">
|
||||||
|
<summary class="btn btn-outline-secondary btn-sm" title="{{.ThemeHeading}}: {{.Current.Label}}"><span aria-hidden="true">{{.Current.Symbol}}</span> {{.Current.Label}}</summary>
|
||||||
|
<form method="post" action="{{$.BasePath}}{{$.AppearancePath}}" class="yw-appearance-menu m-0">
|
||||||
|
<input type="hidden" name="back" value="{{$.AppearanceBack}}">{{$.AppearanceFormHTML}}
|
||||||
|
<h6>{{.ThemeHeading}}</h6>
|
||||||
|
{{range .Themes}}<button type="submit" name="theme" value="{{.ID}}" aria-pressed="{{.Current}}"><span aria-hidden="true">{{.Symbol}}</span> {{.Label}}</button>
|
||||||
|
{{end}}<hr>
|
||||||
|
<h6>{{.PaletteHeading}}</h6>
|
||||||
|
{{range .Palettes}}<button type="submit" name="palette" value="{{.ID}}" aria-pressed="{{.Current}}">{{.Label}}</button>
|
||||||
|
{{end}}</form>
|
||||||
|
</details>
|
||||||
|
{{end}}{{end}}{{if .LogoutPath}}<form method="post" action="{{.BasePath}}{{.LogoutPath}}" class="d-inline m-0"><button type="submit" class="btn btn-outline-secondary btn-sm">Logout</button></form>{{end}}
|
||||||
{{.NavbarRightExtra}}
|
{{.NavbarRightExtra}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user