Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a white icon for red based themes
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Aug 27, 2018
commit 84dbf919d1652ea45df17ed771f76ae6ea32bb08
1 change: 1 addition & 0 deletions img/notifications-red-new-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions img/notifications-red-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/notifications.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/notifications.js.map

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@
computed: {
iconPath: function() {
var iconPath = 'notifications';
if (this.isRedThemed()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to add a duplicate string together with the if statement below, as it produces /apps/notifications/img/notifications-red-new-red-new.svg which is not found

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, that was my test code

iconPath += '-red-new';
}

if (/*this.backgroundFetching &&*/ this.notifications.length) {
if (this.notifications.length) {
if (this.isRedThemed()) {
iconPath += '-red';
}
iconPath += '-new';
}

Expand Down Expand Up @@ -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
*/
Expand Down