Add colors to kanban

pull/1/head
yflory 5 years ago
parent 8c342862e7
commit c220a7ecf4

@ -15,6 +15,7 @@
max-height: 100%; max-height: 100%;
min-height: auto; min-height: auto;
@palette0: #888; // Default bg color for header
@palette1: #FFD4D4; @palette1: #FFD4D4;
@palette2: #FFDECA; @palette2: #FFDECA;
@palette3: #FFE69C; @palette3: #FFE69C;
@ -24,7 +25,13 @@
@palette7: #C8D6FF; @palette7: #C8D6FF;
@palette8: #E4CAFF; @palette8: #E4CAFF;
.kanban-board-header {
background-color: '#888';
}
.cp-kanban-palette-nocolor {
background-color: @palette0;
}
.cp-kanban-palette-color1 { .cp-kanban-palette-color1 {
background-color: @palette1; background-color: @palette1;
} }

@ -57,8 +57,6 @@ define([
Messages.kanban_delete = "Delete"; // XXX Messages.kanban_delete = "Delete"; // XXX
// XXX // XXX
// Fix remote board deletion not applied to local UI
// Add colors...
// Add "large" view // Add "large" view
var setValueAndCursor = function (input, val, _cursor) { var setValueAndCursor = function (input, val, _cursor) {
@ -386,19 +384,16 @@ define([
"11": { "11": {
"id": 11, "id": 11,
"title": Messages.kanban_todo, "title": Messages.kanban_todo,
"color": "blue",
"item": [1, 2] "item": [1, 2]
}, },
"12": { "12": {
"id": 12, "id": 12,
"title": Messages.kanban_working, "title": Messages.kanban_working,
"color": "orange",
"item": [3, 4] "item": [3, 4]
}, },
"13": { "13": {
"id": 13, "id": 13,
"title": Messages.kanban_done, "title": Messages.kanban_done,
"color": "green",
"item": [5, 6] "item": [5, 6]
} }
}, },

@ -304,10 +304,33 @@
} }
}; };
var getTextColor = function (hex) {
if (!/^[0-9a-f]{6}$/.test(hex)) {
return '#000000';
}
var r = parseInt(hex.slice(0,2), 16);
var g = parseInt(hex.slice(2,4), 16);
var b = parseInt(hex.slice(4,6), 16);
if ((r*0.299 + g*0.587 + b*0.114) > 186) {
return '#000000';
}
return '#FFFFFF';
};
var getElementNode = function (element) { var getElementNode = function (element) {
var nodeItem = document.createElement('div'); var nodeItem = document.createElement('div');
nodeItem.classList.add('kanban-item'); nodeItem.classList.add('kanban-item');
nodeItem.dataset.eid = element.id; nodeItem.dataset.eid = element.id;
if (element.color) {
if (/color/.test(element.color)) {
// Palette color
nodeItem.classList.add('cp-kanban-palette-'+element.color);
} else {
// Hex color code
var textColor = getTextColor(element.color);
nodeItem.setAttribute('style', 'background-color:#'+element.color+';color:'+textColor+';');
}
}
var nodeItemText = document.createElement('div'); var nodeItemText = document.createElement('div');
nodeItemText.classList.add('kanban-item-text'); nodeItemText.classList.add('kanban-item-text');
nodeItemText.dataset.eid = element.id; nodeItemText.dataset.eid = element.id;
@ -372,8 +395,17 @@
headerBoard.classList.add(value); headerBoard.classList.add(value);
}); });
if (board.color !== '' && board.color !== undefined) { if (board.color !== '' && board.color !== undefined) {
// XXX color if (/color/.test(board.color)) {
headerBoard.classList.add("kanban-header-" + board.color); // Palette color
headerBoard.classList.add('cp-kanban-palette-'+board.color);
} else if (!/^[0-9a-f]{6}$/.test(board.color)) {
// "string" color (red, blue, etc.)
headerBoard.classList.add("kanban-header-" + board.color);
} else {
// Hex color code
var textColor = getTextColor(board.color);
headerBoard.setAttribute('style', 'background-color:#'+board.color+';color:'+textColor+';');
}
} }
titleBoard = document.createElement('div'); titleBoard = document.createElement('div');
titleBoard.classList.add('kanban-title-board'); titleBoard.classList.add('kanban-title-board');

Loading…
Cancel
Save