summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-11-11 12:39:41 +0100
committerJo-Philipp Wich <jo@mein.io>2021-11-11 13:00:50 +0100
commitd775279dbd0da284af7f74b31b5d3b0eddcf80bc (patch)
tree1c58b65cd63005630b853ac19235413816955217 /modules/luci-base
parent5b3fa3cdc7530887898f5dc38d6dd15b88c66b5f (diff)
luci-base: firewall.js: add getZoneColorStyle() helper
The getZoneColorStyle() function will produce CSS style properties that describe the color value of the zone. The color declaration is divided into a CSS variable called `--zone-color-rgb` which holds the RGB value of the color and a `background-color` property assigning these values as background property. This allows themes to override the color with derived values, e.g. by applying an alpha channel. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/firewall.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/firewall.js b/modules/luci-base/htdocs/luci-static/resources/firewall.js
index 4fa4954ba6..a682af46d0 100644
--- a/modules/luci-base/htdocs/luci-static/resources/firewall.js
+++ b/modules/luci-base/htdocs/luci-static/resources/firewall.js
@@ -224,7 +224,17 @@ Firewall = L.Class.extend({
}, this));
},
- getColorForName: getColorForName
+ getColorForName: getColorForName,
+
+ getZoneColorStyle: function(zone) {
+ var hex = (zone instanceof Zone) ? zone.getColor() : getColorForName((zone != null && zone != '*') ? zone : null);
+
+ return '--zone-color-rgb:%d, %d, %d; background-color:rgb(var(--zone-color-rgb))'.format(
+ parseInt(hex.substring(1, 3), 16),
+ parseInt(hex.substring(3, 5), 16),
+ parseInt(hex.substring(5, 7), 16)
+ );
+ },
});