-
Notifications
You must be signed in to change notification settings - Fork 29
/
sidebar-2.html
261 lines (259 loc) · 7.27 KB
/
sidebar-2.html
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"
rel="stylesheet"
/>
<title>Tailwind + Alpine</title>
</head>
<body
x-data="sidebar()"
class="bg-gray-200 text-gray-700"
@resize.window="handleResize()"
>
<div class="xl:flex">
<div
x-show="isOpen()"
class="fixed xl:static inset-0 flex bg-white bg-opacity-75 h-screen"
>
<div
@click.away="handleAway()"
class="w-80 text-white bg-gray-800 shadow"
>
<div class="flex bg-gray-900 content-between">
<div class="p-3 w-full">Project Sidebar</div>
<a
@click.prevent="handleClose()"
class="p-3 hover:bg-indigo-500 flex-1 flex items-center"
href="#"
>
<svg
class="h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</a>
</div>
<a
class="flex items-center w-full p-3 hover:bg-indigo-500"
href="#"
>
<svg
class="h-6 w-6 mr-3"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"
/>
</svg>
Home
</a>
<a
class="flex items-center w-full p-3 hover:bg-indigo-500"
href="#"
><svg
class="h-6 w-6 mr-3"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"
/>
</svg>
Resources
</a>
<a
class="flex items-center w-full p-3 hover:bg-indigo-500"
href="#"
><svg
class="h-6 w-6 mr-3"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
/>
</svg>
Statistics
</a>
<a
class="flex items-center w-full p-3 hover:bg-indigo-500"
href="#"
><svg
class="h-6 w-6 mr-3"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
/>
</svg>
Settings
</a>
</div>
</div>
<div>
<nav class="text-gray-700 bg-white flex">
<div x-show="!isOpen()" class="flex">
<a
x-show="!isOpen()"
@click.prevent="handleOpen()"
class="p-3 hover:bg-indigo-500 hover:text-white"
href="#"
>
<svg
class="h-6 w-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
</a>
<a
class="p-3 hover:bg-indigo-500 hover:text-white"
href="#"
>
Project Sidebar
</a>
</div>
<div class="flex ml-auto">
<a
class="p-3 hover:bg-indigo-500 hover:text-white"
href="#"
>
Account
</a>
</div>
</nav>
<main class="grid gap-4 p-4 md:grid-cols-2 lg:grid-cols-3">
<div class="shadow-lg">
<div class="px-4 py-3 text-white bg-indigo-500">
Lorem Ipsum
</div>
<p class="p-4 bg-white">
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Nam euismod est at nunc rutrum, sit amet
eleifend magna lacinia. Nullam pharetra suscipit
ultricies. Nulla aliquet porttitor porta. Sed
finibus pretium diam, vitae volutpat arcu accumsan
a. Class aptent taciti sociosqu ad litora torquent
per conubia nostra, per inceptos himenaeos.
Suspendisse potenti. Suspendisse lacus ante, aliquet
in dignissim non, ultrices lobortis metus. Integer
auctor laoreet odio et molestie. Maecenas semper
egestas justo, nec tincidunt augue.
</p>
</div>
<div class="shadow-lg">
<div class="px-4 py-3 text-white bg-indigo-500">
Lorem Ipsum
</div>
<p class="p-4 bg-white">
Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Nam euismod est at nunc rutrum, sit amet
eleifend magna lacinia. Nullam pharetra suscipit
ultricies. Nulla aliquet porttitor porta. Sed
finibus pretium diam, vitae volutpat arcu accumsan
a. Class aptent taciti sociosqu ad litora torquent
per conubia nostra, per inceptos himenaeos.
Suspendisse potenti. Suspendisse lacus ante, aliquet
in dignissim non, ultrices lobortis metus. Integer
auctor laoreet odio et molestie. Maecenas semper
egestas justo, nec tincidunt augue.
</p>
</div>
</main>
</div>
</div>
<script>
function sidebar() {
const breakpoint = 1280
return {
open: {
above: true,
below: false,
},
isAboveBreakpoint: window.innerWidth > breakpoint,
handleResize() {
this.isAboveBreakpoint = window.innerWidth > breakpoint
},
isOpen() {
console.log(this.isAboveBreakpoint)
if (this.isAboveBreakpoint) {
return this.open.above
}
return this.open.below
},
handleOpen() {
if (this.isAboveBreakpoint) {
this.open.above = true
}
this.open.below = true
},
handleClose() {
if (this.isAboveBreakpoint) {
this.open.above = false
}
this.open.below = false
},
handleAway() {
if (!this.isAboveBreakpoint) {
this.open.below = false
}
},
}
}
</script>
<script
src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js"
defer
></script>
</body>
</html>