Overview
The GitHub profile README project supports automatic light/dark theme switching based on the user’s system preferences. Themes are implemented using CSS custom properties (CSS variables) within the SVG rendering system.How Theme Switching Works
Themes are controlled via adata-theme attribute on the SVG wrapper element. The theme is determined by URL parameters:
src/worker.ts:18
Theme Attribute
The SVG root element receives adata-theme attribute that triggers CSS variable changes:
Color Variables
The project uses a comprehensive color system defined in CSS custom properties. Here are the color variables from the source code:Root Color Definitions
src/render.ts:140-161
Theme-Specific Mappings
The active theme determines which color set is used:src/render.ts:178-196
Contribution Dot Colors
The contribution graph uses a 5-level color system (0-4) representing activity intensity:src/render.ts:423-427
Light Theme:
- Level 0: White (#FFFFFF) - No activity
- Level 1: Light gray (#e0e0e0)
- Level 2: Medium gray (#b0b0b0)
- Level 3: Dark gray (#808080)
- Level 4: Black (#202020) - Highest activity
- Level 0: Dark gray (#262626) - No activity
- Level 1: Lighter dark gray (#404040)
- Level 2: Medium gray (#686868)
- Level 3: Light gray (#a0a0a0)
- Level 4: White (#FFFFFF) - Highest activity
Font Configuration
The project uses the Geist font family with embedded base64-encoded font files for optimal loading:src/render.ts:162
Font Weights
Three font weights are embedded:-
Light (300) - Used for body copy and introductory text
- Reference:
src/render.ts:104-111
- Reference:
-
Normal (400) - Default text weight
- Reference:
src/render.ts:113-120
- Reference:
-
Bold (700) - Used for labels and emphasis
- Reference:
src/render.ts:122-129
- Reference:
-
Semibold (600) - Used for labels
- Reference:
src/render.ts:131-138
- Reference:
Font Display Strategy
Customizing Your Theme
Changing Colors
To customize the color palette, modify the CSS variables in your local version:- Text Colors: Edit
--color-text-lightand--color-text-dark - Dot Colors: Modify the
--color-dot-bg-*-lightand--color-dot-bg-*-darkvariables - Borders: Adjust
--color-dot-border-lightand--color-dot-border-dark
Creating Custom Themes
You can create additional theme variants by:- Adding new color variable sets
- Creating new
[data-theme="your-theme"]selectors - Mapping the theme-specific variables to your custom colors
Using Different Fonts
To use a different font family:- Replace the
@font-facedeclarations with your font - Update the
--font-primaryvariable - Ensure proper font-weight support for 300, 400, 600, and 700
Browser Compatibility
The theme system uses CSS custom properties, which are supported in all modern browsers. Note that Firefox has specific handling for certain features (see@-moz-document rules in the source).
Reference: src/render.ts:221-225