thubrecht/inutile (#19)
Co-authored-by: Tom Hubrecht <tom.hubrecht@ens.fr> Reviewed-on: https://git.rz.ens.wtf/Klub-RZ/metis/pulls/19 Co-authored-by: tomate <tom.hubrecht@ens.fr> Co-committed-by: tomate <tom.hubrecht@ens.fr>
This commit is contained in:
parent
6f9a84fed6
commit
183d0df233
2 changed files with 31 additions and 2 deletions
|
@ -18,7 +18,10 @@
|
||||||
<Modal isOpen={open} {toggle} centered scrollable>
|
<Modal isOpen={open} {toggle} centered scrollable>
|
||||||
<ModalHeader {toggle}>
|
<ModalHeader {toggle}>
|
||||||
<span class="pe-3">
|
<span class="pe-3">
|
||||||
<Badge color="custom" style="background-color:{event.backgroundColor}">
|
<Badge
|
||||||
|
color="custom"
|
||||||
|
style="background-color:{event.backgroundColor}; color:{event.textColor}"
|
||||||
|
>
|
||||||
{event.extendedProps.calendar}
|
{event.extendedProps.calendar}
|
||||||
</Badge>
|
</Badge>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
// https://stackoverflow.com/a/35970186
|
||||||
|
function invertColor(hex) {
|
||||||
|
if (hex.indexOf('#') === 0) {
|
||||||
|
hex = hex.slice(1)
|
||||||
|
}
|
||||||
|
// convert 3-digit hex to 6-digits.
|
||||||
|
if (hex.length === 3) {
|
||||||
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
|
||||||
|
}
|
||||||
|
if (hex.length !== 6) {
|
||||||
|
throw new Error('Invalid HEX color.')
|
||||||
|
}
|
||||||
|
var r = parseInt(hex.slice(0, 2), 16),
|
||||||
|
g = parseInt(hex.slice(2, 4), 16),
|
||||||
|
b = parseInt(hex.slice(4, 6), 16)
|
||||||
|
// https://stackoverflow.com/a/3943023/112731
|
||||||
|
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF'
|
||||||
|
}
|
||||||
|
|
||||||
const clouds = {
|
const clouds = {
|
||||||
KLUB_RESEAU: 'klub-reseau',
|
KLUB_RESEAU: 'klub-reseau',
|
||||||
ELEVES_ENS: 'eleves-ens',
|
ELEVES_ENS: 'eleves-ens',
|
||||||
|
@ -43,6 +62,12 @@ const calendars = {
|
||||||
cloud: clouds.FRAMA_AGENDA,
|
cloud: clouds.FRAMA_AGENDA,
|
||||||
name: 'CinéClub',
|
name: 'CinéClub',
|
||||||
color: null
|
color: null
|
||||||
|
},
|
||||||
|
'6SHG6cg9d7S3qqwD': {
|
||||||
|
cloud: clouds.ELEVES_ENS,
|
||||||
|
name: 'Club Inutile ☔',
|
||||||
|
color: null,
|
||||||
|
initial: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +88,7 @@ export const calendarTree = {
|
||||||
"Écriv'ENS": {},
|
"Écriv'ENS": {},
|
||||||
CinéClub: {},
|
CinéClub: {},
|
||||||
Ernestophone: {},
|
Ernestophone: {},
|
||||||
'Club inutile': {}
|
'Club Inutile ☔': {}
|
||||||
},
|
},
|
||||||
COF: {
|
COF: {
|
||||||
BDA: {},
|
BDA: {},
|
||||||
|
@ -140,6 +165,7 @@ function fcEventFromjCalEvent(cal) {
|
||||||
start: evt.dtstart,
|
start: evt.dtstart,
|
||||||
end: evt.dtend,
|
end: evt.dtend,
|
||||||
color: cal.color,
|
color: cal.color,
|
||||||
|
textColor: invertColor(cal.color),
|
||||||
duration: end - start // in ms
|
duration: end - start // in ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue