Skip to content

Commit 04c24b2

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

File tree

1 file changed

+47
-21
lines changed

1 file changed

+47
-21
lines changed

src/components/Class.vue

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
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>
1212
<v-layout>
@@ -18,40 +18,55 @@
1818
<v-card
1919
v-else
2020
draggable
21-
v-on:dragstart = "dragStart"
22-
v-on:click = "$emit('click-class', classInfo)"
23-
:id = "'class'+classInfo.id.replace('.','')+semesterIndex"
21+
v-on:dragstart="dragStart"
22+
v-on:click="$emit('click-class', classInfo)"
23+
:id="'class' + classInfo.id.replace('.','') + semesterIndex"
2424
>
2525
<!-- 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>
26+
<div :class="cardClass(classInfo)" :style="cardHeight">
27+
<v-icon
28+
style="margin: 4px"
29+
small
30+
@click="$emit('remove-class', classInfo); $event.stopPropagation();"
31+
>cancel</v-icon>
32+
<v-card-text class="card-text">
33+
<span style="font-weight: bold; font-size: 1.1em;">{{classInfo.id}}</span>
34+
{{classInfo.title}}
35+
</v-card-text>
2936
</div>
3037
</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>
38+
<v-btn
39+
v-if="warnings.length > 0 && (!classInfo.overrideWarnings || hover)"
40+
@click="warningDialog = true"
41+
icon
42+
slot="badge"
43+
>
44+
<v-icon medium>warning</v-icon>
3545
</v-btn>
3646
</v-badge>
3747
</v-hover>
38-
<v-dialog v-model = "warningDialog" max-width="600">
48+
<v-dialog v-model="warningDialog" max-width="600">
3949
<v-card>
40-
<v-btn icon flat style = "float:right" @click = "warningDialog = false"><v-icon>close</v-icon></v-btn>
50+
<v-btn icon flat style = "float:right" @click = "warningDialog = false">
51+
<v-icon>close</v-icon>
52+
</v-btn>
4153
<v-card-title>
4254
<h3>Warnings for {{classInfo.id}}</h3>
4355
</v-card-title>
4456
<v-card-text>
45-
<p v-for = "warning in warnings" v-html="warning"></p>
57+
<p v-for="warning in warnings" v-html="warning"></p>
4658
<v-switch
47-
label = "Override Warnings"
48-
color = "orange darken-3"
49-
v-model = "shouldOverrideWarnings"
59+
label="Override warnings"
60+
color="orange darken-3"
61+
v-model="shouldOverrideWarnings"
5062
>
5163
</v-switch>
5264
</v-card-text>
5365
<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>
66+
<v-btn
67+
flat
68+
@click="warningDialog = false; $emit('override-warnings', {override: shouldOverrideWarnings, classInfo: classInfo})"
69+
>Close</v-btn>
5570
</v-card-actions>
5671
</v-card>
5772
</v-dialog>
@@ -72,6 +87,18 @@ export default {
7287
shouldOverrideWarnings: this.classInfo.overrideWarnings
7388
}
7489
},
90+
computed: {
91+
cardHeight: function() {
92+
switch (this.$vuetify.breakpoint.name) {
93+
/* Chosen for n lines in the card, working with the set padding and margins. */
94+
case 'xs': return 'height: 5.8em;' // 3 lines
95+
case 'sm': return 'height: 5.8em;' // 3 lines
96+
case 'md': return 'height: 5.8em;' // 3 lines
97+
case 'lg': return 'height: 4.2em;' // 2 lines
98+
case 'xl': return 'height: 4.2em;' // 2 lines
99+
}
100+
}
101+
},
75102
methods: {
76103
dragStart: function(event) {
77104
event.dataTransfer.setData('classData', JSON.stringify({isNew: false,classInfo:this.classInfo}));
@@ -107,7 +134,6 @@ export default {
107134
.classbox {
108135
display: flex;
109136
align-items: flex-start;
110-
height: 5.8em; /* Chosen for three lines in the card, working with the set padding and margins. */
111137
overflow: hidden;
112138
padding: .2em .4em .4em .2em;
113139
/* Multi-line truncation is not a supported feature of CSS right now.

0 commit comments

Comments
 (0)