Frontend Development
Gyrinx follows a server-rendered approach using Django templates with Bootstrap 5 for styling. The frontend emphasizes simplicity, accessibility, and mobile-first design.
Technology Stack
Core Technologies
Django Templates - Server-side rendering with template inheritance
Bootstrap 5 - CSS framework for responsive design
SCSS - CSS preprocessing for maintainable styles
Vanilla JavaScript - Minimal client-side interactivity
Build Tools
npm - Package management and build scripts
SCSS compilation - CSS preprocessing
No bundlers - Keep it simple with direct file serving
Template Architecture
Template Hierarchy
Template Usage Patterns
Full Page Layout
Simple Content Page
Back Button Navigation
Styling with Bootstrap 5
Mobile-First Approach
All designs start with mobile layout and scale up:
Common Bootstrap Patterns
Cards for Content Grouping
Form Styling
Responsive Tables
SCSS Development
File Structure
Build Process
Custom Styling Approach
Override Bootstrap variables rather than writing custom CSS
Use Bootstrap utility classes when possible
Create component-specific styles only when needed
JavaScript Usage
Minimal JavaScript Philosophy
Gyrinx uses minimal JavaScript, favoring server-side rendering and simple form submissions.
When to Use JavaScript
Form enhancements (show/hide fields)
Client-side validation feedback
Simple interactive elements (dropdowns, modals)
Progressive enhancement only
JavaScript Patterns
Form Handling
Django Form Integration
Custom Form Rendering
Static File Management
Development
Production
WhiteNoise serves static files
Files are collected during deployment
CSS is compiled from SCSS in build process
File Organization
Performance Considerations
Template Performance
Use `
` efficiently - Cache template fragments with `` - Minimize database queries in templates
CSS Performance
Minimize custom CSS
Use Bootstrap utilities to reduce file size
Optimize images for web delivery
JavaScript Performance
Load JavaScript at end of
<body>Use event delegation for dynamic content
Avoid large JavaScript frameworks
Accessibility
Built-in Bootstrap Accessibility
Use semantic HTML elements
Leverage Bootstrap's ARIA attributes
Ensure keyboard navigation works
Custom Accessibility
Testing Frontend Code
Template Testing
CSS Testing
Visual regression testing (manual)
Cross-browser testing on common devices
Mobile responsiveness testing
JavaScript Testing
Manual testing for progressive enhancement
Ensure core functionality works without JavaScript
Future Considerations
htmx Integration
While not currently used, htmx could add interactivity:
Performance Monitoring
Consider adding Core Web Vitals monitoring
Monitor CSS bundle size growth
Track JavaScript execution time
Last updated