Skip to content

Commit 691c958

Browse files
committed
Show fewer lines for class cards on wider screens
1 parent 30ae471 commit 691c958

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en" xml:lang="en">
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1.0">

src/components/Class.vue

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<v-badge slot-scope="{ hover }" overlap right color="rgba(0,0,0,0)" style="width:100%;">
77
<v-card
88
v-if="classInfo == 'placeholder'"
9-
class="placeholder classbox"
9+
class="placeholder"
1010
>
1111
<v-container fill-height>
1212
<v-layout align-center justify-center>
@@ -23,22 +23,32 @@
2323

2424
<v-card
2525
v-else
26-
:id="'class'+classInfo.id.replace('.','')+semesterIndex"
26+
:id="'class' + classInfo.id.replace('.','') + semesterIndex"
2727
draggable
2828
@dragstart="dragStart"
2929
@click="$emit('click-class', classInfo)"
3030
>
3131
<!-- This extra div is necessary because we can't set style with background-color on the v-card. -->
32-
<div :class="cardClass(classInfo)">
33-
<v-icon style="margin: 4px" small @click="$emit('remove-class',classInfo); $event.stopPropagation();">
32+
<div :class="cardClass(classInfo)" :style="cardHeight">
33+
<v-icon
34+
style="margin: 4px"
35+
small
36+
@click="$emit('remove-class', classInfo); $event.stopPropagation();"
37+
>
3438
cancel
3539
</v-icon>
3640
<v-card-text class="card-text">
37-
<span style="font-weight: bold; font-size: 1.1em;">{{ classInfo.id }}</span> {{ classInfo.title }}
41+
<span style="font-weight: bold; font-size: 1.1em;">{{ classInfo.id }}</span>
42+
{{ classInfo.title }}
3843
</v-card-text>
3944
</div>
4045
</v-card>
41-
<v-btn v-if="warnings.length>0&&(!classInfo.overrideWarnings||hover)" slot="badge" icon @click="warningDialog = true">
46+
<v-btn
47+
v-if="warnings.length > 0 && (!classInfo.overrideWarnings || hover)"
48+
slot="badge"
49+
icon
50+
@click="warningDialog = true"
51+
>
4252
<v-icon medium>
4353
warning
4454
</v-icon>
@@ -54,15 +64,18 @@
5464
<h3>Warnings for {{ classInfo.id }}</h3>
5565
</v-card-title>
5666
<v-card-text>
57-
<p v-for="warning in warnings" v-html="warning" />
67+
<p v-for="warning in warnings" :key="warning" v-html="warning" />
5868
<v-switch
5969
v-model="shouldOverrideWarnings"
6070
label="Override warnings"
6171
color="orange darken-3"
6272
/>
6373
</v-card-text>
6474
<v-card-actions style="justify-content: flex-end;">
65-
<v-btn flat @click="warningDialog = false; $emit('override-warnings',{override:shouldOverrideWarnings,classInfo:classInfo})">
75+
<v-btn
76+
flat
77+
@click="warningDialog = false; $emit('override-warnings', {override: shouldOverrideWarnings, classInfo: classInfo})"
78+
>
6679
Close
6780
</v-btn>
6881
</v-card-actions>
@@ -84,6 +97,18 @@ export default {
8497
shouldOverrideWarnings: this.classInfo.overrideWarnings
8598
};
8699
},
100+
computed: {
101+
cardHeight: function () {
102+
switch (this.$vuetify.breakpoint.name) {
103+
/* Chosen for n lines in the card, working with the set padding and margins. */
104+
case 'xs': return 'height: 5.8em;'; // 3 lines
105+
case 'sm': return 'height: 5.8em;'; // 3 lines
106+
case 'md': return 'height: 5.8em;'; // 3 lines
107+
case 'lg': return 'height: 4.2em;'; // 2 lines
108+
case 'xl': return 'height: 4.2em;'; // 2 lines
109+
}
110+
}
111+
},
87112
methods: {
88113
dragStart: function (event) {
89114
event.dataTransfer.setData('classData', JSON.stringify({ isNew: false, classInfo: this.classInfo }));
@@ -118,14 +143,14 @@ export default {
118143
.classbox {
119144
display: flex;
120145
align-items: flex-start;
121-
height: 5.8em; /* Chosen for three lines in the card, working with the set padding and margins. */
122146
overflow: hidden;
123147
padding: .2em .4em .4em .2em;
124148
/* Multi-line truncation is not a supported feature of CSS right now.
125149
Optimally, we would have multi-line truncation within the cards, but
126150
currently extra words are clipped.
127151
text-overflow: ellipsis;
128152
white-space: nowrap; */
153+
hyphens: auto;
129154
}
130155
131156
.placeholder {

0 commit comments

Comments
 (0)