Skip to content

Commit b06a08a

Browse files
committed
Styled types and calendars selection
1 parent fa6819d commit b06a08a

File tree

2 files changed

+84
-25
lines changed

2 files changed

+84
-25
lines changed

client/src/components/Main.vue

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
<div id="main">
33
<aside>
44
<toolbar>
5-
<label>Types</label>
6-
<nav>
5+
<fieldset>
6+
<legend @click="showOrHideAllTypes()">Types</legend>
77
<label v-for="type in types" :key="type.id">
88
<input type="checkbox" :value="type.id" v-model="selectedTypeIds"/>
99
<span>{{type.name}}</span>
1010
</label>
11-
</nav>
12-
<label>Calendars</label>
13-
<nav>
14-
<label v-for="calendar in calendars" :key="calendar.id">
11+
</fieldset>
12+
<fieldset>
13+
<legend @click="showOrHideAllCalendars()">Calendars</legend>
14+
<label v-for="calendar in calendars" :key="calendar.id" :class="['']">
1515
<input type="checkbox" :value="calendar.id" v-model="selectedCalendarIds" :disabled="!inArray(calendar.typeId, selectedTypeIds)"/>
1616
<span>{{calendar.name}}</span>
1717
</label>
18-
</nav>
18+
</fieldset>
1919
</toolbar>
2020
</aside>
2121
<main>
@@ -45,6 +45,19 @@ export default {
4545
methods: {
4646
inArray(value, array){
4747
return array.includes(value);
48+
},
49+
showOrHideAllTypes() {
50+
this.selectedTypeIds = this.showOrHide(this.selectedTypeIds, this.types.map(x => x.id));
51+
},
52+
showOrHideAllCalendars() {
53+
const canBeDisplayed = this.calendars
54+
.filter(x => this.selectedTypeIds.includes(x.typeId))
55+
.map(x => x.id);
56+
this.selectedCalendarIds = this.showOrHide(this.selectedCalendarIds, canBeDisplayed);
57+
},
58+
showOrHide(current, full){
59+
const notIn = full.filter(x => !current.includes(x))
60+
return notIn.length == 0? [] : full;
4861
}
4962
},
5063
created(){
@@ -97,10 +110,5 @@ export default {
97110
overflow:auto;
98111
height: 100%;
99112
}
100-
#toolbar nav {
101-
display: flex;
102-
flex-direction: column;
103-
}
104-
105-
113+
106114
</style>

client/src/components/toolbar.vue

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,72 @@
11
<template>
2-
<div id="toolbar">
3-
<header>
4-
{{ header }}
5-
</header>
6-
<slot></slot>
7-
</div>
2+
<form id="toolbar">
3+
<header>
4+
{{ header }}
5+
</header>
6+
<slot></slot>
7+
</form>
88
</template>
99

1010
<script>
1111
export default {
12-
data() {
13-
return {
14-
header:"📅 Calendario"
15-
}
16-
}
17-
}
12+
data() {
13+
return {
14+
header: "📅 Calendario",
15+
};
16+
},
17+
};
1818
</script>
1919

2020
<style>
21+
#toolbar {
22+
display: flex;
23+
flex-direction: column;
24+
height: 100%;
25+
width: 100%;
26+
}
27+
#toolbar header {
28+
font-family: Arial, Helvetica, sans-serif;
29+
}
30+
#toolbar fieldset {
31+
display: flex;
32+
flex-direction: column;
33+
margin: 0.5em 0;
34+
height: auto;
35+
min-width: 0;
36+
text-overflow: ellipsis;
37+
overflow: hidden;
38+
border:none;
39+
}
40+
#toolbar label,
41+
#toolbar legend {
42+
white-space: nowrap;
43+
overflow: hidden;
44+
text-overflow: ellipsis;
45+
cursor: pointer;
46+
}
47+
#toolbar fieldset legend {
48+
margin-bottom: 0.25em;
49+
}
50+
#toolbar input ~ span {
51+
font-weight: 500;
52+
}
53+
#toolbar input:checked ~ span {
54+
font-weight: 700;
55+
}
56+
#toolbar input:disabled ~ span {
57+
opacity: 0.6;
58+
cursor: auto;
59+
}
60+
#toolbar input[type="checkbox"] {
61+
position: absolute;
62+
width: 1px;
63+
height: 1px;
64+
margin: -1px;
65+
border: 0;
66+
padding: 0;
67+
white-space: nowrap;
68+
clip-path: inset(100%);
69+
clip: rect(0 0 0 0);
70+
overflow: hidden;
71+
}
2172
</style>

0 commit comments

Comments
 (0)