weird
weird copied to clipboard
Theming: New Theming Pattern for Easier Customization
This issue proposes a new pattern to make theming the application easier and more maintainable.
Core Idea:
The idea is to shift towards a more component-centric architecture, separating data fetching and logic from presentation, and allowing themes to override both CSS and component templates (with guardrails).
Implementation Details:
-
Minimal Logic in Routes: Remove styling and logic from
+page.svelte
files. Keep most non-client-side logic in+page.server.ts
and pass data down to components. -
Component-Based Routes: Add a
components
folder inside each route, containing smaller components focused on presentation. -
Common Component Library: Move frequently used components to
$lib/components
for global reusability. - Initial Tailwind Styling: Use Tailwind CSS in the initial refactor to reduce review/explanation overhead.
-
$props
for Props: Use the$props
rune for accessing props in Svelte 5 components.
Theming Vision:
-
Primary Focus: CSS-Based Theming: Site admins should be able to override colors, spacing, etc., using a single
theme.css
file. - Secondary: Template Overrides: Offer a controlled option to override specific component templates.
- Future Exploration: We'll investigate alternative CSS theming strategies (CSS variables/open props, theming libraries) for more complex scenarios.
Guardrails for Theming:
- CSS Changes are Safe: Site admins are responsible for CSS-only theme changes.
- Template Override Responsibility: Theme developers are responsible for maintaining template overrides.
This enables:
- Faster Core Development: We can iterate quickly without worrying about breaking themes.
- Theme Developer Control: Themes have flexibility but also clear responsibilities.
Theming Hierarchy:
-
Global CSS Overrides:
theme.css
for site-wide styling changes. - Component Template Overrides: Replace default templates for specific components.
-
Route-Level Overrides: Override the entire
Page.svelte
component for a route. -
No Server-Side Theming: Theming changes should not affect
+page.server.ts
files.
Implementation Stages:
- Component-Based Refactoring: Convert routes to the new pattern (one route per PR), keeping existing logic and using Tailwind.
-
Extract Common Components: Move frequently used components to the
$lib
folder. - Establish Default Theme: Create the default theme (likely Tailwind-based).
- Investigate CSS Theming: Explore advanced CSS theming options (open props, libraries).