Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-08-27 17:23:06 +0300
committerJoas Schilling <coding@schilljs.com>2018-08-27 17:23:06 +0300
commit84dbf919d1652ea45df17ed771f76ae6ea32bb08 (patch)
treeec6f53e96acf8b043ce85eeb3d4f7cb20b61ca8e /src/App.vue
parentf0abc6e877d0bb2574e52f3ecb12c3b2f1e6cc38 (diff)
Add a white icon for red based themes
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src/App.vue')
-rw-r--r--src/App.vue40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/App.vue b/src/App.vue
index 0eec298..6a5c108 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -47,8 +47,14 @@
computed: {
iconPath: function() {
var iconPath = 'notifications';
+ if (this.isRedThemed()) {
+ iconPath += '-red-new';
+ }
- if (/*this.backgroundFetching &&*/ this.notifications.length) {
+ if (this.notifications.length) {
+ if (this.isRedThemed()) {
+ iconPath += '-red';
+ }
iconPath += '-new';
}
@@ -79,6 +85,38 @@
return OCA.Theming && OCA.Theming.inverted;
},
+ isRedThemed: function() {
+ if (OCA.Theming && OCA.Theming.color) {
+ var hsl = this.rgbToHsl(OCA.Theming.color.substring(1, 3),
+ OCA.Theming.color.substring(3, 5),
+ OCA.Theming.color.substring(5, 7)),
+ h = hsl[0] * 360;
+ return (h >= 330 || h <= 15) && hsl[1] > 0.7 && (hsl[2] > 0.1 || hsl[2] < 0.6);
+ }
+ return false;
+ },
+
+ rgbToHsl: function (r, g, b) {
+ r = parseInt(r, 16) / 255; g = parseInt(g, 16) / 255; b = parseInt(b, 16) / 255;
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
+ var h, s, l = (max + min) / 2;
+
+ if (max === min) {
+ h = s = 0;
+ } else {
+ var d = max - min;
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
+ switch (max) {
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
+ case g: h = (b - r) / d + 2; break;
+ case b: h = (r - g) / d + 4; break;
+ }
+ h /= 6;
+ }
+
+ return [h, s, l];
+ },
+
/**
* Performs the AJAX request to retrieve the notifications
*/