forked from excid3/tailwindcss-stimulus-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
383 lines (349 loc) · 20.5 KB
/
index.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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tailwind Stimulus Components</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/@tailwindcss/forms/dist/forms.min.css" rel="stylesheet">
<script>
window.esmsInitOptions = { enable: ['css-modules', 'json-modules'] }
</script>
<script async src="https://unpkg.com/es-module-shims/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"@hotwired/stimulus": "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js",
"tailwindcss-stimulus-components": "./dist/tailwindcss-stimulus-components.modern.js"
}
}
</script>
<!--
Use the following importmap for local package with "npx serve"
"tailwindcss-stimulus-components": "../dist/tailwindcss-stimulus-components.modern.js"
-->
<script type="module">
import { Application } from "@hotwired/stimulus";
import { Alert, ColorPreview, Dropdown, Modal, Popover, Slideover, Tabs, Toggle } from "tailwindcss-stimulus-components";
(() => {
const application = Application.start();
application.register('alert', Alert);
application.register('color-preview', ColorPreview);
application.register('dropdown', Dropdown);
application.register('modal', Modal);
application.register('popover', Popover);
application.register('slideover', Slideover);
application.register('tabs', Tabs);
application.register('toggle', Toggle);
})()
</script>
</head>
<body>
<div class="container mx-auto p-8"
data-controller="slideover"
data-slideover-open-value="false"
data-slideover-invisible-class="-translate-x-full,opacity-0"
data-slideover-visible-class="translate-x-0,opacity-100"
data-slideover-entering-class=""
data-slideover-enter-timeout="300,300"
data-slideover-leaving-class=""
data-slideover-leave-timeout="300,0"
data-slideover-active-target="#slideover-target">
<!-- begin sidebar/slideover -->
<div id="sidebar-mobile">
<div data-slideover-target="overlay" class="fixed inset-0 flex z-40 transition-opacity ease-linear duration-300 opacity-0 hidden">
<div class="fixed inset-0">
<div class="absolute inset-0 bg-gray-600 opacity-75"></div>
</div>
<div id="slideover-target" data-slideover-target="menu" class="relative flex-1 flex flex-col max-w-xs w-full pt-5 pb-4 bg-gray-800 transition ease-in-out duration-300 transform -translate-x-full hidden">
<div class="absolute top-0 right-0 -mr-14 p-1">
<button data-action="slideover#toggle" class="flex items-center justify-center h-12 w-12 rounded-full focus:outline-none focus:bg-gray-600" aria-label="Close sidebar">
<svg class="h-6 w-6 text-white" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div class="flex-shrink-0 flex items-center px-4">
<h1 class="text-white text-2xl font-bold">Sidebar</h1>
</div>
<div class="mt-5 flex-1 h-0 overflow-y-auto">
<nav class="px-2 space-y-1">
</nav>
</div>
</div>
<div class="flex-shrink-0 w-14">
<!-- Dummy element to force sidebar to shrink to fit close icon -->
</div>
</div>
</div>
<!-- end sidebar/slideover -->
<h1 class="text-3xl font-semibold mb-2">Tailwind Stimulus Components Examples</h1>
<img src="https://img.shields.io/npm/v/tailwindcss-stimulus-components.svg" class="inline-block mr-2" />
<a href="https://github.com/excid3/tailwindcss-stimulus-components" class="text-blue-500">View on Github</a>
<p class="my-4">To view examples locally, run <code class="bg-gray-300 text-sm px-2 py-1 rounded">yarn build</code> and then open <code class="bg-gray-300 text-sm px-2 py-1 rounded">docs/index.html</code> in your browser.</p>
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Dropdowns</h2>
<nav id='nav_bar' class="flex items-center justify-between flex-wrap bg-indigo-500 p-6">
<div class="flex items-center flex-no-shrink text-white mr-6">
<svg class="fill-current h-8 w-8 mr-2" width="54" height="54" viewBox="0 0 54 54" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 22.1c1.8-7.2 6.3-10.8 13.5-10.8 10.8 0 12.15 8.1 17.55 9.45 3.6.9 6.75-.45 9.45-4.05-1.8 7.2-6.3 10.8-13.5 10.8-10.8 0-12.15-8.1-17.55-9.45-3.6-.9-6.75.45-9.45 4.05zM0 38.3c1.8-7.2 6.3-10.8 13.5-10.8 10.8 0 12.15 8.1 17.55 9.45 3.6.9 6.75-.45 9.45-4.05-1.8 7.2-6.3 10.8-13.5 10.8-10.8 0-12.15-8.1-17.55-9.45-3.6-.9-6.75.45-9.45 4.05z"/></svg>
<span class="font-semibold text-xl tracking-tight">Dropdown Example</span>
</div>
<div data-controller="dropdown"
data-action="click->dropdown#toggle click@window->dropdown#hide"
data-dropdown-open-value="false"
data-dropdown-active-target="#dropdown-button"
data-dropdown-active-class="bg-indigo-600"
data-dropdown-invisible-class="opacity-0 scale-95"
data-dropdown-visible-class="opacity-100 scale-100"
data-dropdown-entering-class="ease-out duration-300"
data-dropdown-enter-timeout="300"
data-dropdown-leaving-class="ease-in duration-300"
data-dropdown-leave-timeout="300">
<div id="dropdown-button" class="relative inline-block text-sm text-white px-4 py-2 leading-none rounded no-underline hover:bg-indigo-600 mt-0">
<div role="button" tabindex="0" data-dropdown-target="button" class="inline-block select-none">
<span class="appearance-none flex items-center inline-block">
<span>Dropdown Example</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="text-white fill-current h-4 w-4"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"></path></svg>
</span>
</div>
<div data-dropdown-target="menu" class="absolute right-0 mt-2 transform transition hidden opacity-0 scale-95">
<div class="bg-white shadow rounded border overflow-hidden w-32">
<a href="#" class='no-underline block pl-8 py-3 text-gray-900 bg-white hover:bg-gray-300 whitespace-no-wrap'>Account</a>
<a href="#" class='no-underline block pl-8 py-3 text-gray-900 bg-white hover:bg-gray-300 whitespace-no-wrap'>Billing</a>
<a href="#" class='no-underline block pl-8 py-3 text-gray-900 bg-white hover:bg-gray-300 whitespace-no-wrap border-t'>Sign Out</a>
</div>
</div>
</div>
</div>
</nav>
</div>
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Slideovers</h2>
<button data-action="click->slideover#toggle click@window->slideover#hide" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded">
<span>Open Slideover</span>
</button>
</div>
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Modals</h2>
<div data-controller="modal" data-modal-allow-background-close="true">
<a href="#" data-action="click->modal#open" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded">
<span>Open Modal</span>
</a>
<!-- Modal Container -->
<div data-modal-target="container" data-action="click->modal#closeBackground keyup@window->modal#closeWithKeyboard" class="hidden animated fadeIn fixed inset-0 overflow-y-auto flex items-center justify-center" style="z-index: 9999;">
<!-- Modal Inner Container -->
<div class="max-h-screen w-full max-w-lg relative">
<!-- Modal Card -->
<div class="m-1 bg-white rounded shadow">
<div class="p-8">
<h2 class="text-xl mb-4">Large Modal Content</h2>
<p class="mb-4">This is an example modal dialog box.</p>
<div class="flex justify-end items-center flex-wrap mt-6">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" data-action="click->modal#close">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Popover example -->
<div class='my-12'>
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Popover</h2>
<div>
<span>Beginning in 2015, Google introduced what is called the</span>
<div class="popover inline-block cursor-pointer" data-controller="popover" data-popover-translate-x="0" data-popover-translate-y="-128%" data-action="mouseover->popover#mouseOver mouseout->popover#mouseOut">
<span class="underline">'local snack pack',</span>
<div class="content hidden absolute max-w-xs border rounded p-2" data-popover-target="content">
Terrible name - we know. But the biggest name in SEO came up with it.
</div>
</div>
<span>which shows you local search results before normal organic results.</span>
</div>
</div>
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Tabs</h2>
<div data-controller="tabs" data-tabs-active-tab="-mb-px border-l border-t border-r rounded-t">
<ul class="list-reset flex border-b">
<li class="-mb-px mr-1" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Active</a>
</li>
<li class="mr-1" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Tab</a>
</li>
<li class="mr-1" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Tab</a>
</li>
<li class="mr-1">
<a class="bg-white inline-block py-2 px-4 text-gray-500 font-semibold no-underline" href="#">Tab</a>
</li>
</ul>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
Tab panel 1
</div>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
Tab panel 2
</div>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
<iframe width="560" height="315" src="https://www.youtube.com/embed/0aTRN9CSCY0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div class="mt-4">
<a data-action="click->tabs#change" data-index="1" class="text-blue-500 underline" href="#">Change tab by data-index</a>
</div>
</div>
</div>
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Tabs with Anchors</h2>
<div data-controller="tabs" data-tabs-use-anchor="true" data-tabs-active-tab="-mb-px border-l border-t border-r rounded-t">
<ul class="list-reset flex border-b">
<li class="-mb-px mr-1" id="first" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Active</a>
</li>
<li class="mr-1" id="second" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Tab</a>
</li>
<li class="mr-1" id="third" data-tabs-target="tab" data-action="click->tabs#change">
<a class="bg-white inline-block py-2 px-4 text-blue-600 hover:text-blue-700 font-semibold no-underline" href="#">Tab</a>
</li>
<li class="mr-1" id="fourth">
<a class="bg-white inline-block py-2 px-4 text-gray-500 font-semibold no-underline" href="#">Tab</a>
</li>
</ul>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
Tab panel 1
</div>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
Tab panel 2
</div>
<div class="hidden py-4 px-4 border-l border-b border-r" data-tabs-target="panel">
<iframe width="560" height="315" src="https://www.youtube.com/embed/0aTRN9CSCY0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div class="mt-4">
<a data-action="click->tabs#change" data-id="second" class="text-blue-500 underline" href="#">Change tab by data-id</a>
</div>
</div>
</div>
<!-- Toggle -->
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Toggle</h2>
<div data-controller='toggle' class="m-2 p-6 border">
<button data-action='click->toggle#toggle touch->toggle#toggle' class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded">
Toggle button
</button>
<div data-toggle-target='toggleable' class="m-4 hidden">
<p>This is the hidden text...</p>
</div>
</div>
</div>
<!-- Color Picker and Preview -->
<div class="my-12">
<h2 class="text-2xl text-gray-800 font-semibold mb-4">Color Picker and Preview</h2>
<div class="col-span-6 sm:col-span-3">
<label for="hex_color_bg" class="block text-sm font-medium text-gray-700 ">
Color
</label>
<div class="mt-3 flex items-center" data-controller="color-preview">
<p data-color-preview-target="preview"
class="h-10 w-10 mr-2 rounded-full text-2xl text-white text-center"
style="background-color: #ba1e03; color: #fff; padding-top: 1px;">
A
</p>
<span class="ml-2">
<div class="flex rounded-md shadow-sm">
<span class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-gray-500">
#
</span>
<input data-action="input->color-preview#update" data-color-preview-target="color"
id="hex_color_bg" name="hex_color_bg" type="color" value="#ba1e03"
class="focus:ring-indigo-500 focus:border-indigo-500 block shadow-sm sm:text-sm border-gray-300 flex-1 rounded-r-md mt-0 w-24 h-8 px-1 py-1 border" />
</div>
</span>
</div>
</div>
</div>
</div>
<!-- Alert -->
<div class="fixed top-0 inset-x-0 m-4 z-30">
<div class="flex flex-col items-end space-y-4">
<div data-controller="alert" data-alert-show-class="translate-x-0 opacity-100" data-alert-hide-class="translate-x-full opacity-0" class="ease-in-out duration-500 opacity-0 max-w-sm w-full shadow-lg rounded px-4 py-3 rounded relative bg-gray-800 text-white pointer-events-auto">
<div class="p-2">
<div class="flex items-start">
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm leading-5 font-medium">
We have alerts too!
</p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button data-action="alert#close" class="inline-flex text-white focus:outline-none focus:text-gray-300 transition ease-in-out duration-150">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
</button>
</div>
</div>
</div>
</div>
<!-- Alert that auto-dismisses-->
<div data-controller="alert" data-alert-dismiss-after-value="3000" data-alert-show-class="translate-x-0 opacity-100" data-alert-hide-class="translate-x-full opacity-0" class="ease-in-out duration-500 opacity-0 max-w-sm w-full shadow-lg rounded px-4 py-3 rounded relative bg-gray-800 text-white pointer-events-auto">
<div class="p-2">
<div class="flex items-start">
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm leading-5 font-medium">
Auto dismisses after 3 seconds.
</p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button data-action="alert#close" class="inline-flex text-white focus:outline-none focus:text-gray-300 transition ease-in-out duration-150">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Alert on bottom of screen
<div class="fixed inset-x-0 bottom-0 m-4 z-30">
<div class="flex flex-col space-y-4 ">
<div data-controller="alert" data-alert-show-class="translate-x-0 opacity-100" data-alert-hide-class="-translate-x-full opacity-0" class="ease-in-out duration-500 opacity-0 max-w-sm w-full shadow-lg rounded px-3 py-2 rounded relative bg-white text-gray-800 border border-gray-100 shadow-lg pointer-events-auto">
<div class="p-2">
<div class="flex items-start">
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm leading-5 font-medium">
Draft saved successfully
</p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button data-action="alert#close" class="inline-flex text-gray-400 focus:outline-none focus:text-gray-300 transition ease-in-out duration-150">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
</button>
</div>
</div>
</div>
</div>
<div data-controller="alert" data-alert-show-class="translate-x-0 opacity-100" data-alert-hide-class="-translate-x-full opacity-0" class="ease-in-out duration-500 opacity-0 max-w-sm w-full shadow-lg rounded px-3 py-2 rounded relative bg-white text-gray-800 border border-gray-100 shadow-lg pointer-events-auto">
<div class="p-2">
<div class="flex items-start">
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm leading-5 font-medium">
Second alert
</p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button data-action="alert#close" class="inline-flex text-gray-400 focus:outline-none focus:text-gray-300 transition ease-in-out duration-150">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
-->
</body>
</html>