The Comserv Theme System provides a flexible and maintainable approach to styling the application. It allows for site-specific themes, custom color schemes, and centralized style management while maintaining backward compatibility with existing CSS.
This system replaces the previous approach of having separate CSS files for each site with a more structured theme-based approach that promotes consistency and reduces duplication.
The primary goals of the theme system are:
The theme system is being implemented in a progressive manner to ensure backward compatibility and minimize disruption:
This progressive approach allows for incremental implementation and testing, ensuring that each phase works correctly before proceeding to the next. The system will continue to function with the existing CSS configuration until fully migrated to the database-driven version.
Each theme consists of a CSS file located in the /static/css/themes/
directory. The theme files use CSS variables (custom properties) to define colors, fonts, and other style elements that can be customized.
The base theme (default.css
) defines the core styles and variables used by all themes. It includes:
:root { --primary-color: #ffffff; --secondary-color: #f9f9f9; --accent-color: #FF9900; --text-color: #000000; --link-color: #0000FF; --link-hover-color: #000099; --background-color: #ffffff; --border-color: #dddddd; --table-header-bg: #f2f2f2; --warning-color: #f39c12; --success-color: #27ae60; --button-bg: var(--primary-color); --button-text: #ffffff; --button-border: var(--primary-color); --button-hover-bg: var(--secondary-color); }
Custom themes override these variables to create different visual styles without changing the underlying HTML structure.
Theme files are organized in the following structure:
/static/css/themes/ âââ default.css # Base theme with core variables âââ apis.css # Apis-specific theme âââ usbm.css # USBM-specific theme âââ csc.css # CSC-specific theme âââ site_name_custom.css # Custom themes for specific sites
Custom themes can be created in two ways:
Create a new CSS file in the /static/css/themes/
directory that overrides the default variables:
/* custom_theme.css */ :root { --primary-color: #9b59b6; --secondary-color: #34495e; --accent-color: #f1c40f; /* Override other variables as needed */ }
Use the theme management interface in the admin area to create a custom theme by selecting colors and other options. The system will generate the CSS file automatically.
The theme system includes an admin interface for managing themes, accessible at /admin/theme
.
To access the theme management interface, users must:
To migrate an existing site to the theme system:
add_theme_column.pl
script to add it if neededdefault.css
to your_site_name.css
/admin/theme
to select your themeUPDATE sites SET theme = 'your_theme_name' WHERE name = 'YOUR_SITE_NAME';
/static/css/themes/
add_theme_column.pl
scriptALTER TABLE sites ADD COLUMN theme VARCHAR(50) DEFAULT 'default';