Skip to content

Commit 634f82d

Browse files
committed
Added colors (without offset for calendar)
1 parent 8556b83 commit 634f82d

File tree

5 files changed

+110
-28
lines changed

5 files changed

+110
-28
lines changed

client/event.components.json

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
{
22
"default": {
3-
"accentColor": { "h":0, "s":0, "l": 50 },
4-
"index": { "path": "./default/index.vue"},
5-
"create":{ "path": "./default/create.vue"},
6-
"update":{ "path": "./default/update.vue"},
7-
"delete":{ "path": "./default/delete.vue"}
3+
"accentColor": {
4+
"h": 0,
5+
"s": 0,
6+
"l": 0
7+
},
8+
"index": {
9+
"path": "./default/index.vue"
10+
},
11+
"create": {
12+
"path": "./default/create.vue"
13+
},
14+
"update": {
15+
"path": "./default/update.vue"
16+
},
17+
"delete": {
18+
"path": "./default/delete.vue"
19+
}
820
},
921
"notification": {
10-
"accentColor": { "h":25, "s":50, "l": 50 }
22+
"accentColor": {
23+
"h": 227,
24+
"s": 50,
25+
"l": 30
26+
}
1127
},
1228
"anniversary": {
13-
"accentColor": { "h":50, "s":50, "l": 50 }
29+
"accentColor": {
30+
"h": 128,
31+
"s": 50,
32+
"l": 30
33+
}
1434
},
1535
"task": {
16-
"accentColor": { "h":75, "s":50, "l": 50 }
36+
"accentColor": {
37+
"h": 0,
38+
"s": 73,
39+
"l": 30
40+
}
1741
}
1842
}

client/src/components/Main.vue

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<legend @click="showOrHideAllTypes()">Types</legend>
77
<ul>
88
<li v-for="type in types" :key="type.id">
9-
<label>
9+
<label :style="styleObj(type.name)" class="type">
1010
<input
1111
type="checkbox"
1212
:value="type.id"
@@ -21,8 +21,12 @@
2121
<fieldset>
2222
<legend @click="showOrHideAllCalendars()">Calendars</legend>
2323
<ul>
24-
<li v-for="calendar in calendars" :key="calendar.id">
25-
<label>
24+
<li
25+
v-for="calendar in calendars"
26+
:key="calendar.id"
27+
:style="styleObj(getType(calendar.typeId).name)"
28+
>
29+
<label class="calendar">
2630
<input
2731
type="checkbox"
2832
:value="calendar.id"
@@ -49,6 +53,7 @@ import toolbar from "../components/toolbar.vue";
4953
import feed from "../components/feed.vue";
5054
import badge from "../components/ui/badge";
5155
import Badge from "./ui/badge.vue";
56+
import events from "../components/events/fabric.js";
5257
5358
export default {
5459
components: {
@@ -100,6 +105,20 @@ export default {
100105
isDisplayed: this.selectedCalendarIds.includes(ev.calendarId),
101106
};
102107
},
108+
color(typeName) {
109+
return events.typeColorHSL(typeName.toLowerCase(), 0);
110+
},
111+
styleObj(typeName) {
112+
const color = this.color(typeName);
113+
return {
114+
"--color-h": color.h,
115+
"--color-s": color.s + "%",
116+
"--color-l": color.l + "%",
117+
};
118+
},
119+
getType(id) {
120+
return this.types.find((x) => x.id == id);
121+
},
103122
},
104123
created() {
105124
this.$store.commit("initialize");
@@ -162,4 +181,14 @@ export default {
162181
overflow: auto;
163182
height: 100%;
164183
}
184+
#main label.type,#main label.calendar {
185+
--hsl: var(--color-h), var(--color-s), var(--color-l);
186+
}
187+
#main label.type span, #main label.calendar span {
188+
text-shadow: hsla(var(--hsl), 0.4) 0px 0px 1px,
189+
hsla(var(--hsl), 0.4) 0px 0px 1px;
190+
}
191+
#main label.type sup, #main label.calendar sup {
192+
color: hsl(var(--hsl));
193+
}
165194
</style>

client/src/components/calendar.event.vue

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
2-
<component :is="view" :event="event" @click.native="eventClick(event.id)" :id="`event-${event.id}`"></component>
2+
<component
3+
:is="view"
4+
:event="event"
5+
@click.native="eventClick(event.id)"
6+
:id="`event-${event.id}`"
7+
:style="styleObj"
8+
></component>
39
</template>
410

511
<script>
@@ -15,18 +21,28 @@ export default {
1521
},
1622
data() {
1723
return {
18-
currentView: 'index'
24+
currentView: "index",
1925
};
2026
},
2127
computed: {
22-
view() {
23-
return events.is(this.event.$type, this.currentView);
24-
}
28+
view() {
29+
return events.is(this.event.$type, this.currentView);
30+
},
31+
color() {
32+
return events.typeColorHSL(this.event.$type, 0);
33+
},
34+
styleObj() {
35+
return {
36+
"--color-h": this.color.h,
37+
"--color-s": this.color.s+'%',
38+
"--color-l": this.color.l+'%'
39+
};
40+
},
2541
},
2642
methods: {
2743
eventClick(id) {
28-
const path = `/events/${id}`;
29-
if (this.$route.path !== path) this.$router.push(path)
44+
const path = `/events/${id}`;
45+
if (this.$route.path !== path) this.$router.push(path);
3046
},
3147
},
3248
};

client/src/components/events/default/index.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<span>{{ event.name }}</span>
77
</fieldset>
88
</header>
9-
109
<main>
1110
<slot name="content"></slot>
1211
<fieldset>
@@ -90,12 +89,11 @@ export default {
9089

9190
<style>
9291
.event-content {
92+
--hsl: var(--color-h), var(--color-s), var(--color-l);
9393
width: 100%;
9494
height: 100%;
95-
--s: auto;
96-
--c: 0, 0, 0;
9795
overflow: hidden;
98-
border: 3px solid rgb(var(--c));
96+
border: 2px solid hsl(var(--hsl));
9997
margin: 2px;
10098
position: relative;
10199
display: flex;
@@ -105,7 +103,7 @@ export default {
105103
.event-content:not(.selected) aside {
106104
display: none;
107105
}
108-
.event-content:not(.selected) > *:not(header){
106+
.event-content:not(.selected) > *:not(header) {
109107
display: none;
110108
}
111109
.event-content:not(.selected) header {
@@ -124,7 +122,7 @@ export default {
124122
flex-direction: column;
125123
margin: 0.4em 0;
126124
}
127-
.event-content > header{
125+
.event-content > header {
128126
position: sticky;
129127
top: 0;
130128
background: rgb(255, 255, 255, 0.7);
@@ -149,9 +147,12 @@ export default {
149147
.event-content:not(.selected) legend {
150148
display: none;
151149
}
150+
.event-content:not(.selected):hover{
151+
box-shadow: hsla(var(--hsl), 0.7) 1px 1px 2px 1px, hsla(var(--hsl), 0.7) -1px -1px 2px 1px
152+
}
152153
.event-content.selected {
153-
box-shadow: rgba(0, 0, 0, 0.16) 0px 10px 36px 0px,
154-
rgba(0, 0, 0, 0.06) 0px 0px 0px 1px;
154+
box-shadow: hsla(var(--hsl), 0.6) 3px 3px 4px 2px,
155+
hsla(var(--hsl), 0.56) -3px -3px 4px 2px;
155156
}
156157
.event-content textarea {
157158
outline: none;

client/src/components/events/fabric.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ const KEY_FORMAT = (pref, current) => `${pref}-${current}`
33
module.exports = {
44
all: getAllFromGlobal(),//should be appended to vue components section
55
is(calendarType, viewType) {//dynamic component name retrieving in v-bind:is attr
6-
const type = calendarType.replace("Event",'');
6+
const type = calendarType.replace("Event", '');
77
if (components[type]) return KEY_FORMAT(type, viewType);
88
console.error(`Undefined event component type: ${type}`);
99
return KEY_FORMAT("default", viewType);
10-
}
10+
},
11+
typeColorHSL(calendarType, offset) {
12+
const type = calendarType.replace("Event", '');
13+
if (components[type]) {
14+
const color = components[type].accentColor
15+
return {
16+
...color,
17+
h: color.h + (offset || 0)
18+
};
19+
}
20+
console.error(`Undefined event component type: ${type}`);
21+
return components.default.accentColor
22+
},
1123
}
1224

1325
//TODO: Retrieving component by url

0 commit comments

Comments
 (0)