From 9ca376854f32ee45ae054e823ce682cc7b995030 Mon Sep 17 00:00:00 2001 From: "GOMIDES, Rafael" Date: Sat, 17 Oct 2026 13:51:16 -0300 Subject: [PATCH 01/19] feat(design-system): add accessible light palette with shared semantic tokens --- design-system/tokens/tokens.css | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/design-system/tokens/tokens.css b/design-system/tokens/tokens.css index 42adf17..b6a4be6 100644 --- a/design-system/tokens/tokens.css +++ b/design-system/tokens/tokens.css @@ -1,4 +1,4 @@ -/* Dark Engineering v0.1 — canonical, framework-agnostic design tokens. +/* Dark Engineering v0.2 — canonical, theme-aware, framework-agnostic design tokens. Variables are intentionally namespaced: existing portfolio styles are untouched. */ :root { --ds-color-bg: #0b0f0e; @@ -15,6 +15,8 @@ --ds-color-highlight-contrast: #252009; --ds-color-danger: #f0a59c; --ds-color-focus: #e6d67e; + --ds-color-header-bg: rgb(11 15 14 / .92); + --ds-color-code-bg: #101713; --ds-font-sans: "Space Grotesk", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --ds-font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace; --ds-font-size-xs: 0.75rem; @@ -48,6 +50,30 @@ --ds-transition-fast: 160ms ease; --ds-transition-medium: 260ms ease; } +/* Explicit light palette. Absent data-theme, the original dark look is unchanged. + Apply data-theme to so all shared components inherit the same tokens. */ +:root[data-theme="light"] { + color-scheme: light; + --ds-color-bg: #f7f8f4; + --ds-color-surface: #ffffff; + --ds-color-surface-raised: #ebf2ed; + --ds-color-border: #cbd7ce; + --ds-color-border-strong: #8da598; + --ds-color-text: #15231b; + --ds-color-muted: #466050; + --ds-color-subtle: #54695c; + --ds-color-accent: #23633d; + --ds-color-accent-contrast: #ffffff; + --ds-color-highlight: #755500; + --ds-color-highlight-contrast: #ffffff; + --ds-color-danger: #a53432; + --ds-color-focus: #765500; + --ds-color-header-bg: rgb(247 248 244 / .94); + --ds-color-code-bg: #edf3ee; + --ds-shadow-card: 0 16px 48px rgb(27 53 35 / .09); +} +:root[data-theme="dark"] { color-scheme: dark; } + .ds-app, .ds-app *, .ds-app *::before, From 5de70799676c16124ecad3eeb2ad892dd831f035 Mon Sep 17 00:00:00 2001 From: "GOMIDES, Rafael" Date: Sat, 17 Oct 2026 13:51:37 -0300 Subject: [PATCH 02/19] feat(design-system): make header, code and theme toggle theme-aware --- design-system/components/components.css | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/design-system/components/components.css b/design-system/components/components.css index 67a7686..2655ea7 100644 --- a/design-system/components/components.css +++ b/design-system/components/components.css @@ -2,7 +2,7 @@ .ds-container { width: min(var(--ds-content-width), calc(100% - 3rem)); margin-inline: auto; } .ds-skip-link { position: absolute; z-index: 99; top: -100px; left: 1rem; padding: .7rem 1rem; background: var(--ds-color-highlight); color: var(--ds-color-highlight-contrast) !important; } .ds-skip-link:focus { top: .5rem; } -.ds-header { position: relative; z-index: 20; border-bottom: 1px solid var(--ds-color-border); background: rgb(11 15 14 / .92); } +.ds-header { position: relative; z-index: 20; border-bottom: 1px solid var(--ds-color-border); background: var(--ds-color-header-bg); } .ds-header__inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; } .ds-brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ds-color-text); font-weight: 700; letter-spacing: -.05em; white-space: nowrap; font-size: 1.4rem; } .ds-brand__mark { display: inline-grid; place-items: center; border: 1px solid var(--ds-color-border-strong); width: 43px; height: 43px; border-radius: .65rem; } @@ -71,7 +71,7 @@ a.ds-post-item:hover { background: var(--ds-color-surface); } .ds-prose ul, .ds-prose ol { padding-left: 1.4rem; } .ds-prose a { color: var(--ds-color-accent); text-decoration: underline; text-underline-offset: .2em; } .ds-prose code { font-family: var(--ds-font-mono); font-size: .83em; background: var(--ds-color-surface-raised); border: 1px solid var(--ds-color-border); border-radius: .25rem; padding: .15rem .3rem; overflow-wrap: anywhere; } -.ds-prose pre { overflow-x: auto; background: #101713; border: 1px solid var(--ds-color-border); padding: 1.4rem; border-radius: var(--ds-radius-sm); margin-bottom: 1.6rem; line-height: 1.5; font-size: .88rem; } +.ds-prose pre { overflow-x: auto; background: var(--ds-color-code-bg); border: 1px solid var(--ds-color-border); padding: 1.4rem; border-radius: var(--ds-radius-sm); margin-bottom: 1.6rem; line-height: 1.5; font-size: .88rem; } .ds-prose pre code { padding: 0; border: 0; background: transparent; overflow-wrap: normal; } .ds-prose blockquote { margin: 1.5rem 0; padding: .2rem 1.2rem; border-left: 2px solid var(--ds-color-highlight); color: var(--ds-color-muted); } .ds-prose :is(img,video) { max-width: 100%; height: auto; border-radius: var(--ds-radius-sm); } @@ -102,3 +102,11 @@ a.ds-post-item:hover { background: var(--ds-color-surface); } /* Explicitly preserve native hidden semantics on display-based components. */ .ds-app [hidden] { display: none !important; } + +/* Theme control: opt-in by host. Hidden without JS, visible when the theme + controller has initialized. The native button stays keyboard accessible. */ +.ds-theme-toggle { display: none; align-items: center; justify-content: center; flex: 0 0 auto; gap: .55rem; min-width: 44px; min-height: 44px; padding: .5rem .7rem; border: 1px solid var(--ds-color-border-strong); border-radius: var(--ds-radius-xs); background: var(--ds-color-surface); color: var(--ds-color-text); font: 500 .72rem/1.4 var(--ds-font-mono); } +html[data-theme-ready] .ds-theme-toggle { display: inline-flex; } +.ds-theme-toggle:hover { border-color: var(--ds-color-accent); background: var(--ds-color-surface-raised); } +.ds-theme-toggle__icon { font: 1.15rem/1 var(--ds-font-sans); } +@media (max-width: 520px) { .ds-theme-toggle__label { display: none; } } From 54e93dadc9bab3fa16963058dc782d3214702433 Mon Sep 17 00:00:00 2001 From: "GOMIDES, Rafael" Date: Sat, 17 Oct 2026 13:51:58 -0300 Subject: [PATCH 03/19] feat(design-system): add shared persisted system-aware appearance controller --- design-system/theme/theme.js | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 design-system/theme/theme.js diff --git a/design-system/theme/theme.js b/design-system/theme/theme.js new file mode 100644 index 0000000..7575a3e --- /dev/null +++ b/design-system/theme/theme.js @@ -0,0 +1,58 @@ +/* Shared appearance controller. Load synchronously in before CSS to + avoid a flash of the wrong theme. The value is stored across blog pages. + No access to storage is required for basic reading or switching. */ +(() => { + const root = document.documentElement; + const key = 'rgomids-color-theme'; + const media = typeof window.matchMedia === 'function' + ? window.matchMedia('(prefers-color-scheme: dark)') : null; + let preference = 'system'; + try { + const stored = window.localStorage.getItem(key); + if (stored === 'light' || stored === 'dark' || stored === 'system') preference = stored; + } catch (_) { /* Privacy/security settings can block localStorage. */ } + + const resolvedTheme = () => preference === 'system' + ? (media?.matches ? 'dark' : 'light') : preference; + + const render = () => { + const active = resolvedTheme(); + root.dataset.theme = active; + root.dataset.themePreference = preference; + root.style.colorScheme = active; + for (const button of document.querySelectorAll('[data-theme-toggle]')) { + const next = active === 'dark' ? 'light' : 'dark'; + button.setAttribute('aria-label', 'Ativar modo ' + (next === 'light' ? 'claro' : 'escuro')); + button.setAttribute('title', 'Ativar modo ' + (next === 'light' ? 'claro' : 'escuro')); + const label = button.querySelector('[data-theme-label]'); + const icon = button.querySelector('[data-theme-icon]'); + if (label) label.textContent = next === 'light' ? 'Modo claro' : 'Modo escuro'; + if (icon) icon.textContent = next === 'light' ? '☀' : '☾'; + } + }; + + // Set colors before the first stylesheet is parsed. + render(); + const initialize = () => { + root.dataset.themeReady = 'true'; + for (const button of document.querySelectorAll('[data-theme-toggle]')) { + button.addEventListener('click', () => { + preference = resolvedTheme() === 'dark' ? 'light' : 'dark'; + try { window.localStorage.setItem(key, preference); } catch (_) { /* non-persistent fallback */ } + render(); + }); + } + render(); + }; + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initialize, { once: true }); + } else { + initialize(); + } + + const onSystemChange = () => { + if (preference === 'system') render(); + }; + if (media?.addEventListener) media.addEventListener('change', onSystemChange); + else if (media?.addListener) media.addListener(onSystemChange); +})(); From 76eb750845930b42bf1e40f43e9cef04e18d11f6 Mon Sep 17 00:00:00 2001 From: "GOMIDES, Rafael" Date: Sat, 17 Oct 2026 13:52:33 -0300 Subject: [PATCH 04/19] feat(design-system): preview light/dark switch on all design system examples --- design-system/preview/index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/design-system/preview/index.html b/design-system/preview/index.html index 663ac19..df10c1f 100644 --- a/design-system/preview/index.html +++ b/design-system/preview/index.html @@ -3,12 +3,13 @@ - + Dark Engineering — Design System + @@ -20,7 +21,7 @@
RG./ design-system