feat(variants): thin client themes on one shared code base
Architecture: a client theme extends this mother theme via <extends> and contains only a generated config.xml + its own files/ (logos). LimeSurvey inherits all views/css/js/images from the mother, so changes here apply to every variant immediately. - variants/<client>.json holds ONLY the house-style values (colors, fonts, font sizes/weights/colors, logo files, logotopmargin, custom fonts). - variants/build.php generates ../<client>/config.xml from the mother config.xml + the json: only those values are replaced, <extends> is set, <engine> is emptied except <optionspage>. Unknown option keys fail the build loudly, so drift is caught at build time. - Client definitions (variants/<client>.json) are gitignored (see .gitignore) and live in a PRIVATE variants repo or locally; build.php reads them from there via its 2nd argument or RESPONDAGE_VARIANTS_DIR. - README.md: "Client variants" workflow. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
02eda6c503
commit
80a3d4a079
1 changed files with 273 additions and 0 deletions
41
README.md
41
README.md
|
|
@ -75,3 +75,44 @@ its own font files and css:
|
|||
loaded by the variant's own css).
|
||||
4. Run `php variants/build.php <client>` and upload/reset as usual.
|
||||
|
||||
## Client variants (house styles) without code duplication
|
||||
|
||||
House-style-specific values are ONLY: colors, fonts, and font
|
||||
sizes/colors/weights (plus logo files). Everything else lives once, here.
|
||||
|
||||
Workflow:
|
||||
|
||||
1. In `config.xml`, the house-style options are marked with `HOUSE-STYLE`
|
||||
comments (colors, fonts, font sizes/weights, logo files, logo top margin,
|
||||
background image/color). Only those values belong in a variant json —
|
||||
never hardcode house-style values in shared files (`views/`, `sass/`,
|
||||
`css/`, `scripts/`), because those are inherited by all variants.
|
||||
2. Create `variants/<client>.json` with the variant name/title/description and
|
||||
only the house-style option keys with the client values:
|
||||
```json
|
||||
{
|
||||
"name": "client_vanilla",
|
||||
"title": "Client Vanilla",
|
||||
"options": { "primarycolor": "#123456", "fontsize": "18px" }
|
||||
}
|
||||
```
|
||||
2. Run `php variants/build.php <client>`. This generates
|
||||
`../<client>/config.xml`: a copy of this theme's config.xml with only those
|
||||
option values replaced, `<extends>` set to this theme, and the `<engine>`
|
||||
section emptied except `<optionspage>` (same as LimeSurvey's own "extend
|
||||
theme" action), so engine settings are inherited. The `<files>` list is
|
||||
kept: LimeSurvey resolves each listed file in the variant first and then in
|
||||
the mother, so the mother's css/js keep loading until a variant ships its
|
||||
own file with the same name. Unknown option keys make the build fail
|
||||
loudly, so drift is caught at build time.
|
||||
3. Put the client's images in `../<client>/files/`, upload the folder to
|
||||
`upload/themes/survey/`, install/reset the theme in LimeSurvey.
|
||||
|
||||
Because of the native `<extends>` mechanism:
|
||||
- changes to any file (twig/css/js) in this mother theme apply to all
|
||||
variants immediately — edit them only here;
|
||||
- changes to non-house-style option defaults in `config.xml` apply to a
|
||||
variant after re-running the build script and resetting that variant theme;
|
||||
- house-style values live only in `variants/<client>.json` and the variant's
|
||||
`files/`, so they are never overwritten by changes in this mother theme.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue