mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:21:10 +02:00
SUMMARY: Create a unified theming architecture with two new shared packages (@manacore/shared-theme and @manacore/shared-theme-ui) that provides consistent theming across all 4 web applications while allowing app-specific primary color customization. NEW PACKAGES: @manacore/shared-theme: - Svelte 5 Runes-based theme store factory - 4 theme variants: Lume (Gold), Nature (Green), Stone (Blue Gray), Ocean (Blue) - 3 theme modes: Light, Dark, System (auto-detect) - HSL-based color system with 18 semantic tokens - localStorage persistence per app - System preference detection via matchMedia - Pre-defined configs for all apps (memoro, manacore, manadeck, maerchenzauber) @manacore/shared-theme-ui: - ThemeToggle: Light/dark mode toggle button - ThemeSelector: Visual theme variant selector with color dots - ThemeModeSelector: Segmented control for light/dark/system UPDATED PACKAGES: @manacore/shared-tailwind: - Converted from HEX to HSL-based CSS variables - Updated preset.js with hsl(var(--color-*)) syntax - themes.css now contains all 4 theme variants with light/dark modes APP MIGRATIONS: memoro/web: - Replaced 145 LOC theme store with 25 LOC shared implementation - Deleted local ThemeSelector.svelte and ThemeToggle.svelte - Primary color: Gold (47 95% 58%) manacore/web: - Replaced 80 LOC theme store with 25 LOC shared implementation - Deleted local ThemeToggle.svelte - Primary color: Indigo (239 84% 67%) manadeck/web: - Added new theme store using shared package - Primary color: Indigo (239 84% 67%) maerchenzauber/web: - Added new theme store using shared package - Primary color: Purple (280 60% 55%) All app layouts updated with theme.initialize() in onMount. BENEFITS: - ~225 LOC of app-specific code reduced to ~100 LOC total - Single source of truth for theme logic - Consistent theming experience across all apps - Easy to add new theme variants - App-specific primary colors preserved 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
87 lines
2 KiB
Svelte
87 lines
2 KiB
Svelte
<script lang="ts">
|
|
import type { ThemeStore, ThemeMode } from '@manacore/shared-theme';
|
|
import { Icon } from '@manacore/shared-icons';
|
|
|
|
interface Props {
|
|
/** Theme store instance */
|
|
theme: ThemeStore;
|
|
/** Additional CSS classes */
|
|
class?: string;
|
|
}
|
|
|
|
let { theme, class: className = '' }: Props = $props();
|
|
|
|
const modes: { mode: ThemeMode; icon: string; label: string }[] = [
|
|
{ mode: 'light', icon: 'sun', label: 'Light' },
|
|
{ mode: 'dark', icon: 'moon', label: 'Dark' },
|
|
{ mode: 'system', icon: 'monitor', label: 'System' },
|
|
];
|
|
</script>
|
|
|
|
<div class="mode-selector {className}" role="radiogroup" aria-label="Theme mode">
|
|
{#each modes as { mode, icon, label }}
|
|
{@const isActive = theme.mode === mode}
|
|
<button
|
|
type="button"
|
|
onclick={() => theme.setMode(mode)}
|
|
class="mode-button"
|
|
class:active={isActive}
|
|
role="radio"
|
|
aria-checked={isActive}
|
|
aria-label="{label} mode"
|
|
>
|
|
<Icon name={icon} size={16} />
|
|
<span class="label">{label}</span>
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
|
|
<style>
|
|
.mode-selector {
|
|
display: inline-flex;
|
|
padding: 0.25rem;
|
|
gap: 0.25rem;
|
|
background-color: hsl(var(--color-muted));
|
|
border-radius: 0.5rem;
|
|
}
|
|
|
|
.mode-button {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.375rem;
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.375rem;
|
|
background: transparent;
|
|
border: none;
|
|
cursor: pointer;
|
|
color: hsl(var(--color-muted-foreground));
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.mode-button:hover:not(.active) {
|
|
color: hsl(var(--color-foreground));
|
|
}
|
|
|
|
.mode-button.active {
|
|
background-color: hsl(var(--color-surface));
|
|
color: hsl(var(--color-foreground));
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.mode-button:focus-visible {
|
|
outline: 2px solid hsl(var(--color-ring));
|
|
outline-offset: 2px;
|
|
}
|
|
|
|
.label {
|
|
display: none;
|
|
}
|
|
|
|
@media (min-width: 640px) {
|
|
.label {
|
|
display: inline;
|
|
}
|
|
}
|
|
</style>
|