From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] ui: dark mode: add dark mode colors to the datastore usage charts
Date: Tue, 28 Mar 2023 15:11:48 +0200 [thread overview]
Message-ID: <20230328131148.3452447-1-d.csapak@proxmox.com> (raw)
for the `Datastore -> Summary` overview.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/panel/UsageChart.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/www/panel/UsageChart.js b/www/panel/UsageChart.js
index ea5c016e..3ac07efb 100644
--- a/www/panel/UsageChart.js
+++ b/www/panel/UsageChart.js
@@ -101,6 +101,27 @@ Ext.define('PBS.widget.UsageChart', {
me.getComponent('title').update({ title: title });
},
+ checkThemeColors: function() {
+ let me = this;
+ let rootStyle = getComputedStyle(document.documentElement);
+
+ // get color
+ let background = rootStyle.getPropertyValue("--pwt-panel-background").trim() || "#ffffff";
+ let text = rootStyle.getPropertyValue("--pwt-text-color").trim() || "#000000";
+ let gridStroke = rootStyle.getPropertyValue("--pwt-chart-grid-stroke").trim() || "#dddddd";
+
+ // set the colors
+ me.chart.setBackground(background);
+ if (!me.color) {
+ me.chart.axes.forEach((axis) => {
+ axis.setLabel({ color: text });
+ axis.setTitle({ color: text });
+ axis.setStyle({ strokeStyle: gridStroke });
+ });
+ }
+ me.chart.redraw();
+ },
+
initComponent: function() {
var me = this;
me.callParent();
@@ -116,5 +137,12 @@ Ext.define('PBS.widget.UsageChart', {
stroke: me.color,
});
}
+
+ me.checkThemeColors();
+
+ // switch colors on media query changes
+ me.mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
+ me.themeListener = (e) => { me.checkThemeColors(); };
+ me.mediaQueryList.addEventListener("change", me.themeListener);
},
});
--
2.30.2
next reply other threads:[~2023-03-28 13:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 13:11 Dominik Csapak [this message]
2023-03-28 13:25 ` [pbs-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328131148.3452447-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox