refactor(css): row 216 — sass is leading for ALL css files, not just plain.css

Previously only css/plain.css was compiled from sass/plain.sass; css/custom.css
and css/fonts.css were hand-written. Now every theme stylesheet has a leading
sass source: sass/plain.sass, sass/custom.sass, sass/fonts.sass (partials _*),
compiled with 'sass --watch sass:css' (dart-sass 1.83.4 added as local
devDependency; node_modules/package.json stay gitignored). css/*.css are build
artifacts and remain the committed runtime files; sass/ stays developer-local.
Recompiled output is semantically identical to the previous hand-written files
(dart-sass normalization only: 2-space indent, double quotes, @charset).
variants/export_public.sh step 0 now checks BOTH directions for every pair:
stale css/<name>.css vs sass/<name>.sass aborts, and a css file without a sass
source aborts; compiler resolved from PATH or node_modules/.bin/sass.
.gitignore/README document the workflow.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-30 09:11:39 +01:00
commit 756c0ec2d1
5 changed files with 158 additions and 130 deletions

8
.gitignore vendored
View file

@ -18,9 +18,11 @@
/variants/leak-patterns.txt /variants/leak-patterns.txt
/variants/tests/ /variants/tests/
# sass/ sources are developer-only: they are compiled locally to css/plain.css # sass/ sources are developer-only and LEADING: every sass/*.sass (except _*
# (which IS committed). LimeSurvey serves the committed css and never compiles # partials) is compiled locally to its css/<name>.css counterpart (which IS
# sass itself. The .sass files were purged from history with git filter-repo. # committed — sass is leading, css is the build artifact). LimeSurvey serves
# the committed css and never compiles sass itself. The .sass files were purged
# from history with git filter-repo. Watcher: `sass --watch sass:css`.
/sass/ /sass/
# Source maps are artifacts of the local sass compile — not needed at runtime # Source maps are artifacts of the local sass compile — not needed at runtime

View file

@ -67,12 +67,15 @@ Arguments for choosing Respondage Vanilla:
sizes/weights/colors, header logos, ...). sizes/weights/colors, header logos, ...).
- `views/` — twig overrides (header with left/center/right logos and navbar - `views/` — twig overrides (header with left/center/right logos and navbar
menu color, survey list, question, group description). menu color, survey list, question, group description).
- `css/plain.css` — theme styles (listed in config.xml `<files>` and served - `css/*.css` — theme styles (listed in config.xml `<files>` and served
as-is by LimeSurvey). The asset manager hashes the file mtime into the as-is by LimeSurvey). The asset manager hashes the file mtime into the
published URL, so a changed css is picked up automatically (no cache clear published URL, so a changed css is picked up automatically (no cache clear
needed). needed). These are BUILD ARTIFACTS: the leading sources are the
- `css/custom.css`, `scripts/custom.js` — loaded last, safe for project developer-local `sass/*.sass` files (gitignored) — edit the .sass, compile
tweaks. with `sass --watch sass:css` (or `sass sass/<name>.sass css/<name>.css`),
commit the recompiled css. `variants/export_public.sh` aborts the public
export if any css/*.css is stale or has no sass source.
- `scripts/custom.js` — loaded last, safe for project tweaks.
- `options/` — the CUSTOM options page: config.xml sets - `options/` — the CUSTOM options page: config.xml sets
`<optionspage>custom</optionspage>`, so LimeSurvey renders `<optionspage>custom</optionspage>`, so LimeSurvey renders
`options/options.twig` (and auto-registers `options/options.js`) instead of `options/options.twig` (and auto-registers `options/options.js`) instead of
@ -442,7 +445,7 @@ are gitignored (see `.gitignore`), so they are never pushed:
- `variants/` — build/export tooling (`build.php`, `export_public.sh`) and the - `variants/` — build/export tooling (`build.php`, `export_public.sh`) and the
confidential client definitions (`*.json`, `leak-patterns.txt`, confidential client definitions (`*.json`, `leak-patterns.txt`,
`README.internal.md`); `README.internal.md`);
- `sass/` — developer-only sources of `css/plain.css`; - `sass/` — developer-only LEADING sources of all `css/*.css` (compiled locally with `sass --watch sass:css`);
- `css/*.map` — source maps from the local sass compile; - `css/*.map` — source maps from the local sass compile;
- `AGENTS.md`, `prompts.md`, `FEATURE_REQUEST*.md`, `BUG_REPORT*.md` — internal notes and drafts; - `AGENTS.md`, `prompts.md`, `FEATURE_REQUEST*.md`, `BUG_REPORT*.md` — internal notes and drafts;
- `/dist/` — old export zips. - `/dist/` — old export zips.

View file

@ -1,18 +1,13 @@
/****************** @charset "UTF-8";
User custom CSS /* User custom CSS — compiled from this file (sass is leading): edit sass/custom.sass, then `sass --watch sass:css` or `sass sass/custom.sass css/custom.css`. */
--------------- /* It is loaded last, so you can override any other property; it will never be updated by theme upgrades. */
/* The compiled css/custom.css is the committed runtime file; sass/ stays developer-local (gitignored). */
In this file you can add your own custom CSS
It will be loaded last, so you can override any other property.
Also, it will never be updated. So if you inheritate a core template and just add here some CSS, you'll still benefit of all the updates
*/
#outerframeContainer { #outerframeContainer {
hyphens: none; hyphens: none;
} }
/* Subtle theme credit at the bottom of every page /* Subtle theme credit at the bottom of every page
(rendered by views/subviews/footer/footer.twig) */ * (rendered by views/subviews/footer/footer.twig) */
.respondage-theme-footer { .respondage-theme-footer {
padding: 1rem 0 1.5rem; padding: 1rem 0 1.5rem;
opacity: 0.75; opacity: 0.75;
@ -26,12 +21,12 @@
} }
/* row 214: untouched slider = grey handle + transparent selection; touched = /* row 214: untouched slider = grey handle + transparent selection; touched =
sliderhandlecolor (the .slider-handle rule in custom_header.twig). * sliderhandlecolor (the .slider-handle rule in custom_header.twig).
The slider-is-untouched class is synced onto li.slider-item by * The slider-is-untouched class is synced onto li.slider-item by
scripts/custom.js from the answer input's value — core's own * scripts/custom.js from the answer input's value — core's own
slider-untouched class on the .slider element is unreliable when * slider-untouched class on the .slider element is unreliable when
"slider_default_set" is on. Specificity (0,3,0) beats the .slider-handle * "slider_default_set" is on. Specificity (0,3,0) beats the .slider-handle
rule (0,1,0) from custom_header.twig regardless of style-block order. */ * rule (0,1,0) from custom_header.twig regardless of style-block order. */
.slider-item.slider-is-untouched .slider-handle { .slider-item.slider-is-untouched .slider-handle {
background-color: grey; background-color: grey;
} }
@ -42,10 +37,12 @@
} }
/* row 215: while untouched, also hide the value tooltip — core only does that /* row 215: while untouched, also hide the value tooltip — core only does that
(jQuery .hide()) when no default position is set; with slider_default_set * (jQuery .hide()) when no default position is set; with slider_default_set
the tooltip stays visible on an untouched slider. No !important on purpose: * the tooltip stays visible on an untouched slider. No !important on purpose:
on touch core sets an inline display via .show(), which wins over this rule * on touch core sets an inline display via .show(), which wins over this rule
(and slider-is-untouched is removed anyway). */ * (and slider-is-untouched is removed anyway). */
.slider-item.slider-is-untouched .slider .tooltip { .slider-item.slider-is-untouched .slider .tooltip {
display: none; display: none;
} }
/*# sourceMappingURL=custom.css.map */

View file

@ -1,115 +1,105 @@
/* @charset "UTF-8";
* Bundled open source fonts for vanilla_respondage. /* Bundled open source fonts for vanilla_respondage — compiled from this file (sass is leading): edit sass/fonts.sass, then `sass --watch sass:css` or `sass sass/fonts.sass css/fonts.css`. */
* /* The font files live in ../files/fonts/ (the asset manager copies the whole theme directory to the assets dir, so this relative path works from css/). */
* The font files live in ../files/fonts/ (the asset manager copies the whole /* Each font is selectable in the theme options (Fonts category, optgroup "Bundled open source fonts" in config.xml). The class rules are GENERIC (.font-<value>, not body-scoped) on purpose: */
* theme directory to the assets dir, so this relative path works from css/). /* the base font is applied as font-<value> on <body>, and per-element font overrides (fontselect options) apply the same class on individual elements. */
* Each font below is selectable in the theme options (Fonts category, optgroup /* To add your own font to this theme: see files/fonts/README.md. Licenses: SIL Open Font License 1.1 — see files/fonts/OFL-*.txt. */
* "Bundled open source fonts" in config.xml). The class rules are GENERIC
* (.font-<value>, not body-scoped) on purpose: the base font is applied as
* font-<value> on <body>, and the per-element font overrides (fontselect
* options) apply the same class on individual elements (header, progress bar,
* question titles, answers, group titles/descriptions, buttons).
*
* To add your own font to this theme: see files/fonts/README.md.
*
* Licenses: SIL Open Font License 1.1 — see files/fonts/OFL-*.txt.
*/
/* Inter — sans-serif — https://github.com/rsms/inter — OFL 1.1 */ /* Inter — sans-serif — https://github.com/rsms/inter — OFL 1.1 */
@font-face { @font-face {
font-family: 'Inter'; font-family: "Inter";
src: url('../files/fonts/inter-var.woff2') format('woff2'); src: url("../files/fonts/inter-var.woff2") format("woff2");
font-weight: 100 900; /* variable font: wght axis 100-900 */ /* variable font: wght axis 100-900 */
font-weight: 100 900;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* Source Serif 4 — serif — https://github.com/adobe-fonts/source-serif — OFL 1.1 */ /* Source Serif 4 — serif — https://github.com/adobe-fonts/source-serif — OFL 1.1 */
@font-face { @font-face {
font-family: 'Source Serif 4'; font-family: "Source Serif 4";
src: url('../files/fonts/source-serif-4-var.woff2') format('woff2'); src: url("../files/fonts/source-serif-4-var.woff2") format("woff2");
font-weight: 200 900; /* variable font: wght axis 200-900 */ /* variable font: wght axis 200-900 */
font-weight: 200 900;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* EB Garamond — serif — https://open-foundry.com/fonts/eb-garamond — OFL 1.1 */ /* EB Garamond — serif — https://open-foundry.com/fonts/eb-garamond — OFL 1.1 */
@font-face { @font-face {
font-family: 'EB Garamond'; font-family: "EB Garamond";
src: url('../files/fonts/eb-garamond-var.woff2') format('woff2'); src: url("../files/fonts/eb-garamond-var.woff2") format("woff2");
font-weight: 400 800; /* variable font: wght axis 400-800 */ /* variable font: wght axis 400-800 */
font-weight: 400 800;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* Liberation Sans — sans-serif — https://open-foundry.com/fonts/liberation-sans — OFL 1.1 /* Liberation Sans — sans-serif — https://open-foundry.com/fonts/liberation-sans — OFL 1.1
(static weights: 400 and 700 are shipped as separate files) */ * (static weights: 400 and 700 are shipped as separate files) */
@font-face { @font-face {
font-family: 'Liberation Sans'; font-family: "Liberation Sans";
src: url('../files/fonts/liberation-sans-400.woff2') format('woff2'); src: url("../files/fonts/liberation-sans-400.woff2") format("woff2");
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
@font-face { @font-face {
font-family: 'Liberation Sans'; font-family: "Liberation Sans";
src: url('../files/fonts/liberation-sans-700.woff2') format('woff2'); src: url("../files/fonts/liberation-sans-700.woff2") format("woff2");
font-weight: 700; font-weight: 700;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* Noto Sans — sans-serif — source: Google Fonts family "Noto Sans" — OFL 1.1 */ /* Noto Sans — sans-serif — source: Google Fonts family "Noto Sans" — OFL 1.1 */
@font-face { @font-face {
font-family: 'Noto Sans'; font-family: "Noto Sans";
src: url('../files/fonts/noto-sans-var.woff2') format('woff2'); src: url("../files/fonts/noto-sans-var.woff2") format("woff2");
font-weight: 100 900; /* variable font: wght axis 100-900 (wdth stays at default 100) */ /* variable font: wght axis 100-900 (wdth stays at default 100) */
font-weight: 100 900;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* Noto Serif — serif — source: Google Fonts family "Noto Serif" — OFL 1.1 */ /* Noto Serif — serif — source: Google Fonts family "Noto Serif" — OFL 1.1 */
@font-face { @font-face {
font-family: 'Noto Serif'; font-family: "Noto Serif";
src: url('../files/fonts/noto-serif-var.woff2') format('woff2'); src: url("../files/fonts/noto-serif-var.woff2") format("woff2");
font-weight: 100 900; /* variable font: wght axis 100-900 (wdth stays at default 100) */ /* variable font: wght axis 100-900 (wdth stays at default 100) */
font-weight: 100 900;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
/* Open Sans — sans-serif — source: Google Fonts family "Open Sans" — OFL 1.1 */ /* Open Sans — sans-serif — source: Google Fonts family "Open Sans" — OFL 1.1 */
@font-face { @font-face {
font-family: 'Open Sans'; font-family: "Open Sans";
src: url('../files/fonts/open-sans-var.woff2') format('woff2'); src: url("../files/fonts/open-sans-var.woff2") format("woff2");
font-weight: 300 800; /* variable font: wght axis 300-800 (wdth stays at default 100) */ /* variable font: wght axis 300-800 (wdth stays at default 100) */
font-weight: 300 800;
font-style: normal; font-style: normal;
font-display: swap; font-display: swap;
} }
.font-inter { .font-inter {
font-family: 'Inter', Arial, Helvetica, sans-serif; font-family: "Inter", Arial, Helvetica, sans-serif;
} }
.font-source_serif_4 { .font-source_serif_4 {
font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif; font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
} }
.font-eb_garamond { .font-eb_garamond {
font-family: 'EB Garamond', Georgia, 'Times New Roman', serif; font-family: "EB Garamond", Georgia, "Times New Roman", serif;
} }
.font-liberation_sans { .font-liberation_sans {
font-family: 'Liberation Sans', Arial, Helvetica, sans-serif; font-family: "Liberation Sans", Arial, Helvetica, sans-serif;
} }
.font-noto_sans { .font-noto_sans {
font-family: 'Noto Sans', Arial, Helvetica, sans-serif; font-family: "Noto Sans", Arial, Helvetica, sans-serif;
} }
.font-noto_serif { .font-noto_serif {
font-family: 'Noto Serif', Georgia, 'Times New Roman', serif; font-family: "Noto Serif", Georgia, "Times New Roman", serif;
} }
.font-open_sans { .font-open_sans {
font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-family: "Open Sans", Arial, Helvetica, sans-serif;
} }
/*# sourceMappingURL=fonts.css.map */

View file

@ -36,30 +36,66 @@ STAGE="$OUT_DIR/$MOTHER_NAME"
VERSION="$(sed -n 's:.*<version>\([^<]*\)</version>.*:\1:p' "$THEME_DIR/config.xml" | head -1)" VERSION="$(sed -n 's:.*<version>\([^<]*\)</version>.*:\1:p' "$THEME_DIR/config.xml" | head -1)"
ZIP_NAME="${MOTHER_NAME}-${VERSION}-public.zip" ZIP_NAME="${MOTHER_NAME}-${VERSION}-public.zip"
# 0. optional guard: css/plain.css must be in sync with sass/plain.sass. # 0. optional guard: SASS IS LEADING — every sass/*.sass must be compiled to
# LimeSurvey serves the committed css/plain.css and NEVER compiles sass # its css/<name>.css counterpart and every css/*.css must have a sass source.
# LimeSurvey serves the committed css/ files and NEVER compiles sass
# itself, so a stale compiled file would be shipped/served. If a sass # itself, so a stale compiled file would be shipped/served. If a sass
# compiler is on PATH AND the developer-local sass/ sources are present # compiler is available (on PATH, or the local devDependency
# (sass/ is gitignored and NOT part of this repo), recompile to a temp # node_modules/.bin/sass) AND the developer-local sass/ sources are present
# file and compare; abort on drift. # (sass/ is gitignored and NOT part of this repo), recompile each top-level
if command -v sass >/dev/null 2>&1 && [ -f "$THEME_DIR/sass/plain.sass" ]; then # sass source to a temp file and compare; abort on drift.
run_sass() {
if command -v sass >/dev/null 2>&1; then
sass "$@"
elif [ -x "$THEME_DIR/node_modules/.bin/sass" ]; then
# env -u LD_LIBRARY_PATH: harmless normally, works around a broken
# LD_LIBRARY_PATH that makes the shebang's `node` crash (glibc)
env -u LD_LIBRARY_PATH "$THEME_DIR/node_modules/.bin/sass" "$@"
else
return 1
fi
}
if [ -d "$THEME_DIR/sass" ] && run_sass --version >/dev/null 2>&1; then
STALE=0
for SRC in "$THEME_DIR"/sass/*.sass; do
[ -e "$SRC" ] || continue
BASE="$(basename "$SRC" .sass)"
case "$BASE" in _*) continue ;; esac # partials are not compiled standalone
CSS="$THEME_DIR/css/$BASE.css"
if [ ! -f "$CSS" ]; then
echo "ERROR: sass/$BASE.sass has no compiled counterpart css/$BASE.css - aborting." >&2
STALE=1; continue
fi
TMP_CSS="$(mktemp --suffix=.css)" TMP_CSS="$(mktemp --suffix=.css)"
if sass --no-source-map "$THEME_DIR/sass/plain.sass" "$TMP_CSS" 2>/dev/null; then if ! run_sass --no-source-map "$SRC" "$TMP_CSS" 2>/dev/null; then
echo "ERROR: sass/$BASE.sass does not compile - aborting." >&2
rm -f "$TMP_CSS"; STALE=1; continue
fi
# -B ignores blank-line-only changes (dart-sass adds one before the # -B ignores blank-line-only changes (dart-sass adds one before the
# sourceMappingURL comment); strip that comment line: it contains the # sourceMappingURL comment); strip that comment line: it contains the
# output file name and differs between the real and the temp output # output file name and differs between the real and the temp output
if ! diff -qB <(sed '/sourceMappingURL/d' "$THEME_DIR/css/plain.css") <(sed '/sourceMappingURL/d' "$TMP_CSS") >/dev/null 2>&1; then if ! diff -qB <(sed '/sourceMappingURL/d' "$CSS") <(sed '/sourceMappingURL/d' "$TMP_CSS") >/dev/null 2>&1; then
echo "ERROR: css/plain.css is stale relative to sass/plain.sass - aborting." >&2 echo "ERROR: css/$BASE.css is stale relative to sass/$BASE.sass - aborting." >&2
echo " Recompile in the theme dir, e.g.: sass sass/plain.sass css/plain.css" >&2 echo " Recompile in the theme dir, e.g.: sass --watch sass:css (all sass/*.sass -> css/*.css)" >&2
echo " (a watcher like 'sass --watch sass/plain.sass css/plain.css' prevents this)" >&2 echo " or per file: sass sass/$BASE.sass css/$BASE.css" >&2
echo " Commit the recompiled css/plain.css (the .map stays local, gitignored); sass/ is developer-local and not committed." >&2 echo " Commit the recompiled css/$BASE.css (the .map stays local, gitignored); sass/ is developer-local and not committed." >&2
rm -f "$TMP_CSS" STALE=1
exit 1
fi
fi fi
rm -f "$TMP_CSS" rm -f "$TMP_CSS"
done
# reverse direction: css is a build artifact, every css/*.css needs a sass source
for CSS in "$THEME_DIR"/css/*.css; do
[ -e "$CSS" ] || continue
BASE="$(basename "$CSS" .css)"
if [ ! -f "$THEME_DIR/sass/$BASE.sass" ]; then
echo "ERROR: css/$BASE.css has no leading sass source sass/$BASE.sass - aborting." >&2
echo " Create sass/$BASE.sass, compile it (sass --watch sass:css) and commit the result; sass is leading." >&2
STALE=1
fi
done
[ "$STALE" = "1" ] && exit 1
else else
echo "NOTE: 'sass' binary or local sass/ sources not present - skipped the css/plain.css sync check (sass/ is developer-local, gitignored)." >&2 echo "NOTE: 'sass' binary or local sass/ sources not present - skipped the sass->css sync check (sass/ is developer-local, gitignored)." >&2
fi fi
rm -rf "$STAGE" rm -rf "$STAGE"