diff --git a/.gitignore b/.gitignore index 7759bdb..0e35705 100644 --- a/.gitignore +++ b/.gitignore @@ -18,9 +18,11 @@ /variants/leak-patterns.txt /variants/tests/ -# sass/ sources are developer-only: they are compiled locally to css/plain.css -# (which IS committed). LimeSurvey serves the committed css and never compiles -# sass itself. The .sass files were purged from history with git filter-repo. +# sass/ sources are developer-only and LEADING: every sass/*.sass (except _* +# partials) is compiled locally to its css/.css counterpart (which IS +# 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/ # Source maps are artifacts of the local sass compile — not needed at runtime diff --git a/README.md b/README.md index 823bf18..fe57be8 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,15 @@ Arguments for choosing Respondage Vanilla: sizes/weights/colors, header logos, ...). - `views/` — twig overrides (header with left/center/right logos and navbar menu color, survey list, question, group description). -- `css/plain.css` — theme styles (listed in config.xml `` and served +- `css/*.css` — theme styles (listed in config.xml `` and served 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 - needed). -- `css/custom.css`, `scripts/custom.js` — loaded last, safe for project - tweaks. + needed). These are BUILD ARTIFACTS: the leading sources are the + developer-local `sass/*.sass` files (gitignored) — edit the .sass, compile + with `sass --watch sass:css` (or `sass sass/.sass css/.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 `custom`, so LimeSurvey renders `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 confidential client definitions (`*.json`, `leak-patterns.txt`, `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; - `AGENTS.md`, `prompts.md`, `FEATURE_REQUEST*.md`, `BUG_REPORT*.md` — internal notes and drafts; - `/dist/` — old export zips. diff --git a/css/custom.css b/css/custom.css index 05ef886..d43b717 100644 --- a/css/custom.css +++ b/css/custom.css @@ -1,51 +1,48 @@ -/****************** - User custom CSS - --------------- - - 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{ - hyphens: none; +@charset "UTF-8"; +/* 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). */ +#outerframeContainer { + hyphens: none; } /* 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 { - padding: 1rem 0 1.5rem; - opacity: 0.75; + padding: 1rem 0 1.5rem; + opacity: 0.75; } /* row 207: logo height 25px (was max-height 18px) */ .respondage-theme-footer-logo { - height: 25px; - width: auto; - vertical-align: middle; + height: 25px; + width: auto; + vertical-align: middle; } /* row 214: untouched slider = grey handle + transparent selection; touched = - sliderhandlecolor (the .slider-handle rule in custom_header.twig). - The slider-is-untouched class is synced onto li.slider-item by - scripts/custom.js from the answer input's value — core's own - slider-untouched class on the .slider element is unreliable when - "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. */ + * sliderhandlecolor (the .slider-handle rule in custom_header.twig). + * The slider-is-untouched class is synced onto li.slider-item by + * scripts/custom.js from the answer input's value — core's own + * slider-untouched class on the .slider element is unreliable when + * "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. */ .slider-item.slider-is-untouched .slider-handle { - background-color: grey; + background-color: grey; } .slider-item.slider-is-untouched .slider-selection { - background: transparent; - box-shadow: none; + background: transparent; + box-shadow: none; } /* 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 - 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 - (and slider-is-untouched is removed anyway). */ + * (jQuery .hide()) when no default position is set; with slider_default_set + * 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 + * (and slider-is-untouched is removed anyway). */ .slider-item.slider-is-untouched .slider .tooltip { - display: none; -} \ No newline at end of file + display: none; +} + +/*# sourceMappingURL=custom.css.map */ diff --git a/css/fonts.css b/css/fonts.css index af4184a..b883504 100644 --- a/css/fonts.css +++ b/css/fonts.css @@ -1,115 +1,105 @@ -/* - * Bundled open source fonts for vanilla_respondage. - * - * 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/). - * Each font below is selectable in the theme options (Fonts category, optgroup - * "Bundled open source fonts" in config.xml). The class rules are GENERIC - * (.font-, not body-scoped) on purpose: the base font is applied as - * font- on , 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. - */ - +@charset "UTF-8"; +/* 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/). */ +/* Each font is selectable in the theme options (Fonts category, optgroup "Bundled open source fonts" in config.xml). The class rules are GENERIC (.font-, not body-scoped) on purpose: */ +/* the base font is applied as font- on , and per-element font overrides (fontselect options) apply the same class on individual elements. */ +/* 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 */ @font-face { - font-family: 'Inter'; - src: url('../files/fonts/inter-var.woff2') format('woff2'); - font-weight: 100 900; /* variable font: wght axis 100-900 */ - font-style: normal; - font-display: swap; + font-family: "Inter"; + src: url("../files/fonts/inter-var.woff2") format("woff2"); + /* variable font: wght axis 100-900 */ + font-weight: 100 900; + font-style: normal; + font-display: swap; } - /* Source Serif 4 — serif — https://github.com/adobe-fonts/source-serif — OFL 1.1 */ @font-face { - font-family: 'Source Serif 4'; - src: url('../files/fonts/source-serif-4-var.woff2') format('woff2'); - font-weight: 200 900; /* variable font: wght axis 200-900 */ - font-style: normal; - font-display: swap; + font-family: "Source Serif 4"; + src: url("../files/fonts/source-serif-4-var.woff2") format("woff2"); + /* variable font: wght axis 200-900 */ + font-weight: 200 900; + font-style: normal; + font-display: swap; } - /* EB Garamond — serif — https://open-foundry.com/fonts/eb-garamond — OFL 1.1 */ @font-face { - font-family: 'EB Garamond'; - src: url('../files/fonts/eb-garamond-var.woff2') format('woff2'); - font-weight: 400 800; /* variable font: wght axis 400-800 */ - font-style: normal; - font-display: swap; + font-family: "EB Garamond"; + src: url("../files/fonts/eb-garamond-var.woff2") format("woff2"); + /* variable font: wght axis 400-800 */ + font-weight: 400 800; + font-style: normal; + font-display: swap; } - /* 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-family: 'Liberation Sans'; - src: url('../files/fonts/liberation-sans-400.woff2') format('woff2'); - font-weight: 400; - font-style: normal; - font-display: swap; + font-family: "Liberation Sans"; + src: url("../files/fonts/liberation-sans-400.woff2") format("woff2"); + font-weight: 400; + font-style: normal; + font-display: swap; } @font-face { - font-family: 'Liberation Sans'; - src: url('../files/fonts/liberation-sans-700.woff2') format('woff2'); - font-weight: 700; - font-style: normal; - font-display: swap; + font-family: "Liberation Sans"; + src: url("../files/fonts/liberation-sans-700.woff2") format("woff2"); + font-weight: 700; + font-style: normal; + font-display: swap; } - /* Noto Sans — sans-serif — source: Google Fonts family "Noto Sans" — OFL 1.1 */ @font-face { - font-family: 'Noto Sans'; - 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) */ - font-style: normal; - font-display: swap; + font-family: "Noto Sans"; + src: url("../files/fonts/noto-sans-var.woff2") format("woff2"); + /* variable font: wght axis 100-900 (wdth stays at default 100) */ + font-weight: 100 900; + font-style: normal; + font-display: swap; } - /* Noto Serif — serif — source: Google Fonts family "Noto Serif" — OFL 1.1 */ @font-face { - font-family: 'Noto Serif'; - 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) */ - font-style: normal; - font-display: swap; + font-family: "Noto Serif"; + src: url("../files/fonts/noto-serif-var.woff2") format("woff2"); + /* variable font: wght axis 100-900 (wdth stays at default 100) */ + font-weight: 100 900; + font-style: normal; + font-display: swap; } - /* Open Sans — sans-serif — source: Google Fonts family "Open Sans" — OFL 1.1 */ @font-face { - font-family: 'Open Sans'; - 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) */ - font-style: normal; - font-display: swap; + font-family: "Open Sans"; + src: url("../files/fonts/open-sans-var.woff2") format("woff2"); + /* variable font: wght axis 300-800 (wdth stays at default 100) */ + font-weight: 300 800; + font-style: normal; + font-display: swap; } - .font-inter { - font-family: 'Inter', Arial, Helvetica, sans-serif; + font-family: "Inter", Arial, Helvetica, sans-serif; } .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-family: 'EB Garamond', Georgia, 'Times New Roman', serif; + font-family: "EB Garamond", Georgia, "Times New Roman", serif; } .font-liberation_sans { - font-family: 'Liberation Sans', Arial, Helvetica, sans-serif; + font-family: "Liberation Sans", Arial, Helvetica, sans-serif; } .font-noto_sans { - font-family: 'Noto Sans', Arial, Helvetica, sans-serif; + font-family: "Noto Sans", Arial, Helvetica, sans-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-family: 'Open Sans', Arial, Helvetica, sans-serif; + font-family: "Open Sans", Arial, Helvetica, sans-serif; } + +/*# sourceMappingURL=fonts.css.map */ diff --git a/variants/export_public.sh b/variants/export_public.sh index 5852e0e..51014bb 100644 --- a/variants/export_public.sh +++ b/variants/export_public.sh @@ -36,30 +36,66 @@ STAGE="$OUT_DIR/$MOTHER_NAME" VERSION="$(sed -n 's:.*\([^<]*\).*:\1:p' "$THEME_DIR/config.xml" | head -1)" ZIP_NAME="${MOTHER_NAME}-${VERSION}-public.zip" -# 0. optional guard: css/plain.css must be in sync with sass/plain.sass. -# LimeSurvey serves the committed css/plain.css and NEVER compiles sass +# 0. optional guard: SASS IS LEADING — every sass/*.sass must be compiled to +# its css/.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 -# compiler is on PATH AND the developer-local sass/ sources are present -# (sass/ is gitignored and NOT part of this repo), recompile to a temp -# file and compare; abort on drift. -if command -v sass >/dev/null 2>&1 && [ -f "$THEME_DIR/sass/plain.sass" ]; then - TMP_CSS="$(mktemp --suffix=.css)" - if sass --no-source-map "$THEME_DIR/sass/plain.sass" "$TMP_CSS" 2>/dev/null; then +# compiler is available (on PATH, or the local devDependency +# node_modules/.bin/sass) AND the developer-local sass/ sources are present +# (sass/ is gitignored and NOT part of this repo), recompile each top-level +# 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)" + 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 # sourceMappingURL comment); strip that comment line: it contains the # 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 - echo "ERROR: css/plain.css is stale relative to sass/plain.sass - aborting." >&2 - echo " Recompile in the theme dir, e.g.: sass sass/plain.sass css/plain.css" >&2 - echo " (a watcher like 'sass --watch sass/plain.sass css/plain.css' prevents this)" >&2 - echo " Commit the recompiled css/plain.css (the .map stays local, gitignored); sass/ is developer-local and not committed." >&2 - rm -f "$TMP_CSS" - exit 1 + if ! diff -qB <(sed '/sourceMappingURL/d' "$CSS") <(sed '/sourceMappingURL/d' "$TMP_CSS") >/dev/null 2>&1; then + echo "ERROR: css/$BASE.css is stale relative to sass/$BASE.sass - aborting." >&2 + echo " Recompile in the theme dir, e.g.: sass --watch sass:css (all sass/*.sass -> css/*.css)" >&2 + echo " or per file: sass sass/$BASE.sass css/$BASE.css" >&2 + echo " Commit the recompiled css/$BASE.css (the .map stays local, gitignored); sass/ is developer-local and not committed." >&2 + STALE=1 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 - 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 rm -rf "$STAGE"