feat: vylepšená podpora themes
CI / Generate TypeScript types (push) Successful in 1m3s
CI / Server unit tests (push) Successful in 30s
CI / Build server (push) Successful in 25s
CI / Build client (push) Successful in 36s
CI / Playwright E2E tests (push) Successful in 1m20s
CI / Build and push Docker image (push) Successful in 2m46s
CI / Notify (push) Successful in 1s
CI / Generate TypeScript types (push) Successful in 1m3s
CI / Server unit tests (push) Successful in 30s
CI / Build server (push) Successful in 25s
CI / Build client (push) Successful in 36s
CI / Playwright E2E tests (push) Successful in 1m20s
CI / Build and push Docker image (push) Successful in 2m46s
CI / Notify (push) Successful in 1s
This commit is contained in:
5 files changed
+303
-129
No files matched your search
@@ -2,7 +2,8 @@ import { useEffect, useState } from "react";
|
||||
import { Navbar, Nav, NavDropdown, Modal, Button } from "react-bootstrap";
|
||||
import { useAuth } from "../context/auth";
|
||||
import SettingsModal from "./modals/SettingsModal";
|
||||
import { useSettings, ThemePreference, ColorTheme } from "../context/settings";
|
||||
import { useSettings, ThemePreference } from "../context/settings";
|
||||
import HuePicker from "./HuePicker";
|
||||
import FeaturesVotingModal from "./modals/FeaturesVotingModal";
|
||||
import PizzaCalculatorModal from "./modals/PizzaCalculatorModal";
|
||||
import RefreshMenuModal from "./modals/RefreshMenuModal";
|
||||
@@ -13,7 +14,7 @@ import { useNavigate } from "react-router";
|
||||
import { STATS_URL, OBJEDNANI_URL } from "../AppRoutes";
|
||||
import { FeatureRequest, getVotes, updateVote, LunchChoices, getChangelogs } from "../../../types";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faSun, faMoon, faPalette } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faSun, faMoon } from "@fortawesome/free-solid-svg-icons";
|
||||
import { formatDateString } from "../Utils";
|
||||
|
||||
const LAST_SEEN_CHANGELOG_KEY = "lastChangelogDate";
|
||||
@@ -40,25 +41,7 @@ export default function Header({ choices, dayIndex }: Props) {
|
||||
const [clearMockModalOpen, setClearMockModalOpen] = useState<boolean>(false);
|
||||
const [featureVotes, setFeatureVotes] = useState<FeatureRequest[] | undefined>([]);
|
||||
|
||||
// Zjistíme aktuální efektivní téma (pro zobrazení správné ikony)
|
||||
const [effectiveTheme, setEffectiveTheme] = useState<'light' | 'dark'>('light');
|
||||
|
||||
useEffect(() => {
|
||||
const updateEffectiveTheme = () => {
|
||||
if (settings?.themePreference === 'system') {
|
||||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
setEffectiveTheme(isDark ? 'dark' : 'light');
|
||||
} else {
|
||||
setEffectiveTheme(settings?.themePreference || 'light');
|
||||
}
|
||||
};
|
||||
|
||||
updateEffectiveTheme();
|
||||
|
||||
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
mediaQuery.addEventListener('change', updateEffectiveTheme);
|
||||
return () => mediaQuery.removeEventListener('change', updateEffectiveTheme);
|
||||
}, [settings?.themePreference]);
|
||||
const effectiveDark = settings?.effectiveDark ?? false;
|
||||
|
||||
useEffect(() => {
|
||||
if (auth?.login) {
|
||||
@@ -110,8 +93,7 @@ export default function Header({ choices, dayIndex }: Props) {
|
||||
}
|
||||
|
||||
const toggleTheme = () => {
|
||||
// Přepínáme mezi light a dark (ignorujeme system pro jednoduchost)
|
||||
const newTheme: ThemePreference = effectiveTheme === 'dark' ? 'light' : 'dark';
|
||||
const newTheme: ThemePreference = effectiveDark ? 'light' : 'dark';
|
||||
settings?.setThemePreference(newTheme);
|
||||
}
|
||||
|
||||
@@ -195,21 +177,16 @@ export default function Header({ choices, dayIndex }: Props) {
|
||||
<button
|
||||
className="theme-toggle"
|
||||
onClick={toggleTheme}
|
||||
title={effectiveTheme === 'dark' ? 'Přepnout na světlý režim' : 'Přepnout na tmavý režim'}
|
||||
title={effectiveDark ? 'Přepnout na světlý režim' : 'Přepnout na tmavý režim'}
|
||||
aria-label="Přepnout světlý/tmavý režim"
|
||||
>
|
||||
<FontAwesomeIcon icon={effectiveTheme === 'dark' ? faSun : faMoon} />
|
||||
<FontAwesomeIcon icon={effectiveDark ? faSun : faMoon} />
|
||||
</button>
|
||||
<NavDropdown
|
||||
align="end"
|
||||
title={<FontAwesomeIcon icon={faPalette} />}
|
||||
id="color-theme-dropdown"
|
||||
className="theme-toggle"
|
||||
>
|
||||
<NavDropdown.Item active={settings?.colorTheme === 'green'} onClick={() => settings?.setColorTheme('green' as ColorTheme)}>🟢 Zelený</NavDropdown.Item>
|
||||
<NavDropdown.Item active={settings?.colorTheme === 'blue'} onClick={() => settings?.setColorTheme('blue' as ColorTheme)}>🔵 Modrý</NavDropdown.Item>
|
||||
<NavDropdown.Item active={settings?.colorTheme === 'purple'} onClick={() => settings?.setColorTheme('purple' as ColorTheme)}>🟣 Fialový</NavDropdown.Item>
|
||||
</NavDropdown>
|
||||
<HuePicker
|
||||
accentHue={settings?.accentHue ?? 142}
|
||||
isDark={effectiveDark}
|
||||
onChange={hue => settings?.setAccentHue(hue)}
|
||||
/>
|
||||
<NavDropdown align="end" title={auth?.login} id="basic-nav-dropdown">
|
||||
<NavDropdown.Item onClick={() => setSettingsModalOpen(true)}>Nastavení</NavDropdown.Item>
|
||||
<NavDropdown.Item onClick={() => setRefreshMenuModalOpen(true)}>Přenačtení menu</NavDropdown.Item>
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
.hue-picker-dropdown {
|
||||
.dropdown-toggle {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
color: var(--luncher-navbar-text) !important;
|
||||
padding: 8px 12px;
|
||||
font-size: 1.1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border-radius: var(--luncher-radius-sm);
|
||||
transition: var(--luncher-transition);
|
||||
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hue-picker-panel {
|
||||
padding: 0 !important;
|
||||
min-width: 240px;
|
||||
|
||||
.hue-picker-inner {
|
||||
padding: 14px 16px;
|
||||
}
|
||||
|
||||
.hue-picker-label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--luncher-text-secondary);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.hue-slider {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
height: 12px;
|
||||
border-radius: 6px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
hsl(0 70% 50%), hsl(30 70% 50%), hsl(60 70% 50%), hsl(90 70% 50%),
|
||||
hsl(120 70% 50%), hsl(150 70% 50%), hsl(180 70% 50%), hsl(210 70% 50%),
|
||||
hsl(240 70% 50%), hsl(270 70% 50%), hsl(300 70% 50%), hsl(330 70% 50%), hsl(360 70% 50%)
|
||||
);
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
margin-bottom: 14px;
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
border: 2px solid rgba(0, 0, 0, 0.25);
|
||||
cursor: pointer;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.15);
|
||||
}
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
border: 2px solid rgba(0, 0, 0, 0.25);
|
||||
cursor: pointer;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.hue-presets {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
|
||||
.hue-swatch {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
transition: transform 0.15s ease, border-color 0.15s ease;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.15);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--luncher-text);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hue-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid var(--luncher-border);
|
||||
|
||||
.hue-preview-chip {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--luncher-radius-sm);
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 0.8rem;
|
||||
color: var(--luncher-text-secondary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { Dropdown } from 'react-bootstrap';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faPalette } from '@fortawesome/free-solid-svg-icons';
|
||||
import './HuePicker.scss';
|
||||
|
||||
const PRESETS = [
|
||||
{ hue: 142, label: 'Zelená' },
|
||||
{ hue: 217, label: 'Modrá' },
|
||||
{ hue: 263, label: 'Fialová' },
|
||||
{ hue: 0, label: 'Červená' },
|
||||
{ hue: 28, label: 'Oranžová' },
|
||||
{ hue: 340, label: 'Růžová' },
|
||||
];
|
||||
|
||||
type Props = {
|
||||
accentHue: number;
|
||||
isDark: boolean;
|
||||
onChange: (hue: number) => void;
|
||||
};
|
||||
|
||||
function swatchColor(hue: number, isDark: boolean): string {
|
||||
return `hsl(${hue} 70% ${isDark ? 55 : 38}%)`;
|
||||
}
|
||||
|
||||
export default function HuePicker({ accentHue, isDark, onChange }: Props) {
|
||||
return (
|
||||
<Dropdown align="end" autoClose="outside" className="hue-picker-dropdown">
|
||||
<Dropdown.Toggle
|
||||
as="button"
|
||||
className="theme-toggle"
|
||||
aria-label="Barva zvýraznění"
|
||||
title="Barva zvýraznění"
|
||||
>
|
||||
<FontAwesomeIcon icon={faPalette} />
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu className="hue-picker-panel">
|
||||
<div className="hue-picker-inner">
|
||||
<div className="hue-picker-label">Barva zvýraznění</div>
|
||||
<input
|
||||
type="range"
|
||||
min={0}
|
||||
max={360}
|
||||
value={accentHue}
|
||||
onChange={e => onChange(parseInt(e.target.value, 10))}
|
||||
className="hue-slider"
|
||||
aria-label="Odstín barvy zvýraznění"
|
||||
/>
|
||||
<div className="hue-presets">
|
||||
{PRESETS.map(p => (
|
||||
<button
|
||||
key={p.hue}
|
||||
className={`hue-swatch${accentHue === p.hue ? ' active' : ''}`}
|
||||
style={{ background: swatchColor(p.hue, isDark) }}
|
||||
title={p.label}
|
||||
onClick={() => onChange(p.hue)}
|
||||
aria-label={p.label}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="hue-preview">
|
||||
<div
|
||||
className="hue-preview-chip"
|
||||
style={{ background: swatchColor(accentHue, isDark) }}
|
||||
/>
|
||||
<span>Aktuální barva zvýraznění</span>
|
||||
</div>
|
||||
</div>
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user