feat(variants): custom fonts per client variant
- config.xml: "Custom (this theme)" optgroup in the font dropdown plus an instruction comment on how to place a custom font (@font-face + body class in the variant's own css). - variants/build.php: supports "fontOptions" (dropdown entries) and "files_add" (extra css/js of the variant) in the variant json. - README.md: "Custom fonts per variant" section. data-font-package stays "websafe" because LimeSurvey only knows core font packages; the real font is loaded via the variant's css. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
b6a9ac74db
commit
02eda6c503
2 changed files with 68 additions and 1 deletions
33
README.md
33
README.md
|
|
@ -42,3 +42,36 @@ Option `logotopmargin` (Images category, e.g. `15px` or `0px`) sets the top
|
|||
padding of the header logos, applied in `custom_header.twig`. Use `0px` to
|
||||
align a logo exactly with the top of the screen.
|
||||
|
||||
## Custom fonts per variant
|
||||
|
||||
LimeSurvey only knows its core font packages (`application/config/fonts.php`),
|
||||
so a theme cannot register a `font-*` package itself. Instead a variant ships
|
||||
its own font files and css:
|
||||
|
||||
1. Put the font files in the variant's `files/fonts/` (e.g. `my-custom-font.woff2`).
|
||||
2. Create `css/variant.css` in the variant with the `@font-face` and the body
|
||||
class rule (the selected font is applied as `font-<value>` on `<body>`):
|
||||
```css
|
||||
@font-face {
|
||||
font-family: 'My Custom Font';
|
||||
src: url('../files/fonts/my-custom-font.woff2') format('woff2');
|
||||
font-weight: 400; font-style: normal;
|
||||
}
|
||||
body.font-my_custom_font {
|
||||
font-family: 'My Custom Font', Arial, sans-serif;
|
||||
}
|
||||
```
|
||||
(`../files/...` works because the asset manager copies the whole theme dir.)
|
||||
3. In `variants/<client>.json` declare the css file and the dropdown entry:
|
||||
```json
|
||||
{
|
||||
"files_add": { "css": ["css/variant.css"], "js": [] },
|
||||
"fontOptions": [ { "value": "my_custom_font", "label": "My Custom Font" } ]
|
||||
}
|
||||
```
|
||||
`build.php` appends the css to the `<files>` list and the font to the
|
||||
"Custom (this theme)" optgroup of the font dropdown (`data-font-package`
|
||||
stays `websafe`, so no nonexistent package is requested — the real font is
|
||||
loaded by the variant's own css).
|
||||
4. Run `php variants/build.php <client>` and upload/reset as usual.
|
||||
|
||||
|
|
|
|||
34
config.xml
34
config.xml
|
|
@ -109,10 +109,44 @@
|
|||
<progressbarcolor type="colorpicker" category="Colors" width="12" title="Progress bar color" options="on|off" optionlabels="Yes|No">#5e1c64</progressbarcolor>
|
||||
<progressbarfontcolor type="colorpicker" category="Colors" width="12" title="Progress bar font color" options="on|off" optionlabels="Yes|No">#ffffff</progressbarfontcolor>
|
||||
<privacybackgroundcolor type="colorpicker" category="Colors" width="12" title="Privacy background color" options="on|off" optionlabels="Yes|No">lightyellow</privacybackgroundcolor>
|
||||
<!-- fonts
|
||||
HOUSE-STYLE: the whole Fonts section (font choice, fontsize and all
|
||||
font sizes/weights) is house-style specific.
|
||||
|
||||
PLACING A CUSTOM FONT - instructions:
|
||||
1. Put the font file (e.g. .woff2) in the files/fonts/ folder of
|
||||
the variant (or of this mother theme if all variants should be
|
||||
able to pick the font).
|
||||
2. Create a css file in the variant, e.g. css/variant.css, with the
|
||||
@font-face and the body class (the selected font is applied as
|
||||
class font-<value> on <body>):
|
||||
@font-face {
|
||||
font-family: 'My Custom Font';
|
||||
src: url('../files/fonts/my-custom-font.woff2') format('woff2');
|
||||
}
|
||||
body.font-my_custom_font {
|
||||
font-family: 'My Custom Font', Arial, sans-serif;
|
||||
}
|
||||
('../files/...' works because the asset manager copies the whole
|
||||
theme dir; in css of the mother theme likewise: ../files/fonts/...)
|
||||
3. Add to variants/<client>.json:
|
||||
"files_add": { "css": ["css/variant.css"], "js": [] },
|
||||
"fontOptions": [ { "value": "my_custom_font",
|
||||
"label": "My Custom Font" } ]
|
||||
build.php appends the css to the <files> list and the font to the
|
||||
"Custom (this theme)" optgroup below. data-font-package stays
|
||||
"websafe": LimeSurvey only knows core font packages
|
||||
(application/config/fonts.php); the actual font is loaded via
|
||||
the variant's own css.
|
||||
4. Run: php variants/build.php <client> and upload/reset the theme.
|
||||
See also README.md ("Custom fonts per variant"). -->
|
||||
<!-- fonts -->
|
||||
<!-- When adding new items, please keep fonts ordered alphabetically -->
|
||||
<font type="dropdown" category="Fonts" width="4" title="Fonts" parent="font">opensans
|
||||
<dropdownoptions>
|
||||
<!-- Custom fonts of a variant are appended to the optgroup below by variants/build.php ("fontOptions" in the variant json) -->
|
||||
<optgroup label="Custom (this theme)">
|
||||
</optgroup>
|
||||
<optgroup label="User browser">
|
||||
<option class="font-arial " value="arial" data-font-package="websafe">Arial</option>
|
||||
<option class="font-arial_black " value="arial_black" data-font-package="websafe">Arial Black</option>
|
||||
|
|
|
|||
Loading…
Reference in a new issue