|
17 | 17 |
|
18 | 18 | <script type="module">
|
19 | 19 | import { Application } from "@hotwired/stimulus";
|
20 |
| - import { Alert, ColorPreview, Dropdown, Modal, Popover, Slideover, Tabs, Toggle } from "tailwindcss-stimulus-components"; |
| 20 | + import { Accordion, Alert, ColorPreview, Dropdown, Modal, Popover, Slideover, Tabs, Toggle } from "tailwindcss-stimulus-components"; |
21 | 21 |
|
22 | 22 | (() => {
|
23 | 23 | const application = Application.start();
|
| 24 | + application.register('accordion', Accordion); |
24 | 25 | application.register('alert', Alert);
|
25 | 26 | application.register('color-preview', ColorPreview);
|
26 | 27 | application.register('dropdown', Dropdown);
|
@@ -68,6 +69,63 @@ <h1 class="text-3xl font-semibold mb-2">Tailwind Stimulus Components Examples</h
|
68 | 69 | <a href="https://github.com/excid3/tailwindcss-stimulus-components" target="_blank" class="text-blue-500">View on Github</a>
|
69 | 70 | <p class="my-4">To view examples locally, run <code class="bg-gray-300 text-sm px-2 py-1 rounded">npm install && npm run build && npx serve</code> and then open <code class="bg-gray-300 text-sm px-2 py-1 rounded">localhost:3000</code> in your browser.</p>
|
70 | 71 |
|
| 72 | + <div class="my-12"> |
| 73 | + <h2 class="text-2xl text-gray-800 font-semibold mb-4">Accordion</h2> |
| 74 | + |
| 75 | + <!-- Accordion --> |
| 76 | + <div data-controller="accordion" |
| 77 | + class='flex flex-col gap-0.5 max-w-75 border border-gray-400 rounded-lg'> |
| 78 | + <div data-index='0' data-action='click->accordion#toggle' data-accordion-target='button' |
| 79 | + class='flex justify-between items-center cursor-pointer w-full items-center gap-3 rounded-lg px-2 py-4 text-left text-base/6 font-medium text-zinc-950 sm:py-2 sm:text-sm/5' |
| 80 | + > |
| 81 | + <span>Button 1</span> |
| 82 | + <span data-accordion-target='chevron' class='w-4 h-4 transition-transform'> |
| 83 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"> |
| 84 | + <path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5" /> |
| 85 | + </svg> |
| 86 | + </span> |
| 87 | + </div> |
| 88 | + <div data-accordion-target='panel' class='pl-4 overflow-hidden h-0'> |
| 89 | + <div class="p-4"> |
| 90 | + This is the first accordion panel. |
| 91 | + </div> |
| 92 | + </div> |
| 93 | + |
| 94 | + <div data-index='1' data-action='click->accordion#toggle' data-accordion-target='button' |
| 95 | + class='flex justify-between items-center cursor-pointer w-full items-center gap-3 rounded-lg px-2 py-4 text-left text-base/6 font-medium text-zinc-950 sm:py-2 sm:text-sm/5' |
| 96 | + > |
| 97 | + <span>Button 2</span> |
| 98 | + <span data-accordion-target='chevron' class='w-4 h-4 transition-transform'> |
| 99 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"> |
| 100 | + <path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5" /> |
| 101 | + </svg> |
| 102 | + </span> |
| 103 | + </div> |
| 104 | + <div data-accordion-target='panel' class='pl-4 overflow-hidden h-0'> |
| 105 | + <div class="p-4"> |
| 106 | + This is the second accordion panel. |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + |
| 110 | + <div data-index='2' data-action='click->accordion#toggle' data-accordion-target='button' |
| 111 | + class='flex justify-between items-center cursor-pointer w-full items-center gap-3 rounded-lg px-2 py-4 text-left text-base/6 font-medium text-zinc-950 sm:py-2 sm:text-sm/5' |
| 112 | + > |
| 113 | + <span>Button 3</span> |
| 114 | + <span data-accordion-target='chevron' class='w-4 h-4 transition-transform'> |
| 115 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"> |
| 116 | + <path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5" /> |
| 117 | + </svg> |
| 118 | + </span> |
| 119 | + </div> |
| 120 | + <div data-accordion-target='panel' class='pl-4 overflow-hidden h-0'> |
| 121 | + <div class="p-4"> |
| 122 | + This is the third accordion panel. |
| 123 | + </div> |
| 124 | + </div> |
| 125 | + |
| 126 | + </div> |
| 127 | + </div> |
| 128 | + |
71 | 129 | <div class="my-12">
|
72 | 130 | <h2 class="text-2xl text-gray-800 font-semibold mb-4">Alerts</h2>
|
73 | 131 |
|
|
0 commit comments