Status: Production Ready
Date: May 1, 2024
Implementation Phase: Styling Foundation & Integration
Successfully implemented a modular, scalable SCSS styling system for Anki flashcards with:
scripts/anki/styles/
├── _variables.scss # Global design tokens (colors, spacing, typography)
├── _base-components.scss # Reusable CSS classes for all card types
├── courses/
│ ├── psychology.scss # Psychology-specific color overrides
│ └── devops.scss # DevOps-specific styling
├── psychology.css # Compiled output (16 KB)
└── devops.css # Compiled output (17 KB)
User Card Data (JSON)
↓
metadata['course'] = 'psychology'
↓
APKGGenerator creates models
↓
_get_css('psychology')
↓
Load: scripts/anki/styles/psychology.css
↓
Inject CSS into Anki models
↓
Generate APKG with styled cards
_variables.scss)Color Palette:
Spacing Scale:
Typography:
Other Tokens:
_base-components.scss)Implements universal card types used by all courses:
Content Components:
.skill-card - Lists of skills with blue accent.comparison-box - Side-by-side comparisons.definition-card - Term + definition with gradient.highlight-card - Highlighted/quoted contentStatus Indicators:
.success-box - Green background, green border.warning-box - Orange background, orange border.danger-box - Red background, red border.info-box - Blue background, blue borderCode & Technical:
.code-block - Dark background, syntax highlighting.terminal-output - Black background, green text (classic terminal)code styling with light backgroundUtilities:
.text-center, .text-right, .text-left.text-bold, .text-italic, .text-small, .text-muted.mt-1, .mb-2, .p-3, etc.psychology.scss)Purpose: Support counselling skills, empathy training, therapeutic concepts
Color Scheme:
Custom Components:
.counselling-technique - Structured technique display.response-pattern - Counsellor response examples.skill-assessment - Skill evaluation framework.empathy-emphasis / .sympathy-emphasis - Comparative styling.counsellor-note - Advisory formattingTable Styling:
devops.scss)Purpose: Support infrastructure, cloud engineering, deployment workflows
Color Scheme:
Custom Components:
.command-box - Shell commands with output.architecture-component - Infrastructure diagrams.deployment-steps - Numbered workflow steps.configuration-box - Config key/value pairs.devops-alert - Incident/failure alertsSyntax Highlighting:
Status Styling:
.status-success - Green.status-error - Red.status-pending - Orange 1# Compile all course CSS
2npm run anki:styles:compile
3
4# Compile specific course
5npm run anki:styles:compile:psychology
6npm run anki:styles:compile:devops
7
8# Watch mode for development
9npm run anki:styles:watch
10
11# List compiled CSS files
12npm run anki:styles:list
scripts/anki/styles/courses/scripts/anki/styles/ (same directory for easy reference)Metadata Detection
1{
2 "metadata": {
3 "course": "psychology" // This key triggers CSS loading
4 }
5}
CSS Loading
data['metadata']['course']scripts/anki/styles/{course}.cssModel Creation
Result
✅ Psychology CSS integration verified (68.2 KB APKG)
✅ DevOps CSS integration verified (72.2 KB APKG)
✅ Default CSS fallback verified (56.2 KB APKG)
✅ CSS caching working correctly
✅ All 51 existing tests still passing
Create scripts/anki/styles/courses/{coursename}.scss:
1@import '../variables';
2@import '../base-components';
3
4// Override variables for your course
5$course-primary: #your-color;
6$course-accent: #another-color;
7
8// Override or enhance component styling
9.skill-card {
10 background-color: rgba($course-primary, 0.1);
11 border-left-color: $course-primary;
12}
1npx sass scripts/anki/styles/courses/{coursename}.scss \
2 scripts/anki/styles/{coursename}.css
1{
2 "metadata": {
3 "course": "coursename"
4 }
5}
The APKG generator automatically detects the course and injects the CSS!
_base-components.scss_variables.scss| File | Size | Lines | Purpose |
|---|---|---|---|
_variables.scss | 3.1 KB | 140+ | Global design tokens |
_base-components.scss | 11.3 KB | 450+ | Universal components |
psychology.scss | 6.5 KB | 280+ | Psychology overrides |
devops.scss | 7.2 KB | 320+ | DevOps overrides |
| File | Size |
|---|---|
psychology.css | 16 KB |
devops.css | 17 KB |
| Test File | Tests | Status |
|---|---|---|
test_css_integration.py | 3 scenarios | ✅ Passing |
test_apkg_generator.py | 25 tests | ✅ Passing |
| All Anki tests | 51 total | ✅ All Passing |
JSON:
1{
2 "id": "psy-001",
3 "question": "What are the core counselling skills?",
4 "answer": "<div class='skill-card'><h4>Core Skills</h4><ol class='skill-list'><li class='skill-item'><b>Empathy</b></li><li class='skill-item'><b>Active Listening</b></li></ol></div>",
5 "tags": ["counselling", "skills"],
6 "difficulty": 2,
7 "html_enabled": true
8}
Rendered In Anki:
JSON:
1{
2 "id": "devops-001",
3 "question": "Deploy to production",
4 "answer": "<div class='command-box'><div class='command-label'>Deploy Command:</div><div class='command-text'>kubectl apply -f deployment.yaml</div><div class='command-output'>deployment.apps/my-app created</div></div>",
5 "tags": ["kubernetes", "deployment"],
6 "difficulty": 2,
7 "html_enabled": true
8}
Rendered In Anki:
1[679f599f] test(anki): Add CSS integration test for APKG generation
2[547929e1] feat(anki): Integrate course-specific CSS into APKG generation
3[889cb6ee] build(anki): Compile course-specific SCSS to CSS and add npm scripts
4[cd4ba7fb] style(anki): Create comprehensive SCSS styling system
| Metric | Value |
|---|---|
| CSS Variables | 80+ |
| Base Components | 20+ classes |
| Psychology Components | 5+ custom classes |
| DevOps Components | 8+ custom classes |
| Courses Supported | 2 (foundation) → 50+ (scalable) |
| File Size Increase | +16-17 KB per APKG |
| Performance Impact | Negligible (CSS cached) |
| Breaking Changes | 0 |
| Test Pass Rate | 100% (51/51) |
For questions about the styling system:
content/docs/anki/tests/anki/test_css_integration.pycourse_styles.json for course registryStatus: ✅ Production Ready - SCSS system fully implemented and integrated