* [pbs-devel] [PATCH proxmox-backup] ui: dark mode: add dark mode colors to the datastore usage charts
@ 2023-03-28 13:11 Dominik Csapak
2023-03-28 13:25 ` [pbs-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2023-03-28 13:11 UTC (permalink / raw)
To: pbs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-28 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 13:11 [pbs-devel] [PATCH proxmox-backup] ui: dark mode: add dark mode colors to the datastore usage charts Dominik Csapak
2023-03-28 13:25 ` [pbs-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox