From 93ecc5910a8dd51e53898fb8097b0d0107a120a6 Mon Sep 17 00:00:00 2001 From: Louis Whittington Date: Tue, 31 Mar 2026 13:01:13 -0500 Subject: [PATCH] Add color utility functions and theme palette integration - Introduced utility functions for color manipulation: `fhHexToRgb`, `fhRgbToHex`, `fhMixHex`, `fhRelativeLuminance`, and `fhContrastText`. - Implemented a comprehensive theme palette based on the user's favorite color, including primary, secondary, and semantic colors. - Updated CSS variables in the stylesheet to reflect the new theme structure, enhancing consistency across the UI. - Modified header to dynamically apply theme styles based on the generated palette, improving visual coherence. --- assets/css/style.css | 245 ++++++++++++++++++++++++++++++++++++++++--- includes/header.php | 61 ++++++++++- index.php | 107 +++++++++++++++++-- 3 files changed, 387 insertions(+), 26 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 4daaf71..8011d34 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -20,6 +20,61 @@ 0 4px 8px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.55); + + --fh-primary: #4a90e2; + --fh-primary-hover: #3e79be; + --fh-primary-active: #3567a2; + --fh-primary-subtle: #edf4fc; + --fh-primary-border: #c6dcf6; + --fh-primary-text: #ffffff; + --fh-primary-subtle-text: #1f2a37; + + --fh-secondary: #dce9f8; + --fh-secondary-hover: #cfdff2; + --fh-secondary-active: #c0d3ea; + --fh-secondary-border: #b4c9e3; + --fh-secondary-text: #1f2a37; + + --fh-tertiary: #f4f8fd; + --fh-tertiary-hover: #e5eef9; + --fh-tertiary-active: #d6e5f5; + --fh-tertiary-border: #c6d8ee; + --fh-tertiary-text: #1f2a37; + --fh-focus-ring: #89b6eb; + --fh-surface-tint: #f7fafe; + --fh-header-gradient-end: #2c5282; + + --fh-success: #198754; + --fh-success-hover: #157347; + --fh-success-active: #146c43; + --fh-success-subtle: #d1e7dd; + --fh-success-border: #a3cfbb; + --fh-success-text: #ffffff; + --fh-success-subtle-text: #0f5132; + + --fh-warning: #f59e0b; + --fh-warning-hover: #d97706; + --fh-warning-active: #b45309; + --fh-warning-subtle: #fff3cd; + --fh-warning-border: #ffe69c; + --fh-warning-text: #111827; + --fh-warning-subtle-text: #664d03; + + --fh-danger: #dc3545; + --fh-danger-hover: #bb2d3b; + --fh-danger-active: #b02a37; + --fh-danger-subtle: #f8d7da; + --fh-danger-border: #f1aeb5; + --fh-danger-text: #ffffff; + --fh-danger-subtle-text: #842029; + + --fh-info: #0ea5e9; + --fh-info-hover: #0b84bd; + --fh-info-active: #0a6f9f; + --fh-info-subtle: #cff4fc; + --fh-info-border: #9eeaf9; + --fh-info-text: #ffffff; + --fh-info-subtle-text: #055160; } /* Opacity only — do not animate transform on #dashboardContentArea: it would trap @@ -46,7 +101,7 @@ main { } .app-header { - background: linear-gradient(135deg, var(--person-accent, #4a90e2) 0%, #2c5282 100%); + background: linear-gradient(135deg, var(--fh-primary, var(--person-accent, #4a90e2)) 0%, var(--fh-header-gradient-end, #2c5282) 100%); } /* Header top: title (left) · balance + persona (right from md up); mobile: second row = persona menu */ @@ -190,7 +245,7 @@ body.header-tone-light .app-header-logo-link { .persona-chip-mobile.active { font-weight: 600; - background-color: rgba(74, 144, 226, 0.14); + background-color: var(--fh-primary-subtle, rgba(74, 144, 226, 0.14)); } .app-header .app-header-actions .dropdown-toggle { @@ -282,7 +337,7 @@ body.header-tone-light .app-header-logo-link { @supports (color: color-mix(in srgb, #fff 50%, #000)) { .family-hub-body main .card { - border-color: color-mix(in srgb, var(--person-accent, #4a90e2) 14%, var(--border-color)); + border-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 14%, var(--border-color)); } } @@ -295,10 +350,10 @@ body.header-tone-light .app-header-logo-link { @supports (color: color-mix(in srgb, #fff 50%, #000)) { .family-hub-body main .card:focus-within { - border-color: color-mix(in srgb, var(--person-accent, #4a90e2) 28%, var(--border-color)); + border-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 28%, var(--border-color)); box-shadow: var(--fh-shadow-lift), - 0 0 0 3px color-mix(in srgb, var(--person-accent, #4a90e2) 32%, transparent); + 0 0 0 3px color-mix(in srgb, var(--fh-primary, #4a90e2) 32%, transparent); outline: none; } } @@ -306,7 +361,7 @@ body.header-tone-light .app-header-logo-link { @supports not (color: color-mix(in srgb, #fff 50%, #000)) { .family-hub-body main .card:focus-within { box-shadow: var(--fh-shadow-lift); - outline: 2px solid var(--person-accent, #4a90e2); + outline: 2px solid var(--fh-primary, #4a90e2); outline-offset: 2px; } } @@ -354,6 +409,7 @@ body.header-tone-light .app-header-logo-link { .family-hub-body main .btn:focus-visible:not(:disabled):not(.disabled) { transform: translateY(-1px); + box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--fh-focus-ring, #89b6eb) 38%, transparent); } .family-hub-body main .btn:active:not(:disabled):not(.disabled) { @@ -387,6 +443,163 @@ body.header-tone-light .app-header-logo-link { box-shadow var(--fh-duration-fast) var(--fh-ease-out); } +.family-hub-body .btn-primary { + --bs-btn-bg: var(--fh-primary); + --bs-btn-border-color: var(--fh-primary); + --bs-btn-color: var(--fh-primary-text); + --bs-btn-hover-bg: var(--fh-primary-hover); + --bs-btn-hover-border-color: var(--fh-primary-hover); + --bs-btn-hover-color: var(--fh-primary-text); + --bs-btn-active-bg: var(--fh-primary-active); + --bs-btn-active-border-color: var(--fh-primary-active); + --bs-btn-active-color: var(--fh-primary-text); + --bs-btn-disabled-bg: var(--fh-primary); + --bs-btn-disabled-border-color: var(--fh-primary); + --bs-btn-disabled-color: var(--fh-primary-text); +} + +.family-hub-body .btn-outline-primary { + --bs-btn-color: var(--fh-primary); + --bs-btn-border-color: var(--fh-primary-border); + --bs-btn-hover-color: var(--fh-primary-text); + --bs-btn-hover-bg: var(--fh-primary); + --bs-btn-hover-border-color: var(--fh-primary); + --bs-btn-active-color: var(--fh-primary-text); + --bs-btn-active-bg: var(--fh-primary-active); + --bs-btn-active-border-color: var(--fh-primary-active); +} + +.family-hub-body .btn-secondary, +.family-hub-body .btn-outline-secondary:hover, +.family-hub-body .btn-outline-secondary:focus-visible { + --bs-btn-bg: var(--fh-secondary); + --bs-btn-border-color: var(--fh-secondary-border); + --bs-btn-color: var(--fh-secondary-text); + --bs-btn-hover-bg: var(--fh-secondary-hover); + --bs-btn-hover-border-color: var(--fh-secondary-border); + --bs-btn-hover-color: var(--fh-secondary-text); + --bs-btn-active-bg: var(--fh-secondary-active); + --bs-btn-active-border-color: var(--fh-secondary-border); + --bs-btn-active-color: var(--fh-secondary-text); +} + +.family-hub-body .btn-outline-secondary { + --bs-btn-color: var(--fh-secondary-text); + --bs-btn-border-color: var(--fh-secondary-border); +} + +.family-hub-body .btn-tertiary { + --bs-btn-bg: var(--fh-tertiary); + --bs-btn-border-color: var(--fh-tertiary-border); + --bs-btn-color: var(--fh-tertiary-text); + --bs-btn-hover-bg: var(--fh-tertiary-hover); + --bs-btn-hover-border-color: var(--fh-tertiary-border); + --bs-btn-hover-color: var(--fh-tertiary-text); + --bs-btn-active-bg: var(--fh-tertiary-active); + --bs-btn-active-border-color: var(--fh-tertiary-border); + --bs-btn-active-color: var(--fh-tertiary-text); +} + +.family-hub-body .btn-success { + --bs-btn-bg: var(--fh-success); + --bs-btn-border-color: var(--fh-success); + --bs-btn-color: var(--fh-success-text); + --bs-btn-hover-bg: var(--fh-success-hover); + --bs-btn-hover-border-color: var(--fh-success-hover); + --bs-btn-active-bg: var(--fh-success-active); + --bs-btn-active-border-color: var(--fh-success-active); +} + +.family-hub-body .btn-warning { + --bs-btn-bg: var(--fh-warning); + --bs-btn-border-color: var(--fh-warning); + --bs-btn-color: var(--fh-warning-text); + --bs-btn-hover-bg: var(--fh-warning-hover); + --bs-btn-hover-border-color: var(--fh-warning-hover); + --bs-btn-hover-color: var(--fh-warning-text); + --bs-btn-active-bg: var(--fh-warning-active); + --bs-btn-active-border-color: var(--fh-warning-active); + --bs-btn-active-color: var(--fh-warning-text); +} + +.family-hub-body .btn-danger { + --bs-btn-bg: var(--fh-danger); + --bs-btn-border-color: var(--fh-danger); + --bs-btn-color: var(--fh-danger-text); + --bs-btn-hover-bg: var(--fh-danger-hover); + --bs-btn-hover-border-color: var(--fh-danger-hover); + --bs-btn-active-bg: var(--fh-danger-active); + --bs-btn-active-border-color: var(--fh-danger-active); +} + +.family-hub-body .btn-info { + --bs-btn-bg: var(--fh-info); + --bs-btn-border-color: var(--fh-info); + --bs-btn-color: var(--fh-info-text); + --bs-btn-hover-bg: var(--fh-info-hover); + --bs-btn-hover-border-color: var(--fh-info-hover); + --bs-btn-active-bg: var(--fh-info-active); + --bs-btn-active-border-color: var(--fh-info-active); +} + +.family-hub-body .nav-pills .nav-link.active, +.family-hub-body .nav-pills .show > .nav-link { + background-color: var(--fh-primary); + color: var(--fh-primary-text); +} + +.family-hub-body .nav-pills .nav-link:not(.active) { + color: var(--fh-primary); +} + +.family-hub-body .progress-bar { + background-color: var(--fh-primary); +} + +.family-hub-body .table-primary { + --bs-table-bg: var(--fh-primary-subtle); + --bs-table-striped-bg: color-mix(in srgb, var(--fh-primary-subtle) 88%, #ffffff); + --bs-table-hover-bg: color-mix(in srgb, var(--fh-primary-subtle) 82%, #ffffff); + color: var(--fh-primary-subtle-text); +} + +.family-hub-body .text-bg-info { + background-color: var(--fh-info-subtle) !important; + color: var(--fh-info-subtle-text) !important; +} + +.family-hub-body .alert-success { + background-color: var(--fh-success-subtle); + border-color: var(--fh-success-border); + color: var(--fh-success-subtle-text); +} + +.family-hub-body .alert-warning { + background-color: var(--fh-warning-subtle); + border-color: var(--fh-warning-border); + color: var(--fh-warning-subtle-text); +} + +.family-hub-body .alert-danger { + background-color: var(--fh-danger-subtle); + border-color: var(--fh-danger-border); + color: var(--fh-danger-subtle-text); +} + +.family-hub-body .alert-info { + background-color: var(--fh-info-subtle); + border-color: var(--fh-info-border); + color: var(--fh-info-subtle-text); +} + +.family-hub-body .form-control:focus, +.family-hub-body .form-select:focus, +.family-hub-body .form-check-input:focus, +.family-hub-body .btn:focus-visible { + border-color: var(--fh-primary-border); + box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--fh-focus-ring, #89b6eb) 42%, transparent); +} + @media (hover: hover) and (pointer: fine) { .family-hub-body main a.badge:hover, .family-hub-body main a.badge:focus-visible { @@ -538,7 +751,7 @@ body.header-tone-light .app-header .tab.active { } .calendar-agenda-today { - background-color: rgba(74, 144, 226, 0.06); + background-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 8%, #ffffff); } /* Calendar tab: Google column first; side-by-side 70% / 30% from xl up when embed is configured */ @@ -578,7 +791,7 @@ body.header-tone-light .app-header .tab.active { @supports (color: color-mix(in srgb, #fff 50%, #000)) { .meal-detail-intro.card { - background-color: color-mix(in srgb, var(--person-accent, #4a90e2) 8%, #fff); + background-color: color-mix(in srgb, var(--fh-primary, #4a90e2) 8%, #fff); } } @@ -610,7 +823,7 @@ body.header-tone-light .app-header .tab.active { } .meal-detail-section-heading .fa { - color: var(--person-accent, var(--primary-color)); + color: var(--fh-primary, var(--primary-color)); opacity: 0.9; } @@ -643,7 +856,7 @@ body.header-tone-light .app-header .tab.active { /* Meal plan grid + share/import actions */ .meal-grid-table thead th { - background-color: color-mix(in srgb, var(--person-accent, var(--primary-color)) 18%, var(--secondary-color, #f8f9fa)); + background-color: color-mix(in srgb, var(--fh-primary, var(--primary-color)) 18%, var(--secondary-color, #f8f9fa)); font-weight: 600; border-color: var(--border-color); } @@ -665,8 +878,8 @@ body.header-tone-light .app-header .tab.active { .banking-hero { border-radius: 0.8rem; padding: 0.9rem 1rem; - background: linear-gradient(135deg, rgba(74, 144, 226, 0.12), rgba(74, 226, 168, 0.1)); - border: 1px solid rgba(74, 144, 226, 0.2); + background: linear-gradient(135deg, color-mix(in srgb, var(--fh-primary, #4a90e2) 20%, #ffffff), color-mix(in srgb, var(--fh-info, #0ea5e9) 16%, #ffffff)); + border: 1px solid color-mix(in srgb, var(--fh-primary, #4a90e2) 34%, #ffffff); } .banking-overview-card { @@ -696,10 +909,10 @@ body.header-tone-light .app-header .tab.active { pointer-events: none; } -.banking-overview-checking::after { background: #4a90e2; } -.banking-overview-savings::after { background: #2fbf71; } -.banking-overview-charity::after { background: #8f65ff; } -.banking-overview-donated::after { background: #f2994a; } +.banking-overview-checking::after { background: var(--fh-primary, #4a90e2); } +.banking-overview-savings::after { background: var(--fh-success, #2fbf71); } +.banking-overview-charity::after { background: var(--fh-info, #8f65ff); } +.banking-overview-donated::after { background: var(--fh-warning, #f2994a); } @keyframes banking-card-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } diff --git a/includes/header.php b/includes/header.php index ad8536a..ca7cda4 100644 --- a/includes/header.php +++ b/includes/header.php @@ -13,7 +13,66 @@ - + (string) ($themePalette['accent'] ?? ($favoriteColor ?? '#4a90e2')), + '--fh-primary' => (string) ($themePalette['primary'] ?? '#4a90e2'), + '--fh-primary-hover' => (string) ($themePalette['primary_hover'] ?? '#3e79be'), + '--fh-primary-active' => (string) ($themePalette['primary_active'] ?? '#3567a2'), + '--fh-primary-subtle' => (string) ($themePalette['primary_subtle'] ?? '#edf4fc'), + '--fh-primary-border' => (string) ($themePalette['primary_border'] ?? '#c6dcf6'), + '--fh-primary-text' => (string) ($themePalette['primary_text'] ?? '#ffffff'), + '--fh-primary-subtle-text' => (string) ($themePalette['primary_subtle_text'] ?? '#1f2a37'), + '--fh-secondary' => (string) ($themePalette['secondary'] ?? '#dce9f8'), + '--fh-secondary-hover' => (string) ($themePalette['secondary_hover'] ?? '#cfdff2'), + '--fh-secondary-active' => (string) ($themePalette['secondary_active'] ?? '#c0d3ea'), + '--fh-secondary-border' => (string) ($themePalette['secondary_border'] ?? '#b4c9e3'), + '--fh-secondary-text' => (string) ($themePalette['secondary_text'] ?? '#1f2a37'), + '--fh-tertiary' => (string) ($themePalette['tertiary'] ?? '#f4f8fd'), + '--fh-tertiary-hover' => (string) ($themePalette['tertiary_hover'] ?? '#e5eef9'), + '--fh-tertiary-active' => (string) ($themePalette['tertiary_active'] ?? '#d6e5f5'), + '--fh-tertiary-border' => (string) ($themePalette['tertiary_border'] ?? '#c6d8ee'), + '--fh-tertiary-text' => (string) ($themePalette['tertiary_text'] ?? '#1f2a37'), + '--fh-focus-ring' => (string) ($themePalette['focus_ring'] ?? '#89b6eb'), + '--fh-surface-tint' => (string) ($themePalette['surface_tint'] ?? '#f7fafe'), + '--fh-header-gradient-end' => (string) ($themePalette['header_gradient_end'] ?? '#2c5282'), + '--fh-success' => (string) ($themePalette['success'] ?? '#198754'), + '--fh-success-hover' => (string) ($themePalette['success_hover'] ?? '#157347'), + '--fh-success-active' => (string) ($themePalette['success_active'] ?? '#146c43'), + '--fh-success-subtle' => (string) ($themePalette['success_subtle'] ?? '#d1e7dd'), + '--fh-success-border' => (string) ($themePalette['success_border'] ?? '#a3cfbb'), + '--fh-success-text' => (string) ($themePalette['success_text'] ?? '#ffffff'), + '--fh-success-subtle-text' => (string) ($themePalette['success_subtle_text'] ?? '#0f5132'), + '--fh-warning' => (string) ($themePalette['warning'] ?? '#f59e0b'), + '--fh-warning-hover' => (string) ($themePalette['warning_hover'] ?? '#d97706'), + '--fh-warning-active' => (string) ($themePalette['warning_active'] ?? '#b45309'), + '--fh-warning-subtle' => (string) ($themePalette['warning_subtle'] ?? '#fff3cd'), + '--fh-warning-border' => (string) ($themePalette['warning_border'] ?? '#ffe69c'), + '--fh-warning-text' => (string) ($themePalette['warning_text'] ?? '#111827'), + '--fh-warning-subtle-text' => (string) ($themePalette['warning_subtle_text'] ?? '#664d03'), + '--fh-danger' => (string) ($themePalette['danger'] ?? '#dc3545'), + '--fh-danger-hover' => (string) ($themePalette['danger_hover'] ?? '#bb2d3b'), + '--fh-danger-active' => (string) ($themePalette['danger_active'] ?? '#b02a37'), + '--fh-danger-subtle' => (string) ($themePalette['danger_subtle'] ?? '#f8d7da'), + '--fh-danger-border' => (string) ($themePalette['danger_border'] ?? '#f1aeb5'), + '--fh-danger-text' => (string) ($themePalette['danger_text'] ?? '#ffffff'), + '--fh-danger-subtle-text' => (string) ($themePalette['danger_subtle_text'] ?? '#842029'), + '--fh-info' => (string) ($themePalette['info'] ?? '#0ea5e9'), + '--fh-info-hover' => (string) ($themePalette['info_hover'] ?? '#0b84bd'), + '--fh-info-active' => (string) ($themePalette['info_active'] ?? '#0a6f9f'), + '--fh-info-subtle' => (string) ($themePalette['info_subtle'] ?? '#cff4fc'), + '--fh-info-border' => (string) ($themePalette['info_border'] ?? '#9eeaf9'), + '--fh-info-text' => (string) ($themePalette['info_text'] ?? '#ffffff'), + '--fh-info-subtle-text' => (string) ($themePalette['info_subtle_text'] ?? '#055160'), + ]; + $bodyStyleParts = []; + foreach ($themeVars as $varName => $varValue) { + $bodyStyleParts[] = $varName . ': ' . $varValue; + } + $bodyStyle = implode('; ', $bodyStyleParts) . ';'; +?> +
diff --git a/index.php b/index.php index d4a38f9..5f4e729 100644 --- a/index.php +++ b/index.php @@ -55,6 +55,61 @@ $isCalendarTvView = $activeTab === 'calendar' && isset($_GET['view']) && (string $familyHubApiBase = familyHubWebApiBase(); +if (!function_exists('fhHexToRgb')) { + function fhHexToRgb(string $hex): array + { + if (!preg_match('/^#([0-9A-Fa-f]{6})$/', $hex, $m)) { + return [74, 144, 226]; + } + $raw = $m[1]; + return [ + hexdec(substr($raw, 0, 2)), + hexdec(substr($raw, 2, 2)), + hexdec(substr($raw, 4, 2)), + ]; + } +} + +if (!function_exists('fhRgbToHex')) { + function fhRgbToHex(array $rgb): string + { + $r = max(0, min(255, (int) round((float) ($rgb[0] ?? 0)))); + $g = max(0, min(255, (int) round((float) ($rgb[1] ?? 0)))); + $b = max(0, min(255, (int) round((float) ($rgb[2] ?? 0)))); + return sprintf('#%02x%02x%02x', $r, $g, $b); + } +} + +if (!function_exists('fhMixHex')) { + function fhMixHex(string $leftHex, string $rightHex, float $rightWeight): string + { + $weight = max(0.0, min(1.0, $rightWeight)); + $left = fhHexToRgb($leftHex); + $right = fhHexToRgb($rightHex); + $mixed = [ + ($left[0] * (1 - $weight)) + ($right[0] * $weight), + ($left[1] * (1 - $weight)) + ($right[1] * $weight), + ($left[2] * (1 - $weight)) + ($right[2] * $weight), + ]; + return fhRgbToHex($mixed); + } +} + +if (!function_exists('fhRelativeLuminance')) { + function fhRelativeLuminance(string $hex): float + { + [$r, $g, $b] = fhHexToRgb($hex); + return (0.2126 * $r + 0.7152 * $g + 0.0722 * $b) / 255; + } +} + +if (!function_exists('fhContrastText')) { + function fhContrastText(string $backgroundHex): string + { + return fhRelativeLuminance($backgroundHex) >= 0.6 ? '#111827' : '#ffffff'; + } +} + $favoriteColor = '#4a90e2'; if ( $activePerson !== null @@ -63,16 +118,50 @@ if ( ) { $favoriteColor = (string) $activePerson['favoriteColor']; } + +$themePalette = []; +$themePalette['accent'] = $favoriteColor; +$themePalette['primary'] = $favoriteColor; +$themePalette['primary_hover'] = fhMixHex($favoriteColor, '#000000', 0.12); +$themePalette['primary_active'] = fhMixHex($favoriteColor, '#000000', 0.2); +$themePalette['primary_subtle'] = fhMixHex($favoriteColor, '#ffffff', 0.86); +$themePalette['primary_border'] = fhMixHex($favoriteColor, '#ffffff', 0.64); +$themePalette['primary_text'] = fhContrastText($themePalette['primary']); +$themePalette['primary_subtle_text'] = fhContrastText($themePalette['primary_subtle']); +$themePalette['secondary'] = fhMixHex($favoriteColor, '#ffffff', 0.76); +$themePalette['secondary_hover'] = fhMixHex($favoriteColor, '#ffffff', 0.66); +$themePalette['secondary_active'] = fhMixHex($favoriteColor, '#ffffff', 0.57); +$themePalette['secondary_border'] = fhMixHex($favoriteColor, '#ffffff', 0.5); +$themePalette['secondary_text'] = fhContrastText($themePalette['secondary']); +$themePalette['tertiary'] = fhMixHex($favoriteColor, '#ffffff', 0.9); +$themePalette['tertiary_hover'] = fhMixHex($favoriteColor, '#ffffff', 0.82); +$themePalette['tertiary_active'] = fhMixHex($favoriteColor, '#ffffff', 0.73); +$themePalette['tertiary_border'] = fhMixHex($favoriteColor, '#ffffff', 0.62); +$themePalette['tertiary_text'] = fhContrastText($themePalette['tertiary']); +$themePalette['focus_ring'] = fhMixHex($favoriteColor, '#ffffff', 0.35); +$themePalette['surface_tint'] = fhMixHex($favoriteColor, '#ffffff', 0.93); +$themePalette['header_gradient_end'] = fhMixHex($favoriteColor, '#0f172a', 0.58); + +$semanticBase = [ + 'success' => '#198754', + 'warning' => '#f59e0b', + 'danger' => '#dc3545', + 'info' => '#0ea5e9', +]; +foreach ($semanticBase as $key => $baseHex) { + $main = fhMixHex($baseHex, $favoriteColor, 0.2); + $themePalette[$key] = $main; + $themePalette[$key . '_hover'] = fhMixHex($main, '#000000', 0.1); + $themePalette[$key . '_active'] = fhMixHex($main, '#000000', 0.18); + $themePalette[$key . '_subtle'] = fhMixHex($main, '#ffffff', 0.84); + $themePalette[$key . '_border'] = fhMixHex($main, '#ffffff', 0.62); + $themePalette[$key . '_text'] = fhContrastText($main); + $themePalette[$key . '_subtle_text'] = fhContrastText($themePalette[$key . '_subtle']); +} + $headerThemeClass = 'header-tone-dark'; -if (preg_match('/^#([0-9A-Fa-f]{6})$/', $favoriteColor, $m)) { - $hex = $m[1]; - $r = hexdec(substr($hex, 0, 2)); - $g = hexdec(substr($hex, 2, 2)); - $b = hexdec(substr($hex, 4, 2)); - $relativeLuminance = (0.2126 * $r + 0.7152 * $g + 0.0722 * $b) / 255; - if ($relativeLuminance >= 0.62) { - $headerThemeClass = 'header-tone-light'; - } +if (fhRelativeLuminance($themePalette['primary']) >= 0.62) { + $headerThemeClass = 'header-tone-light'; } include 'includes/header.php';