[pbs-devel] [PATCH proxmox-backup] ui: dark mode: add dark mode colors to the datastore usage charts
Dominik Csapak
d.csapak at proxmox.com
Tue Mar 28 15:11:48 CEST 2023
for the `Datastore -> Summary` overview.
Signed-off-by: Dominik Csapak <d.csapak at 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
More information about the pbs-devel
mailing list