From 37c8aaa8edd099d00b1bef6c71821c42c6a77f6d Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 20 Sep 2024 17:13:19 +0300 Subject: [PATCH] WIP - bit of dark theme polishing --- pkg/shell/base_index.js | 11 ----------- pkg/shell/frames.jsx | 7 +++---- pkg/shell/shell.jsx | 3 +++ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pkg/shell/base_index.js b/pkg/shell/base_index.js index 4df61cfc88b..51f0ed0bae9 100644 --- a/pkg/shell/base_index.js +++ b/pkg/shell/base_index.js @@ -186,17 +186,6 @@ function Frames(index, setupIdleResetTimers) { self.frame_array[idx] = frame; else self.frame_array.push(frame); - - const style = localStorage.getItem('shell:style') || 'auto'; - let dark_mode; - // If a user set's an explicit theme, ignore system changes. - if ((window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && style === "auto") || style === "dark") { - dark_mode = true; - } else { - dark_mode = false; - } - - frame.dark_mode = dark_mode; } return frame; }; diff --git a/pkg/shell/frames.jsx b/pkg/shell/frames.jsx index bd567895239..f21455ee4d9 100644 --- a/pkg/shell/frames.jsx +++ b/pkg/shell/frames.jsx @@ -197,8 +197,8 @@ export const Frames = ({ state, current_frame }) => { poll_frame_ready(state, frame, iframe); // XXX - doesn't work (or is not enough), document has - // zero hight. Make content-area dark? - if (iframe.contentDocument.documentElement) { + // zero height. Make content-area dark? + if (!iframes_by_name[name] && iframe.contentDocument.documentElement) { const style = localStorage.getItem('shell:style') || 'auto'; if ((window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches @@ -210,8 +210,7 @@ export const Frames = ({ state, current_frame }) => { } else { iframe.contentDocument.documentElement.style.background = 'white'; } - } else - console.log("No doc?"); + } } }); diff --git a/pkg/shell/shell.jsx b/pkg/shell/shell.jsx index d1f65715407..7c9d87a6b3c 100644 --- a/pkg/shell/shell.jsx +++ b/pkg/shell/shell.jsx @@ -63,6 +63,9 @@ const _ = cockpit.gettext; /* Don't render into . */ +/* Move theme state into ShellState, have a setter for it. + */ + function trigger_connection_flow(machine) { console.log("TRIGGER"); if (window.trigger_connection_flow) {