The Theme Service manages the application’s color scheme by reading and writing CSS variables in the layout file. It provides automatic synchronization of color aliases.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ashcroft08/provesa-web/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The theme service operates directly on thesrc/routes/layout.css file, using regular expressions to extract and update CSS custom properties. It maintains the site’s color palette including primary, secondary, accent, and background colors.
Color Synchronization
The service automatically synchronizes color aliases:--color-accent-redfollowsaccent--color-accent-yellowfollowssecondary
Methods
getThemeColors()
Retrieves the current theme colors from the CSS file.Primary brand color (hex format). Default:
#455dd9Secondary brand color (hex format). Default:
#ffd100Accent color for highlights (hex format). Default:
#e4002bBackground color (hex format). Default:
#ffffffError Handling
If the CSS file cannot be read, returns default colors:Implementation Details
Source:src/lib/server/services/theme.service.js:9-22
The method uses regex patterns to extract colors:
updateThemeColors()
Updates theme colors in the CSS file with automatic alias synchronization.New primary color in hex format
New secondary color in hex format. Also updates
--color-accent-yellowNew accent color in hex format. Also updates
--color-accent-redNew background color in hex format
Automatic Synchronization
When updating colors, the service maintains consistency:- Secondary → Accent Yellow: When
secondaryis updated,--color-accent-yellowis automatically set to the same value - Accent → Accent Red: When
accentis updated,--color-accent-redis automatically set to the same value
Error Handling
Throws an error if the CSS file cannot be written:Implementation Details
Source:src/lib/server/services/theme.service.js:30-56
The method performs regex replacements:
Usage Example
Complete Theme Update Flow
SvelteKit Server Route Example
File Location
The service operates on:CSS Variables Managed
The following CSS custom properties are managed by this service:--color-primary: Main brand color--color-secondary: Secondary brand color--color-accent: Accent/highlight color--color-background: Background color--color-accent-red: Synchronized with accent--color-accent-yellow: Synchronized with secondary
Best Practices
Changes to theme colors take effect immediately in the CSS file but may require a browser refresh for users to see the updated colors.
