Skip to content

Commit 4c5d289

Browse files
committed
refactor: comment changes
1 parent ea8d44e commit 4c5d289

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

resources/views/components/input/checkbox.blade.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,50 @@
44
'checked' => false,
55
])
66

7-
<div class="float-left flex flex-col gap-1">
8-
<!-- Label Text (Clickable) -->
7+
<div class="flex flex-col gap-1">
98

10-
<label
11-
for="{{ $name }}"
12-
class="cursor-pointer text-sm font-medium text-slate-50"
13-
>
9+
<x-input.label for="{{ $name }}">
1410
{{ $label }}
15-
</label>
11+
</x-input.label>
1612

17-
<!-- Hidden Checkbox Input (Starts Unchecked) -->
1813
<input
1914
type="checkbox"
2015
id="{{ $name }}"
2116
name="{{ $name }}"
22-
@if($checked) checked @endif
17+
:checked="$checked"
2318
class="peer hidden"
2419
/>
2520

26-
<!-- Custom Visual Checkbox -->
2721
<span
2822
tabindex="0"
2923
role="checkbox"
30-
aria-checked="{{ $checked ? 'true' : 'false' }}"
31-
class="h-6 w-6 cursor-pointer justify-center rounded border-2 border-slate-50 bg-indigo-400 peer-checked:border-indigo-400 peer-checked:bg-slate-50"
24+
:aria-checked="$checked"
25+
class="size-5 cursor-pointer justify-center rounded border-2 border-indigo-400 bg-slate-50 peer-checked:border-indigo-400 peer-checked:bg-indigo-400"
3226
onclick="toggleCheckbox('{{ $name }}')"
3327
onkeydown="handleKeyPress(event, '{{ $name }}')"
3428
>
35-
<x-lucide-check class="h-5 w-5 text-slate-50" />
29+
<x-lucide-check class="size-4 text-slate-50" />
3630
</span>
3731
</div>
3832

3933
<script>
4034
function toggleCheckbox(checkboxId) {
4135
const checkbox = document.getElementById(checkboxId)
42-
const visualCheckbox = checkbox.nextElementSibling // Get the <span>
36+
const visualCheckbox = checkbox.nextElementSibling
4337
44-
checkbox.checked = !checkbox.checked // Toggle checkbox state
38+
checkbox.checked = !checkbox.checked
4539
visualCheckbox.setAttribute(
4640
'aria-checked',
4741
checkbox.checked ? 'true' : 'false',
48-
) // Update aria-checked
49-
checkbox.dispatchEvent(new Event('change')) // Fire change event for Livewire/Vue if needed
42+
)
5043
}
5144
5245
function handleKeyPress(event, checkboxId) {
5346
if (event.key === 'Enter' || event.key === ' ') {
54-
event.preventDefault() // Prevent scrolling on Space key
47+
event.preventDefault()
5548
toggleCheckbox(checkboxId)
5649
}
5750
}
5851
</script>
52+
53+
</div>

resources/views/home.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ class="w-40"
8080
class="w-40"
8181
/>
8282
</div>
83+
<x-input.checkbox name="admin" label="Is admin:" checked="false" />
8384
</x-layout>

0 commit comments

Comments
 (0)