From ed86f03a9f7c2f58a9111f925bb81303596b394b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 7 Nov 2021 11:04:52 +0100 Subject: luci-theme-bootstrap: add explicit dark/light mode selection Register two further "virtual" themes called BootstrapDark and BootstrapLight which force dark and light mode respectively. The actual Bootstrap theme itself will continue to auto-select dark mode preference based on OS/Browser preference settings. Fixes: #5492 Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/themes/bootstrap-dark | 1 + .../luasrc/view/themes/bootstrap-light | 1 + .../luasrc/view/themes/bootstrap/header.htm | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 120000 themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark create mode 120000 themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light (limited to 'themes/luci-theme-bootstrap/luasrc/view') diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark new file mode 120000 index 0000000000..ac7bcbbf37 --- /dev/null +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-dark @@ -0,0 +1 @@ +bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light new file mode 120000 index 0000000000..ac7bcbbf37 --- /dev/null +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap-light @@ -0,0 +1 @@ +bootstrap \ No newline at end of file diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm index 6e4861fe0b..a3f28fd709 100644 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm @@ -15,14 +15,32 @@ local node = disp.context.dispatched + local darkpref + + if theme == "bootstrap-dark" then + darkpref = "true" + elseif theme == "bootstrap-light" then + darkpref = "false" + end + -- send as HTML5 http.prepare_content("text/html") -%> - +> <%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI + <% if darkpref == nil then %> + + <% end %> -- cgit v1.2.3