mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-02 15:57:17 +00:00
Merge pull request #1968 from infinito-nexus/feature/sys-front-inj-design/tokens-css
refactor(sys-front-inj-design): split design tokens into tokens.css.j2
This commit is contained in:
3 files changed
+40
-38
No files matched your search
@@ -10,6 +10,7 @@ It derives the design tokens from the single base color in `web-svc-design` thro
|
||||
The role renders the shared `default.css` and `bootstrap.css` once per deployment onto the CDN, links them with a cache-busting version, and adds the role's own `style.css` and `design.js` when the role ships them.
|
||||
The role's `style.css` is rendered per vhost and stored once per network the role is served on: the first network keeps `style.css`, every further one gets `<label>-style.css` (for example `onion-style.css`), and each vhost links the file of its own network.
|
||||
Light and dark tokens switch with `prefers-color-scheme`; a role mirrors an app-native theme switch through `<html data-design-theme="light|dark">`.
|
||||
The `--design-*` tokens alone live in [tokens.css.j2](templates/css/tokens.css.j2), which `default.css` includes. A role that serves the tokens on a page without design injection renders that template itself with `CSS_PALETTE` and `CSS_FONT`, so the tokens keep one source.
|
||||
|
||||
## Purpose
|
||||
|
||||
|
||||
@@ -1,41 +1,4 @@
|
||||
{% macro tokens(mode) -%}
|
||||
{% for name, value in CSS_PALETTE[mode].items() %}
|
||||
{{ name }}: {{ value }};
|
||||
{% endfor %}
|
||||
--design-shadow-color: {{ '0, 0, 0, 0.10' if mode == 'light' else '0, 0, 0, 0.45' }};
|
||||
--design-invert: {{ '0' if mode == 'light' else '1' }};
|
||||
{%- endmacro %}
|
||||
{% if CSS_FONT.import_url %}
|
||||
@import url('{{ CSS_FONT.import_url }}');
|
||||
{% endif %}
|
||||
:root {
|
||||
{{ tokens('light') }}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root:not([data-design-theme="light"]) {
|
||||
{{ tokens('dark') }}
|
||||
}
|
||||
}
|
||||
:root[data-design-theme="dark"] {
|
||||
{{ tokens('dark') }}
|
||||
}
|
||||
:root {
|
||||
--design-font: {{ CSS_FONT.type }};
|
||||
--design-radius-sm: 4px;
|
||||
--design-radius: 8px;
|
||||
--design-radius-lg: 12px;
|
||||
--design-space-1: 4px;
|
||||
--design-space-2: 8px;
|
||||
--design-space-3: 12px;
|
||||
--design-space-4: 16px;
|
||||
--design-space-5: 24px;
|
||||
--design-space-6: 32px;
|
||||
--design-shadow-1: 0 1px 2px rgba(var(--design-shadow-color));
|
||||
--design-shadow-2: 0 2px 8px rgba(var(--design-shadow-color));
|
||||
--design-shadow-3: 0 8px 24px rgba(var(--design-shadow-color));
|
||||
--design-focus-ring: 0 0 0 3px color-mix(in srgb, var(--design-link) 45%, transparent);
|
||||
--design-focus-ring-inset: inset 0 0 0 1px var(--design-link);
|
||||
}
|
||||
{% include 'roles/sys-front-inj-design/templates/css/tokens.css.j2' %}
|
||||
:root {
|
||||
--bs-font-sans-serif: var(--design-font);
|
||||
--bs-body-font-family: var(--design-font);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
{% macro tokens(mode) -%}
|
||||
{% for name, value in CSS_PALETTE[mode].items() %}
|
||||
{{ name }}: {{ value }};
|
||||
{% endfor %}
|
||||
--design-shadow-color: {{ '0, 0, 0, 0.10' if mode == 'light' else '0, 0, 0, 0.45' }};
|
||||
--design-invert: {{ '0' if mode == 'light' else '1' }};
|
||||
{%- endmacro %}
|
||||
{% if CSS_FONT.import_url %}
|
||||
@import url('{{ CSS_FONT.import_url }}');
|
||||
{% endif %}
|
||||
:root {
|
||||
{{ tokens('light') }}
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root:not([data-design-theme="light"]) {
|
||||
{{ tokens('dark') }}
|
||||
}
|
||||
}
|
||||
:root[data-design-theme="dark"] {
|
||||
{{ tokens('dark') }}
|
||||
}
|
||||
:root {
|
||||
--design-font: {{ CSS_FONT.type }};
|
||||
--design-radius-sm: 4px;
|
||||
--design-radius: 8px;
|
||||
--design-radius-lg: 12px;
|
||||
--design-space-1: 4px;
|
||||
--design-space-2: 8px;
|
||||
--design-space-3: 12px;
|
||||
--design-space-4: 16px;
|
||||
--design-space-5: 24px;
|
||||
--design-space-6: 32px;
|
||||
--design-shadow-1: 0 1px 2px rgba(var(--design-shadow-color));
|
||||
--design-shadow-2: 0 2px 8px rgba(var(--design-shadow-color));
|
||||
--design-shadow-3: 0 8px 24px rgba(var(--design-shadow-color));
|
||||
--design-focus-ring: 0 0 0 3px color-mix(in srgb, var(--design-link) 45%, transparent);
|
||||
--design-focus-ring-inset: inset 0 0 0 1px var(--design-link);
|
||||
}
|
||||
Reference in new issue
Block a user