-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathResponsiveTable.vue
78 lines (76 loc) · 1.4 KB
/
ResponsiveTable.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script setup lang="ts">
interface Props {
colLabels: string[]
rows: {
heading: string
cols: string[][]
}[]
}
defineProps<Props>()
</script>
<template>
<table>
<thead>
<tr>
<th />
<th v-for="colLabel in colLabels" :key="colLabel">
{{ colLabel }}
</th>
</tr>
</thead>
<tbody v-for="(row, rowIndex) in rows" :key="rowIndex">
<tr>
<td :colspan="colLabels.length + 1">
{{ row.heading }}
</td>
</tr>
<tr v-for="(cols, colIndex) in row.cols" :key="colIndex">
<td v-if="colIndex === 0">
{{ row.heading }}
</td>
<td v-else />
<td v-for="col in cols" :key="col">
{{ col }}
</td>
</tr>
</tbody>
</table>
</template>
<style scoped lang="postcss">
table {
@apply w-full mt-14;
}
thead tr {
@apply bg-brand-teal-dark/70 text-white;
}
thead tr th {
@apply py-3.5 px-6 text-lg text-left;
}
thead tr th:first-child {
@apply hidden sm:block;
}
tbody {
@apply border-b border-brand-teal-dark;
}
tbody td {
@apply lg:py-4 py-3 px-6 text-lg;
}
tbody td:first-child {
@apply font-bold;
}
tbody tr:not(:first-child) td:first-child {
@apply hidden sm:block;
}
tbody tr:first-child {
@apply sm:hidden;
}
tbody tr:first-child td {
@apply pt-7;
}
tbody tr:nth-child(2) td {
@apply md:pt-8;
}
tbody tr:last-child td {
@apply pb-8;
}
</style>