Skip to content

Commit 1827088

Browse files
committed
Show fewer lines for class cards on wider screens
1 parent 5ca640f commit 1827088

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

src/components/Class.vue

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,72 @@
33
<template>
44
<v-flex lg2 md3 xs4>
55
<v-hover>
6-
<v-badge overlap right color = "rgba(0,0,0,0)" style = "width:100%;" slot-scope = "{ hover }">
6+
<v-badge overlap right color="rgba(0,0,0,0)" style="width:100%;" slot-scope="{ hover }">
77
<v-card
8-
v-if = "classInfo == 'placeholder'"
9-
class = "placeholder classbox"
8+
v-if="classInfo == 'placeholder'"
9+
class="placeholder"
1010
>
1111
<v-container fill-height>
12-
<v-layout>
13-
<v-btn style = "margin: auto" large icon @click = "$emit('add-at-placeholder',semesterIndex)"><v-icon>add</v-icon></v-btn>
12+
<v-layout align-center justify-center>
13+
<v-btn large icon @click="$emit('add-at-placeholder', semesterIndex)">
14+
<v-icon>add</v-icon>
15+
</v-btn>
1416
</v-layout>
1517
</v-container>
1618
</v-card>
1719

1820
<v-card
1921
v-else
2022
draggable
21-
v-on:dragstart = "dragStart"
22-
v-on:click = "$emit('click-class', classInfo)"
23-
:id = "'class'+classInfo.id.replace('.','')+semesterIndex"
23+
v-on:dragstart="dragStart"
24+
v-on:click="$emit('click-class', classInfo)"
25+
:id="'class' + classInfo.id.replace('.','') + semesterIndex"
2426
>
2527
<!-- This extra div is necessary because we can't set style with background-color on the v-card. -->
26-
<div :class="cardClass(classInfo)">
27-
<v-icon style = "margin: 4px" small @click = "$emit('remove-class',classInfo); $event.stopPropagation();">cancel</v-icon>
28-
<v-card-text class="card-text"><span style="font-weight: bold; font-size: 1.1em;">{{classInfo.id}}</span> {{classInfo.title}}</v-card-text>
28+
<div :class="cardClass(classInfo)" :style="cardHeight">
29+
<v-icon
30+
style="margin: 4px"
31+
small
32+
@click="$emit('remove-class',classInfo); $event.stopPropagation();"
33+
>cancel</v-icon>
34+
<v-card-text class="card-text">
35+
<span style="font-weight: bold; font-size: 1.1em;">{{classInfo.id}}</span>
36+
{{classInfo.title}}
37+
</v-card-text>
2938
</div>
3039
</v-card>
31-
<v-btn v-if = "warnings.length>0&&(!classInfo.overrideWarnings||hover)" @click = "warningDialog = true" icon slot = "badge">
32-
<v-icon medium>
33-
warning
34-
</v-icon>
40+
<v-btn
41+
v-if="warnings.length > 0 && (!classInfo.overrideWarnings || hover)"
42+
@click = "warningDialog = true"
43+
icon
44+
slot="badge"
45+
>
46+
<v-icon medium>warning</v-icon>
3547
</v-btn>
3648
</v-badge>
3749
</v-hover>
38-
<v-dialog v-model = "warningDialog" max-width="600">
50+
<v-dialog v-model="warningDialog" max-width="600">
3951
<v-card>
40-
<v-btn icon flat style = "float:right" @click = "warningDialog = false"><v-icon>close</v-icon></v-btn>
52+
<v-btn icon flat style = "float:right" @click = "warningDialog = false">
53+
<v-icon>close</v-icon>
54+
</v-btn>
4155
<v-card-title>
4256
<h3>Warnings for {{classInfo.id}}</h3>
4357
</v-card-title>
4458
<v-card-text>
45-
<p v-for = "warning in warnings" v-html="warning"></p>
59+
<p v-for="warning in warnings" v-html="warning"></p>
4660
<v-switch
47-
label = "Override Warnings"
48-
color = "orange darken-3"
49-
v-model = "shouldOverrideWarnings"
61+
label="Override warnings"
62+
color="orange darken-3"
63+
v-model="shouldOverrideWarnings"
5064
>
5165
</v-switch>
5266
</v-card-text>
5367
<v-card-actions style="justify-content: flex-end;">
54-
<v-btn flat @click = "warningDialog = false; $emit('override-warnings',{override:shouldOverrideWarnings,classInfo:classInfo})">Close</v-btn>
68+
<v-btn
69+
flat
70+
@click="warningDialog = false; $emit('override-warnings', {override: shouldOverrideWarnings, classInfo: classInfo})"
71+
>Close</v-btn>
5572
</v-card-actions>
5673
</v-card>
5774
</v-dialog>
@@ -72,6 +89,18 @@ export default {
7289
shouldOverrideWarnings: this.classInfo.overrideWarnings
7390
}
7491
},
92+
computed: {
93+
cardHeight: function() {
94+
switch (this.$vuetify.breakpoint.name) {
95+
/* Chosen for n lines in the card, working with the set padding and margins. */
96+
case 'xs': return 'height: 5.8em;' // 3 lines
97+
case 'sm': return 'height: 5.8em;' // 3 lines
98+
case 'md': return 'height: 5.8em;' // 3 lines
99+
case 'lg': return 'height: 4.2em;' // 2 lines
100+
case 'xl': return 'height: 4.2em;' // 2 lines
101+
}
102+
}
103+
},
75104
methods: {
76105
dragStart: function(event) {
77106
event.dataTransfer.setData('classData', JSON.stringify({isNew: false,classInfo:this.classInfo}));
@@ -107,7 +136,6 @@ export default {
107136
.classbox {
108137
display: flex;
109138
align-items: flex-start;
110-
height: 5.8em; /* Chosen for three lines in the card, working with the set padding and margins. */
111139
overflow: hidden;
112140
padding: .2em .4em .4em .2em;
113141
/* Multi-line truncation is not a supported feature of CSS right now.

0 commit comments

Comments
 (0)