From 641f5a32005d15d904797355ba6a87ad3dae011c Mon Sep 17 00:00:00 2001 From: Reza Barzakhi <95584955+rezabarzakhi@users.noreply.github.com> Date: Tue, 29 Sep 2026 20:36:19 +0330 Subject: [PATCH 1/2] feat: add 16-bit SNES theme toggle and retro text effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add dual-theme system: original dark theme (default) + 16-bit SNES theme - Theme toggle button (🎮/🎨) in topbar, preference saved in localStorage - New 'retro16' text effect: pixel-style outline with highlight for SNES-era look - CSS custom properties approach: .theme-retro16 class on swaps all variables - 16-bit palette: navy backgrounds, SNES accent colors, smaller border-radius - Helper functions: hexToHsl, hslToHex, darkenColor, lightenColor for effect rendering - Press Start 2P font loaded for 16-bit theme UI elements --- src/App.css | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/App.jsx | 71 +++++++++++++++++++++ src/fonts.js | 1 + src/index.css | 44 +++++++++++++ 4 files changed, 283 insertions(+) diff --git a/src/App.css b/src/App.css index 2aa8404..e77f516 100644 --- a/src/App.css +++ b/src/App.css @@ -2288,3 +2288,170 @@ word-break: break-all; overflow-x: auto; } + +/* ===== 16-bit SNES Theme Overrides ===== */ +.theme-retro16 .aurora { + display: none; +} + +.theme-retro16 .brand-name { + font-weight: 400; + font-size: 10px; + letter-spacing: 1px; + color: var(--snes-gold, #f0c040); + background: none; + -webkit-background-clip: unset; + background-clip: unset; + animation: none; +} + +.theme-retro16 .pill-btn { + border-radius: var(--r-m); + font-size: 11px; + font-weight: 400; +} + +.theme-retro16 .pill-btn:not(.soft):not(.ghost) { + background: linear-gradient(135deg, var(--snes-gold, #f0c040), var(--snes-orange, #e89848)); + color: #0a0a14; + border: none; +} + +.theme-retro16 .controls { + border-radius: var(--r-m) var(--r-m) 0 0; + border-top: 1px solid var(--border-1); +} + +.theme-retro16 .chip { + border-radius: var(--r-s); + border-width: 1px; +} + +.theme-retro16 .chip.selected { + border-color: var(--accent); + background: var(--accent-soft); + box-shadow: 0 0 12px var(--accent-glow); +} + +.theme-retro16 .swatch { + border-radius: var(--r-s); +} + +.theme-retro16 .toggle { + border-radius: var(--r-s); +} + +.theme-retro16 .sheet { + border-radius: var(--r-l) var(--r-l) 0 0; + border: 1px solid var(--border-1); +} + +.theme-retro16 .sheet-grab span { + border-radius: var(--r-s); +} + +.theme-retro16 .text-input { + border-radius: var(--r-s); +} + +.theme-retro16 .toast { + border-radius: var(--r-m); +} + +.theme-retro16 .code-block { + border-radius: var(--r-s); +} + +.theme-retro16 .stage::before { + border-radius: var(--r-m); +} + +.theme-retro16 .stage-inner { + border-radius: var(--r-m); +} + +.theme-retro16 .spinner { + border-radius: 50%; +} + +.theme-retro16 .startup-loader { + background: linear-gradient(145deg, var(--bg-0), var(--bg-1)); +} + +.theme-retro16 .startup-loader__mark::before { + border-radius: var(--r-l); + background: linear-gradient(135deg, var(--snes-gold, #f0c040), var(--snes-orange, #e89848)); + border: none; + box-shadow: 0 4px 20px rgba(240, 192, 64, 0.3); + transform: none; +} + +.theme-retro16 .startup-loader__orbit, +.theme-retro16 .startup-loader__spark { + display: none; +} + +.theme-retro16 .startup-loader__logo path { + fill: var(--snes-black, #0a0a14); + stroke: var(--snes-black, #0a0a14); +} + +.theme-retro16 .startup-loader__wordmark { + font-family: 'Press Start 2P', monospace; + font-size: clamp(16px, 4vw, 22px); + font-weight: 400; + letter-spacing: 1px; +} + +.theme-retro16 .startup-loader__wordmark strong { + background: none; + color: var(--snes-gold, #f0c040); + -webkit-background-clip: unset; + background-clip: unset; + font-weight: 400; +} + +.theme-retro16 .startup-loader__progress { + border-radius: var(--r-s); + border: 1px solid var(--border-1); +} + +.theme-retro16 .startup-loader__progress span { + background: linear-gradient(90deg, var(--snes-gold, #f0c040), var(--snes-orange, #e89848)); + border-radius: var(--r-s); + box-shadow: 0 0 8px rgba(240, 192, 64, 0.4); +} + +/* Theme toggle button */ +.theme-toggle { + display: flex; + align-items: center; + justify-content: center; + width: 34px; + height: 34px; + border-radius: 50%; + border: 1px solid var(--border-1); + background: var(--surface-2); + color: var(--text-2); + cursor: pointer; + transition: all 0.2s var(--ease-out); + font-size: 16px; + padding: 0; +} + +.theme-toggle:hover { + background: var(--surface-3); + color: var(--text-1); + border-color: var(--border-2); +} + +.theme-retro16 .theme-toggle { + border-radius: var(--r-s); + border: 1px solid var(--snes-gold, #f0c040); + color: var(--snes-gold, #f0c040); + background: transparent; +} + +.theme-retro16 .theme-toggle:hover { + background: rgba(240, 192, 64, 0.15); +} diff --git a/src/App.jsx b/src/App.jsx index 190db56..4f9c4f1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -126,6 +126,43 @@ function longShadow(color, depth, angle) { }).join(', ') } +function hexToHsl(hex) { + let r = parseInt(hex.slice(1, 3), 16) / 255 + let g = parseInt(hex.slice(3, 5), 16) / 255 + let b = parseInt(hex.slice(5, 7), 16) / 255 + const max = Math.max(r, g, b), min = Math.min(r, g, b) + let h = 0, s = 0, l = (max + min) / 2 + if (max !== min) { + const d = max - min + s = l > 0.5 ? d / (2 - max - min) : d / (max + min) + if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6 + else if (max === g) h = ((b - r) / d + 2) / 6 + else h = ((r - g) / d + 4) / 6 + } + return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)] +} + +function hslToHex(h, s, l) { + s /= 100; l /= 100 + const a = s * Math.min(l, 1 - l) + const f = (n) => { + const k = (n + h / 30) % 12 + const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1) + return Math.round(255 * color).toString(16).padStart(2, '0') + } + return `#${f(0)}${f(8)}${f(4)}` +} + +function darkenColor(hex, amount) { + const [h, s, l] = hexToHsl(hex) + return hslToHex(h, s, Math.max(0, l - amount * 100)) +} + +function lightenColor(hex, amount) { + const [h, s, l] = hexToHsl(hex) + return hslToHex(h, s, Math.min(100, l + amount * 100)) +} + function CurvedText({ text, mode, bend, style }) { const pathId = `fontwow-path-${mode}` const curve = Math.max(-90, Math.min(90, bend)) @@ -211,6 +248,7 @@ const defaultState = { const defaultAppSettings = { lang: 'fa', themeColor: '#8b5cf6', + retroTheme: false, } function Sheet({ title, onClose, tall, children }) { @@ -511,6 +549,14 @@ export default function App() { document.documentElement.lang = appSettings.lang }, [appSettings.lang]) + useEffect(() => { + if (appSettings.retroTheme) { + document.documentElement.classList.add('theme-retro16') + } else { + document.documentElement.classList.remove('theme-retro16') + } + }, [appSettings.retroTheme]) + const updateLayer = useCallback((id, patch) => { update((current) => ({ layers: current.layers.map((layer) => (layer.id === id ? { ...layer, ...patch } : layer)), @@ -1207,6 +1253,23 @@ export default function App() { effectStyle = { textShadow: `0 0 6px ${state.color}, 0 0 14px ${state.color}, 0 0 28px ${state.color}, 0 0 48px ${state.color}`, } + } else if (state.effect === 'retro16') { + const darker = darkenColor(state.color, 0.4) + const lighter = lightenColor(state.color, 0.3) + effectStyle = { + textShadow: [ + `-2px -2px 0px ${darker}`, + `2px -2px 0px ${darker}`, + `-2px 2px 0px ${darker}`, + `2px 2px 0px ${darker}`, + `0px -2px 0px ${darker}`, + `0px 2px 0px ${darker}`, + `-2px 0px 0px ${darker}`, + `2px 0px 0px ${darker}`, + `-1px -1px 0px ${lighter}`, + `1px 1px 2px rgba(0,0,0,0.5)`, + ].join(', '), + } } if (state.textMaskUrl) { @@ -1716,6 +1779,14 @@ export default function App() { > +