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>
6.7 KiB
Shared Packages Roadmap
This document outlines the plan to unify common code across all web apps in the monorepo.
Current Shared Packages
@manacore/shared-icons- Unified Phosphor Icons for all web apps@manacore/shared-ui- Unified UI Components (Text, Button, Badge, Toggle, Input, Modal)@manacore/shared-auth- Unified Auth Logic (Supabase client, token management)@manacore/shared-auth-ui- Unified Auth UI (LoginPage, RegisterPage, OAuth buttons)@manacore/shared-tailwind- Unified Tailwind Config (HSL colors, preset, themes.css)@manacore/shared-theme- NEW Unified Theme Store (Svelte 5, 4 variants, light/dark/system)@manacore/shared-theme-ui- NEW Theme UI Components (ThemeToggle, ThemeSelector)@manacore/shared-utils- Unified Utilities (formatting, validation, async)@manacore/shared-types- Unified TypeScript Types@manacore/shared-supabase- Unified Supabase Client Factory@manacore/shared-i18n- Unified i18n (languages, locale detection, translations)@manacore/shared-config- Unified Config (env validation)
Planned Shared Packages
1. Shared UI Components (@manacore/shared-ui)
Status: Done Priority: High Estimated LOC Savings: 500-800 per app
Components to unify:
Button.svelte- Primary, secondary, ghost, danger variantsInput.svelte- Text input with label, error statesText.svelte- Typography component with variantsModal.svelte- Overlay modal with header, body, footer slotsSpinner.svelte- Loading indicatorToast.svelte- Notification toastsBadge.svelte- Status badgesCard.svelte- Content containerDropdown.svelte- Select/dropdown menus
Apps using these:
- ManaCore Web
- Memoro Web
- Maerchenzauber Web
- ManaDeck Web
2. Shared Auth (@manacore/shared-auth)
Status: Done Priority: High Estimated LOC Savings: 800-1200 per app
Modules to unify:
tokenManager.ts- JWT token storage, refresh, validationauthService.ts- Login, logout, register, password resetsupabaseClient.ts- Authenticated Supabase client factoryauthStore.ts- Svelte store for auth stateauthGuard.ts- Route protection utilities
Considerations:
- Each app may have different Supabase projects
- Token storage strategy (localStorage vs cookies)
- OAuth providers per app
3. Shared Tailwind Config (@manacore/shared-tailwind)
Status: Done Priority: High Estimated Benefit: Consistent branding, easier theme updates
Config unified:
- Color palette (primary, secondary, accent colors)
- Theme variants (Lume, Nature, Stone, Ocean) with light/dark modes
- Typography scale (font sizes, line heights)
- Border radius tokens
- Shadow tokens
- CSS variable-based theming system
Structure:
packages/shared-tailwind/
├── package.json
├── src/
│ ├── index.js # Main exports
│ ├── preset.js # Tailwind preset with all tokens
│ ├── colors.js # Color definitions (4 themes)
│ ├── theme-variables.css # CSS variables for themes
│ └── components.css # Component utilities
Apps using this:
- Memoro Web (full migration with theme.css + components.css)
- ManaCore Web (preset only, keeps local colors)
- ManaDeck Web (colors import, HSL-based system)
- Maerchenzauber Web (dependency added)
4. Shared Utilities (@manacore/shared-utils)
Status: Done Priority: Medium Estimated LOC Savings: 200-400 per app
Utilities included:
date.ts- formatDate, formatRelativeTime, toISOStringformat.ts- formatDuration, formatFileSize, formatNumber, formatCurrency, formatPercentvalidation.ts- isValidEmail, isValidUrl, isValidPhone, validatePassword, isValidUuidstring.ts- truncate, capitalize, generateId, slugifyasync.ts- sleep, retry, debounce
5. Shared Types (@manacore/shared-types)
Status: Planned Priority: Medium Estimated Benefit: Type safety across packages
Types to unify:
User- Common user typeApiResponse<T>- Standard API response wrapperPaginatedResponse<T>- Pagination typesTheme- Theme configuration typesLocale- i18n locale types
Note: App-specific database types (Supabase generated) should remain in each app.
6. Shared i18n (@manacore/shared-i18n)
Status: Done Priority: Medium Estimated LOC Savings: 100-300 per app
Modules to unify:
i18n.ts- svelte-i18n setup and initializationdetectLocale.ts- Browser language detection- Common translations:
- Error messages
- UI labels (Save, Cancel, Delete, etc.)
- Date/time formats
- Validation messages
Structure:
packages/shared-i18n/
├── package.json
├── src/
│ ├── index.ts
│ ├── setup.ts
│ ├── detectLocale.ts
│ └── translations/
│ ├── common/
│ │ ├── en.json
│ │ └── de.json
│ └── errors/
│ ├── en.json
│ └── de.json
7. Shared Config (@manacore/shared-config)
Status: Planned Priority: Low Estimated Benefit: Consistent env handling
Config to unify:
- Environment variable validation (Zod schemas)
- API endpoint construction
- Feature flag utilities
- App metadata (version, name, etc.)
Implementation Order
-
Phase 1 (Completed)
@manacore/shared-icons@manacore/shared-ui
-
Phase 2 (Completed)
@manacore/shared-auth@manacore/shared-auth-ui@manacore/shared-tailwind
-
Phase 3 (Completed)
@manacore/shared-utils@manacore/shared-types@manacore/shared-supabase
-
Phase 4 (Completed)
@manacore/shared-i18n@manacore/shared-config
Guidelines for Shared Packages
Package Structure
packages/shared-{name}/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # Public exports
│ └── ...
└── README.md
Package.json Template
{
"name": "@manacore/shared-{name}",
"version": "0.1.0",
"private": true,
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts"
},
"peerDependencies": {
"svelte": "^5.0.0"
}
}
Best Practices
- Keep it minimal - Only share truly common code
- Document props - Use TypeScript interfaces with JSDoc
- Version carefully - Coordinate updates across apps
- Test thoroughly - Changes affect all apps
- Avoid breaking changes - Use deprecation warnings
Notes
- Created: 2025-11-24
- Last Updated: 2025-11-24
- Author: Claude Code