Skip to content

Commit 2b1593f

Browse files
committed
better loading button
1 parent 91e29da commit 2b1593f

File tree

5 files changed

+59
-27
lines changed

5 files changed

+59
-27
lines changed

resources/css/components/button.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
active:outline-2
77
has-focus-visible:outline-2;
88

9+
&[data-loading],
10+
&[loading],
11+
&.el-loading {
12+
@apply pointer-events-none;
13+
}
14+
15+
& .el-loader {
16+
@apply hidden absolute left-0 top-0 gap-2 h-full w-full items-center justify-center;
17+
border-radius: inherit;
18+
background: inherit;
19+
}
20+
21+
&[data-loading] .el-loader,
22+
&[loading] .el-loader,
23+
&.el-loading .el-loader {
24+
@apply flex;
25+
}
26+
927
& input {
1028
@apply pointer-events-none absolute left-0 top-0 size-full appearance-none opacity-0;
1129
}

resources/css/components/shared.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,47 +174,47 @@
174174
}
175175
&[data-color="sky-light"],
176176
&.el-color-sky-light {
177-
@apply ring-sky-500;
177+
@apply ring-sky-200;
178178
}
179179
&[data-color="emerald"],
180180
&.el-color-emerald {
181181
@apply ring-emerald-600;
182182
}
183183
&[data-color="emerald-light"],
184184
&.el-color-emerald-light {
185-
@apply ring-emerald-500;
185+
@apply ring-emerald-200;
186186
}
187187
&[data-color="rose"],
188188
&.el-color-rose {
189189
@apply ring-rose-600;
190190
}
191191
&[data-color="rose-light"],
192192
&.el-color-rose-light {
193-
@apply ring-rose-500;
193+
@apply ring-rose-200;
194194
}
195195
&[data-color="purple"],
196196
&.el-color-purple {
197197
@apply ring-purple-600;
198198
}
199199
&[data-color="purple-light"],
200200
&.el-color-purple-light {
201-
@apply ring-purple-500;
201+
@apply ring-purple-200;
202202
}
203203
&[data-color="yellow"],
204204
&.el-color-yellow {
205205
@apply ring-yellow-600;
206206
}
207207
&[data-color="yellow-light"],
208208
&.el-color-yellow-light {
209-
@apply ring-yellow-500;
209+
@apply ring-yellow-200;
210210
}
211211
&[data-color="amber"],
212212
&.el-color-amber {
213213
@apply ring-amber-600;
214214
}
215215
&[data-color="amber-light"],
216216
&.el-color-amber-light {
217-
@apply ring-amber-500;
217+
@apply ring-amber-200;
218218
}
219219
&[data-color="glass"],
220220
&.el-color-glass {

resources/views/components/button/index.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'content' => null,
88
'offset' => true,
99
'loader' => null,
10-
'loading' => false,
1110
'badge' => null,
1211
'before' => null,
1312
'input' => null,
@@ -24,7 +23,7 @@
2423
$target,
2524
fn($a) => $a->merge([
2625
'wire:loading.attr' => 'disabled',
27-
'wire:loading.class' => 'pointer-events-none',
26+
'wire:loading.class' => 'el-loading',
2827
]),
2928
)" :size="$size" :color-checked="$_colorChecked" :tag="$_tag">
3029
{!! $before !!}
@@ -69,10 +68,11 @@
6968
<x-kit::button.icon :icon="$iconRight" :offset="$offset" :size="$size" :attributes="$iconAttributes" />
7069
@endif
7170

72-
@if ($target || $loading)
73-
<x-kit::button.loader :loading="$loading"
74-
wire:target="{{ $target }}">{{ $loader }}</x-kit::buttons.loader>
75-
@endif
71+
<span class="el-loader">
72+
<span
73+
class="animate-spin-loader size-4 rounded-full border-2 border-current border-r-transparent border-t-transparent"></span>
74+
{{ $loader }}
75+
</span>
7676

7777
{!! $after !!}
7878
</x-kit::button.base>

resources/views/components/button/loader.blade.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

workbench/resources/views/demo.blade.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,39 @@
3434
<div class="p-3">
3535
<h1 class="font-semibold">Button</h1>
3636
</div>
37-
<div class="flex grow items-center justify-center border-b border-gray-200">
37+
<div class="flex grow items-center justify-center gap-2 border-b border-gray-200">
3838
<x-kit::button color="rose" class="rounded-md ring-1 ring-inset">
3939
Button
40-
41-
<x-slot:icon>
40+
<x-slot:icon-right>
4241
<iconify-icon icon="heroicons:check"></iconify-icon>
43-
</x-slot:icon>
42+
</x-slot:icon-right>
43+
</x-kit::button>
44+
45+
<x-kit::button color="rose-light" class="rounded-md ring-1 ring-inset">
46+
Button
47+
</x-kit::button>
48+
49+
</div>
50+
</div>
51+
52+
<div class="isolate flex flex-col">
53+
<div class="p-3">
54+
<h1 class="font-semibold">Loading button</h1>
55+
</div>
56+
<div class="flex grow items-center justify-center gap-2 border-b border-gray-200">
57+
58+
<x-kit::button color="white" class="rounded-md ring-1 ring-inset" data-loading>
59+
Button
4460
</x-kit::button>
61+
62+
<x-kit::button color="sky-light" class="el-loading rounded-md ring-1 ring-inset">
63+
Button
64+
</x-kit::button>
65+
66+
<x-kit::button color="sky-light" class="rounded-md ring-1 ring-inset" loading>
67+
Button
68+
</x-kit::button>
69+
4570
</div>
4671
</div>
4772

0 commit comments

Comments
 (0)