This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Example.vue
114 lines (101 loc) · 2.37 KB
/
Example.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<css-grid
:columns="currentGrid.columns"
:rows="currentGrid.rows"
:areas="currentGrid.areas">
<css-grid-item area="title">
<color-block color="#BBBDF6">
<h1>Header</h1>
</color-block>
</css-grid-item>
<css-grid-item area="leftbar">
<color-block color="#FE4A49">
<h2>Left bar</h2>
</color-block>
</css-grid-item>
<css-grid-item area="main">
<main-content />
</css-grid-item>
<css-grid-item area="rightbar">
<color-block color="#009FB7">
<h2>Right bar</h2>
</color-block>
</css-grid-item>
<css-grid-item area="footer">
<color-block color="#8D6B94">
<h2>footer</h2>
</color-block>
</css-grid-item>
<viewport-listener v-model="viewport"/>
</css-grid>
</template>
<script>
// Component used to show the cell areas clearly
import colorBlock from './examples/ColorBlock'
// A nested grid with more use cases
import mainContent from './examples/MainContent'
export default {
components: {
colorBlock,
mainContent
},
data () {
return {
// default viewport, mobile first
viewport: {width: 320, height: 568},
// 3x3 grid
desktopGrid: {
columns: ['20%', 'auto', '20%'],
rows: ['100px', 'auto', '100px'],
areas: [
['title', 'title', 'title'],
['leftbar', 'main', 'rightbar'],
['footer', 'footer', 'footer']
]
},
// 2x4 grid
tabletGrid: {
columns: ['30%', 'auto'],
rows: ['150px', '400px', 'auto', '100px'],
areas: [
['title', 'title'],
['leftbar', 'main'],
['rightbar', 'main'],
['footer', 'footer']
]
},
// 1x5 grid
mobileGrid: {
columns: ['100%'],
rows: [
'80px',
'auto',
'100px',
'100px',
'80px'
],
areas: [
['title'],
['main'],
['leftbar'],
['rightbar'],
['footer']
]
}
}
},
computed: {
// change Layout according to the viewport size
currentGrid () {
if (this.viewport.isDesktop ||
this.viewport.isLargeDesktop) {
return this.desktopGrid
}
if (this.viewport.isTablet) {
return this.tabletGrid
}
return this.mobileGrid
}
}
}
</script>