From d4d4f16dfdbad387480a0cba9c808bdd50dc4d3c Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Wed, 14 Oct 2026 23:03:24 -0500 Subject: [PATCH] feat(ui): add a light and dark theme toggle to the landing page (#5695) * feat(ui): add a light and dark theme toggle to the landing page The landing page was dark only. A button in the top bar, shown on the dashboard and on the /_floci/ui wait view, switches between a dark and a light theme. With no choice made the page follows the OS colour scheme, including a change while it is open; a choice is remembered in localStorage under floci.theme, next to the news setting, and the page still switches for the current view when storage is blocked. The theme is set by the head script before the stylesheet paints, so a light page does not flash dark on load. The dark palette is unchanged. The light one keeps the same accent family with every text colour at 4.5:1 or better against the page backgrounds, and the five colours that were written as literals (logo dot, button text, code snippets, error box, the copied border) are now variables both themes set. Signed-off-by: Hector Ventura * feat(ui): name the emulator in the top bar and keep a page-view theme choice The page will be shared by the other Floci emulators, so the top bar now says which one serves it, floci-aws, next to the logo, and the page title and the version pill's tooltip name it too. A theme picked with the toggle while storage is blocked could be undone by an OS colour-scheme change later in the same page view, because the OS listener only checked the stored choice. The click is now remembered in memory as well, so the OS is followed only until the user picks. Signed-off-by: Hector Ventura * chore(ui): pin the floci-ui console image to 0.7.0 The console image defaulted to floci/floci-ui:latest, and a cached latest tag is never pulled again, so a machine kept whatever console it first downloaded. The default is now the released 0.7.0 tag, in the config default, application.yml and the three docs tables that list it. FLOCI_SERVICES_UI_IMAGE still overrides it. Signed-off-by: Hector Ventura --------- Signed-off-by: Hector Ventura --- README.md | 2 +- docs/configuration/environment-variables.md | 2 +- docs/ui/index.md | 4 +- .../floci/config/EmulatorConfig.java | 2 +- src/main/resources/application.yml | 2 +- src/main/resources/ui/index.html | 93 +++++++++++++++++-- 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8d085798a5..c92bcca424 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ services: | Variable | Default | Description | |---|---|---| | `FLOCI_SERVICES_UI_ENABLED` | `true` | Enable the console sidecar | -| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:latest` | Console image to run | +| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:0.7.0` | Console image to run | | `FLOCI_SERVICES_UI_CONTAINER_NAME` | `floci-ui` | Name of the sidecar container | | `FLOCI_SERVICES_UI_PORT` | `4500` | Host port the console is published on | | `FLOCI_SERVICES_UI_BIND_ADDRESS` | _(none)_ | Host interface that port is published on. Unset publishes on every interface; set `127.0.0.1` when Floci's own port is loopback-only | diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md index 3ddf6ecbff..f505ce8b0c 100644 --- a/docs/configuration/environment-variables.md +++ b/docs/configuration/environment-variables.md @@ -556,7 +556,7 @@ Floci starts the web console as a sidecar container the first time `/_floci/ui` | Variable | Default | Description | |---|---|---| | `FLOCI_SERVICES_UI_ENABLED` | `true` | Enable the web console sidecar | -| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:latest` | Console image to run | +| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:0.7.0` | Console image to run | | `FLOCI_SERVICES_UI_CONTAINER_NAME` | `floci-ui` | Name of the sidecar container | | `FLOCI_SERVICES_UI_PORT` | `4500` | Host port the console is published on | | `FLOCI_SERVICES_UI_BIND_ADDRESS` | _(none)_ | Host interface that port is published on. Unset publishes on every interface; set `127.0.0.1` when Floci's own port is loopback-only | diff --git a/docs/ui/index.md b/docs/ui/index.md index 724408e44d..e52e5cb93e 100644 --- a/docs/ui/index.md +++ b/docs/ui/index.md @@ -49,7 +49,7 @@ All keys live under `floci.services.ui.*`, so `FLOCI_SERVICES_UI_*` as environme | Variable | Default | Description | |---|---|---| | `FLOCI_SERVICES_UI_ENABLED` | `true` | Enable the console sidecar | -| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:latest` | Console image to run | +| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:0.7.0` | Console image to run | | `FLOCI_SERVICES_UI_CONTAINER_NAME` | `floci-ui` | Name of the sidecar container | | `FLOCI_SERVICES_UI_PORT` | `4500` | Host port the console is published on | | `FLOCI_SERVICES_UI_BIND_ADDRESS` | _(none)_ | Host interface that port is published on (see [Ports](#ports)) | @@ -156,7 +156,7 @@ previous run that it is pointing at a dead address. !!! note "The page says the image is unavailable" Floci could not pull the console image. Pull it yourself to see the real error: - `docker pull floci/floci-ui:latest`. + `docker pull floci/floci-ui:0.7.0`. !!! note "The page says Floci could not reach the container runtime" diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java index a24a3d8e91..bffbbec3df 100644 --- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java +++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java @@ -2590,7 +2590,7 @@ public interface EmulatorConfig { @WithDefault("true") boolean enabled(); - @WithDefault("floci/floci-ui:latest") + @WithDefault("floci/floci-ui:0.7.0") String image(); @WithDefault("floci-ui") diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f3494caa54..85e8a6d774 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -684,7 +684,7 @@ floci: prefer-local-images: true ui: enabled: true - image: "floci/floci-ui:latest" + image: "floci/floci-ui:0.7.0" container-name: floci-ui port: 4500 # bind-address: unset by default, so Docker publishes the console on every interface. diff --git a/src/main/resources/ui/index.html b/src/main/resources/ui/index.html index 98f8d486ef..a49b5930ae 100644 --- a/src/main/resources/ui/index.html +++ b/src/main/resources/ui/index.html @@ -3,11 +3,19 @@ - Floci: local AWS emulator + floci-aws: local AWS emulator @@ -31,11 +39,39 @@ --green: #22c55e; --amber: #e0b341; --red: #f87171; + --green-soft: rgba(34,197,94,.45); + --logo-dot: #7A7FD6; + --on-accent: #fff; + --code-text: #CFD3F5; + --error-text: #F5C2C2; --radius: 8px; --pad: 28px; --sans: "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace; } + :root[data-theme="light"] { + color-scheme: light; + --bg: #F7F8FB; + --bg2: #EDEFF5; + --bg3: #FFFFFF; + --border: #E1E5EE; + --border-bright: #C5CCDA; + --text: #0F172A; + --text-body: #334155; + --text-muted: #556070; + --text-dim: #5E6978; + --accent: #4C52B5; + --accent-deep: #4C52B5; + --accent-mid: #5A60C6; + --accent-dim: rgba(85,89,167,.12); + --green: #15803D; + --amber: #A16207; + --red: #DC2626; + --green-soft: rgba(21,128,61,.45); + --logo-dot: #5A60C6; + --code-text: #2E3470; + --error-text: #B42318; + } * { box-sizing: border-box; } html, body { height: 100%; } body { @@ -60,7 +96,7 @@ } .floci-logo { height: 30px; width: auto; display: block; } .floci-text, .floci-cloud { fill: var(--text); } - .floci-dot { fill: #7A7FD6; } + .floci-dot { fill: var(--logo-dot); } .status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); } .status .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-dim); } .status.ready .dot { background: var(--green); } @@ -76,11 +112,12 @@ font-family: var(--mono); font-size: 12px; color: var(--text); } .build:empty { display: none; } + .emulator { font-family: var(--mono); font-size: 12.5px; color: var(--text-muted); } .top-end { margin-left: auto; display: flex; align-items: center; gap: 20px; } .btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent; - background: var(--accent-deep); color: #fff; font-weight: 600; font-size: 13.5px; + background: var(--accent-deep); color: var(--on-accent); font-weight: 600; font-size: 13.5px; transition: background .15s ease, transform .16s ease; } .btn:hover { background: var(--accent-mid); text-decoration: none; } @@ -89,6 +126,15 @@ background: transparent; border-color: var(--border-bright); color: var(--text); font-weight: 500; } .btn-quiet:hover { background: var(--bg2); } + .theme-toggle { + display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; + border-radius: var(--radius); border: 1px solid var(--border-bright); background: transparent; + color: var(--text-muted); transition: color .15s ease, background .15s ease; + } + .theme-toggle:hover { color: var(--text); background: var(--bg2); } + .theme-toggle svg { width: 16px; height: 16px; display: block; } + [data-theme="light"] .theme-toggle .icon-sun, + [data-theme="dark"] .theme-toggle .icon-moon { display: none; } /* ── Layout ──────────────────────────────────────────── */ .layout { flex: 1; display: grid; grid-template-columns: 1fr; } @@ -136,7 +182,7 @@ transition: color .15s ease, border-color .15s ease; } .copy:hover { color: var(--text); border-color: var(--text-dim); } - .copy.done { color: var(--green); border-color: rgba(34,197,94,.45); } + .copy.done { color: var(--green); border-color: var(--green-soft); } .tabs { display: flex; gap: 18px; margin-top: 22px; border-bottom: 1px solid var(--border); } .tab { @@ -150,7 +196,7 @@ .snippet pre { margin: 0; padding: 14px 14px 16px; border-radius: var(--radius); background: var(--bg3); border: 1px solid var(--border); overflow-x: auto; - font-family: var(--mono); font-size: 12px; line-height: 1.7; color: #CFD3F5; + font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--code-text); } .stages { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; } @@ -246,7 +292,7 @@ .error { margin: 20px 0 0; padding: 14px; border-radius: var(--radius); background: var(--bg3); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; - font-family: var(--mono); font-size: 12px; line-height: 1.7; color: #F5C2C2; + font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--error-text); } .actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; } @@ -280,11 +326,17 @@ + + floci-aws Connecting… - + @@ -610,6 +662,33 @@ .finally(function () { refreshing = false; }); } + // ── Theme (follows the OS until the user picks one) ── + var THEME_KEY = "floci.theme"; + var themeButton = $("theme-toggle"); + var themeChosen = false; // a click this page view, which wins over the OS even when storage is blocked + function storedTheme() { + try { var t = localStorage.getItem(THEME_KEY); return t === "light" || t === "dark" ? t : null; } + catch (e) { return null; /* storage blocked: the choice lasts for this page view */ } + } + function applyTheme(theme) { + document.documentElement.dataset.theme = theme; + var label = theme === "dark" ? "Switch to light theme" : "Switch to dark theme"; + themeButton.setAttribute("aria-label", label); + themeButton.title = label; + } + applyTheme(document.documentElement.dataset.theme === "light" ? "light" : "dark"); + themeButton.addEventListener("click", function () { + var next = document.documentElement.dataset.theme === "light" ? "dark" : "light"; + themeChosen = true; + applyTheme(next); + try { localStorage.setItem(THEME_KEY, next); } catch (e) { /* storage blocked: lasts for this page view */ } + }); + if (window.matchMedia) { + var osLight = matchMedia("(prefers-color-scheme: light)"); + var onOsChange = function (event) { if (!themeChosen && !storedTheme()) { applyTheme(event.matches ? "light" : "dark"); } }; + if (osLight.addEventListener) { osLight.addEventListener("change", onOsChange); } else if (osLight.addListener) { osLight.addListener(onOsChange); } + } + // ── News (off until the user turns it on) ──────────── var newsItems = null; var newsHost = NEWS_URL.replace(/^https?:\/\//, "").split("/")[0];