Every colour was a 256-colour ANSI index hardcoded in styles.go, so changing the palette meant editing the styles themselves. This puts a semantic token set between the two: styles name roles, a theme supplies the colours. internal/theme holds the twelve tokens, the two built-ins (gruvbox-dark, the new default, and gruvbox-light) and the loader for user themes in ~/.config/terdut-tui/themes/. A user file may 'extends:' a built-in and override only what it cares about, and may shadow a built-in name to tweak it in place. Unknown keys, malformed colours and incomplete themes are refused with a message naming what went wrong. Colours are truecolor hex now: lipgloss downsamples for 256- and 16-colour terminals and honours NO_COLOR, so themes carry no fallbacks of their own. An ANSI index is still accepted for anyone who would rather follow their terminal's own palette. The 21 package-level style vars become a Styles struct on the Model, which is what rule 3 asked for all along; the four free functions in view.go take one as their first argument. The embedded bubbles components are restyled from the same tokens — otherwise a theme would leave a pink selected row and grey help text behind. Note that the table's Cell style deliberately keeps no foreground: bubbles renders cells before wrapping the row in Selected, so a colour there cuts the selection highlight short.
This commit is contained in:
@@ -69,10 +69,49 @@ Create `~/.config/terdut-tui/config.yaml`:
|
||||
server_url: https://terdut.example.com
|
||||
api_key: <your-api-key>
|
||||
refresh_interval: 30 # seconds, optional
|
||||
theme: gruvbox-dark # optional, this is the default
|
||||
```
|
||||
|
||||
The API key is generated in terdut-server. See the server documentation for how to bootstrap a user and issue an API key.
|
||||
|
||||
## Themes
|
||||
|
||||
Two themes ship with the client: `gruvbox-dark` (the default) and
|
||||
`gruvbox-light`. Both colour foregrounds only — the terminal supplies the
|
||||
background — so pick the one that matches the background you already run.
|
||||
|
||||
To make your own, drop a file in `~/.config/terdut-tui/themes/` and name it in
|
||||
`theme:`. `extends` inherits a built-in, so a file only has to list what it
|
||||
changes:
|
||||
|
||||
```yaml
|
||||
# ~/.config/terdut-tui/themes/mine.yaml
|
||||
extends: gruvbox-dark
|
||||
primary: "#d3869b"
|
||||
accent: "#fabd2f"
|
||||
```
|
||||
|
||||
A file may shadow a built-in name — `themes/gruvbox-dark.yaml` is how you tweak
|
||||
the default without renaming it.
|
||||
|
||||
Without `extends`, every token must be set. The twelve are:
|
||||
|
||||
| Token | Where it shows |
|
||||
|---|---|
|
||||
| `primary` | header, active tab, selected row, cursors |
|
||||
| `on_primary` | text drawn *on* `primary` — the active tab and selected row |
|
||||
| `text` | incident titles and other emphasis |
|
||||
| `muted` | secondary text, dividers, footer, table headers |
|
||||
| `accent` | status line, acknowledged incidents, the by-day chart |
|
||||
| `firing` | firing alerts, triggered incidents, the by-hour chart |
|
||||
| `resolved` | resolved alerts and incidents, the top-alerts chart |
|
||||
| `error` | error banners |
|
||||
| `sev_critical`, `sev_error`, `sev_warning`, `sev_info` | the `severity` label |
|
||||
|
||||
Values are hex (`#83a598` or `#abc`) or an ANSI palette index (`0`–`255`) if you
|
||||
would rather follow your terminal's own colours. Colours are downsampled
|
||||
automatically on 256- and 16-colour terminals, and `NO_COLOR` is honoured.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user