Previews

No matching results.

x
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
<div class="p-8 space-y-8">
<div>
<h3 class="text-lg font-semibold mb-4">Click Counter Demo</h3>
<div class="flex items-center gap-4">
<button type="button" data-action="click->counter#increment" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Click Me!
</span>
</button>
<span class="text-lg">Clicks: <span data-counter-target="count">0</span></span>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Alert Demo</h3>
<div class="flex flex-wrap gap-3">
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" onclick="alert('Primary button clicked!')" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-info-500 bg-info-600 hover:bg-info-700 active:bg-info-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Show Alert
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" onclick="console.log('Success button clicked')" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-success-500 bg-transparent border-2 border-success-600 hover:border-success-700 hover:bg-success-50 text-success-600 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Log to Console
</span>
</button>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Disabled Button Interaction</h3>
<div class="flex flex-wrap gap-3">
<button type="button" disabled="disabled" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" onclick="alert('This should not fire')" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 opacity-50 cursor-not-allowed">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Disabled (Click Won't Work)
</span>
</button>
<button type="button" disabled="disabled" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" onclick="alert('This should not fire')" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-wait">
<span data-better-ui--button-target="spinner" class="">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class="hidden inline-flex items-center gap-2">
Loading (Click Won't Work)
</span>
</button>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Button with Custom Data Attributes</h3>
<button type="button" data-turbo-method="post" data-turbo-confirm="Are you sure?" data-custom-value="example" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Button with Data Attributes
</span>
</button>
<p class="text-sm text-gray-600 mt-2">Inspect this button to see data-turbo-method, data-turbo-confirm, and data-custom-value attributes</p>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Buttons with ARIA Labels</h3>
<div class="flex flex-wrap gap-3">
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" aria-label="Delete item" title="Delete" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-danger-500 bg-danger-600 hover:bg-danger-700 active:bg-danger-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
</svg>
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" aria-label="Edit item" title="Edit" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
</span>
</button>
</div>
<p class="text-sm text-gray-600 mt-2">Hover over buttons to see tooltips (title) and inspect for aria-label attributes</p>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Focus State Demo</h3>
<p class="text-sm text-gray-600 mb-2">Tab through these buttons to see focus states:</p>
<div class="flex flex-wrap gap-3">
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Primary
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-secondary-500 bg-secondary-600 hover:bg-secondary-700 active:bg-secondary-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Secondary
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent-500 bg-accent-600 hover:bg-accent-700 active:bg-accent-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Accent
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-success-500 bg-success-600 hover:bg-success-700 active:bg-success-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Success
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-danger-500 bg-danger-600 hover:bg-danger-700 active:bg-danger-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Danger
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-warning-500 bg-warning-600 hover:bg-warning-700 active:bg-warning-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Warning
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-info-500 bg-info-600 hover:bg-info-700 active:bg-info-800 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Info
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-grayscale-400 bg-grayscale-100 hover:bg-grayscale-200 active:bg-grayscale-300 text-grayscale-900 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Light
</span>
</button>
<button type="button" data-controller="better-ui--button" data-action="click->better-ui--button#handleClick" class="inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-grayscale-600 bg-grayscale-900 hover:bg-grayscale-800 active:bg-grayscale-700 text-grayscale-50 px-4 py-2 text-base gap-2 cursor-pointer">
<span data-better-ui--button-target="spinner" class="hidden">
<svg class="animate-spin w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<span class="sr-only">Loading...</span>
</span>
<span data-better-ui--button-target="content" class=" inline-flex items-center gap-2">
Dark
</span>
</button>
</div>
</div>
</div>
<script data-turbo-track="reload">
// Simple counter controller for demo
if (!window.Stimulus) {
console.warn('Stimulus not loaded for interactive demo');
} else {
class CounterController extends window.Stimulus.Controller {
static targets = ["count"]
connect() {
this.count = 0;
}
increment() {
this.count++;
if (this.hasCountTarget) {
this.countTarget.textContent = this.count;
}
}
}
if (window.Stimulus.application) {
try {
window.Stimulus.application.register("counter", CounterController);
} catch(e) {
// Controller might already be registered
}
}
}
</script>
<div data-controller="counter">
<!-- Counter context for demo -->
</div>
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
<div class="p-8 space-y-8">
<div>
<h3 class="text-lg font-semibold mb-4">Click Counter Demo</h3>
<div class="flex items-center gap-4">
<%= render BetterUi::ButtonComponent.new(
variant: :primary,
data: {
action: "click->counter#increment"
}
) do %>
Click Me!
<% end %>
<span class="text-lg">Clicks: <span data-counter-target="count">0</span></span>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Alert Demo</h3>
<div class="flex flex-wrap gap-3">
<%= render BetterUi::ButtonComponent.new(
variant: :info,
onclick: "alert('Primary button clicked!')"
) do %>
Show Alert
<% end %>
<%= render BetterUi::ButtonComponent.new(
variant: :success,
style: :outline,
onclick: "console.log('Success button clicked')"
) do %>
Log to Console
<% end %>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Disabled Button Interaction</h3>
<div class="flex flex-wrap gap-3">
<%= render BetterUi::ButtonComponent.new(
variant: :primary,
disabled: true,
onclick: "alert('This should not fire')"
) do %>
Disabled (Click Won't Work)
<% end %>
<%= render BetterUi::ButtonComponent.new(
variant: :primary,
show_loader: true,
onclick: "alert('This should not fire')"
) do %>
Loading (Click Won't Work)
<% end %>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Button with Custom Data Attributes</h3>
<%= render BetterUi::ButtonComponent.new(
variant: :primary,
data: {
turbo_method: :post,
turbo_confirm: "Are you sure?",
custom_value: "example"
}
) do %>
Button with Data Attributes
<% end %>
<p class="text-sm text-gray-600 mt-2">Inspect this button to see data-turbo-method, data-turbo-confirm, and data-custom-value attributes</p>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Buttons with ARIA Labels</h3>
<div class="flex flex-wrap gap-3">
<%= render BetterUi::ButtonComponent.new(
variant: :danger,
aria: { label: "Delete item" },
title: "Delete"
) do |button| %>
<% button.with_icon_before do %>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
</svg>
<% end %>
<% end %>
<%= render BetterUi::ButtonComponent.new(
variant: :primary,
aria: { label: "Edit item" },
title: "Edit"
) do |button| %>
<% button.with_icon_before do %>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
<% end %>
<% end %>
</div>
<p class="text-sm text-gray-600 mt-2">Hover over buttons to see tooltips (title) and inspect for aria-label attributes</p>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Focus State Demo</h3>
<p class="text-sm text-gray-600 mb-2">Tab through these buttons to see focus states:</p>
<div class="flex flex-wrap gap-3">
<% (@variants || BetterUi::ApplicationComponent::VARIANTS.keys).each do |variant| %>
<%= render BetterUi::ButtonComponent.new(variant: variant) do %>
<%= variant.to_s.capitalize %>
<% end %>
<% end %>
</div>
</div>
</div>
<script data-turbo-track="reload">
// Simple counter controller for demo
if (!window.Stimulus) {
console.warn('Stimulus not loaded for interactive demo');
} else {
class CounterController extends window.Stimulus.Controller {
static targets = ["count"]
connect() {
this.count = 0;
}
increment() {
this.count++;
if (this.hasCountTarget) {
this.countTarget.textContent = this.count;
}
}
}
if (window.Stimulus.application) {
try {
window.Stimulus.application.register("counter", CounterController);
} catch(e) {
// Controller might already be registered
}
}
}
</script>
<div data-controller="counter">
<!-- Counter context for demo -->
</div>