Repository navigation
Conversation
frontend/styling/theme.css ships empty and is loaded after index.css on the modern page, so a host can override the CSS variables of colors.css, the background and the logo without touching the files of the project. There is no switch for the visitors. The README documents the variables, what a theme cannot reach, and the Docker paths: the entrypoint empties /var/www/html and copies /speedtest/frontend at every start, so a theme is mounted (or copied) into /speedtest/frontend. Follows the suggestion in librespeed#863 of a static style for hosts, kept apart from the localization.
PR Summary by QodoAdd host-controlled CSS theming for the modern design
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1.
|
Branding of the modern design for hosts
Follow-up to the suggestion of @sstidl in #863: a customization tool for people who host a frontend, as a static style
baked into the container or the frontend directory, with no switch for the visitors, and kept apart from the
localization (#873).
What it does
frontend/styling/theme.cssis new, ships empty (only a comment) and is loaded afterindex.csson the modernpage (
index-modern.htmlandfrontend/index.html). The default look does not change.styling/colors.css, and can set its own background imageand logo, by replacing or mounting that file. No JavaScript, no storage, no new setting.
frontend/README.md(section "Theming") lists the variables, how to change the background and the logo, and what atheme cannot reach: the colors inside the SVG files, the
theme-colorof the page and of the manifest, and the imagemade for sharing a result. It also notes that two variables of
colors.css(--gauge-progress-colorand--popup-shadow-color) are declared but not used, so changing them has no effect.doc_docker.mdexplains the Docker paths.Docker
The entrypoint empties
/var/www/htmland copies/speedtest/frontendinto it at every start. A theme therefore hasto be mounted at
/speedtest/frontend/styling/theme.css(or copied there in a derived image), not at/var/www/html/frontend/...: mounting there makes the start fail (rm: can't remove ...: Resource busy, withset -e), and the copy would overwrite it anyway. The modern design is served only withUSE_NEW_DESIGN=true, and achange to a mounted file needs a restart.
docker run -d -p 80:8080 -e MODE=standalone -e USE_NEW_DESIGN=true \ -v $PWD/theme.css:/speedtest/frontend/styling/theme.css:ro \ ghcr.io/librespeed/speedtestScope, on purpose
Only the modern design. The classic page and the stability page have their own styles. No environment variables
(
THEME_*): they would need asedin the entrypoint, and a mounted file or aCOPYin a derived image alreadycovers "baked into the container or the frontend dir".
@sstidl, is a theme file that the host mounts or copies in a derived image what you had in mind, or would you rather
have a few ready-made themes picked by an environment variable?
Tests
tests/e2e/theme.spec.js: the shipped file is empty and keeps the default look; a host theme changes the accent colorand the background; a relative
url()intheme.cssis relative to the file; both modern pages load it afterindex.css; and a theme mounted in the Docker image (standalone-apostropheservice, one volume and a fixture) is theone that is served. The existing
title-special-chars,modes,design-switch,static-repository-assetsandmobile-gauge-visibilityspecs pass with the Docker setup (23 tests).