forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasonry.vue
More file actions
69 lines (54 loc) · 1.37 KB
/
Masonry.vue
File metadata and controls
69 lines (54 loc) · 1.37 KB
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
<template>
<div class="q-pa-md">
<q-btn class="q-mb-md" color="primary" label="Regenerate layout" @click="onClick" />
<div class="column example-container">
<div class="flex-break hidden"></div>
<div class="flex-break"></div>
<div class="flex-break"></div>
<div class="flex-break"></div>
<div v-for="(cell, i) in cells" :key="i" class="example-cell" tabindex="0">
<div>
<div v-for="(text, j) in cell" :key="j">
{{ text }}
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { ref } from 'vue'
const generateCells = () => Array(24).fill(null).map((_, cell) => (
Array(2 + Math.ceil(3 * Math.random())).fill(null).map((_, text) => `Cell ${cell + 1} - ${text + 1}`)
))
export default {
setup () {
const cells = ref(generateCells())
return {
cells,
onClick () {
cells.value = generateCells()
}
}
}
}
</script>
<style lang="sass" scoped>
.flex-break
flex: 1 0 100% !important
width: 0 !important
$x: 4
@for $i from 1 through ($x - 1)
.example-container > div:nth-child(#{$x}n + #{$i})
order: #{$i}
.example-container > div:nth-child(#{$x}n)
order: #{$x}
.example-container
height: 700px
.example-cell
width: 25%
padding: 1px
> div
padding: 4px 8px
box-shadow: inset 0 0 0 2px $grey-6
</style>