Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

Commit e7bb8c7

Browse files
committed
fix: pure CSS custom checkboxes with appearance:none and :checked
1 parent f41ba1e commit e7bb8c7

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

public/js/admin.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,10 +1384,10 @@ async function showAddNestsModal() {
13841384
if (!content || !overlay) return;
13851385

13861386
if (!$a('#custom-checkbox-style')) {
1387-
const style = document.createElement('style');
1388-
style.id = 'custom-checkbox-style';
1389-
style.textContent = '.custom-checkbox-label.checked .custom-checkbox-ui { background: var(--accent-1); border-color: var(--accent-1); } .custom-checkbox-label.checked .custom-checkbox-ui .custom-checkbox-check { display: block; }';
1390-
document.head.appendChild(style);
1387+
const s = document.createElement('style');
1388+
s.id = 'custom-checkbox-style';
1389+
s.textContent = '.add-nest-checkbox { width:20px;height:20px;border:2px solid var(--text-secondary);border-radius:4px;flex-shrink:0;cursor:pointer;appearance:none;-webkit-appearance:none;background:transparent;transition:var(--transition);position:relative } .add-nest-checkbox:checked { background:var(--accent-1);border-color:var(--accent-1) } .add-nest-checkbox:checked::after { content:""; position:absolute; top:3px;left:6px; width:5px;height:9px; border:solid var(--bg-primary); border-width:0 2px 2px 0; transform:rotate(45deg) }';
1390+
document.head.appendChild(s);
13911391
}
13921392

13931393
content.innerHTML = '<div style="text-align:center;padding:24px"><span class="spinner"></span> Loading available nests...</div>';
@@ -1412,11 +1412,8 @@ async function showAddNestsModal() {
14121412
<p style="color:var(--text-secondary);font-size:0.85rem;margin-bottom:16px">Select nests from the panel to make them available:</p>
14131413
<div id="add-nests-list" style="max-height:300px;overflow-y:auto;margin-bottom:16px">
14141414
${data.nests.map(n => ahtml`
1415-
<label style="display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--border);cursor:pointer" class="custom-checkbox-label" data-id="${n.id}">
1416-
<input type="checkbox" class="add-nest-checkbox" value="${n.id}" data-name="${n.name}" style="display:none" />
1417-
<span class="custom-checkbox-ui" style="width:20px;height:20px;border:2px solid var(--text-secondary);border-radius:4px;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:var(--transition);background:transparent">
1418-
<svg class="custom-checkbox-check" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--bg-primary)" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" style="display:none"><polyline points="20 6 9 17 4 12"/></svg>
1419-
</span>
1415+
<label style="display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--border);cursor:pointer">
1416+
<input type="checkbox" class="add-nest-checkbox" value="${n.id}" data-name="${n.name}" />
14201417
<span><strong>${n.name}</strong> <span style="color:var(--text-secondary);font-size:0.82rem">(ID: ${n.id})</span></span>
14211418
</label>
14221419
`).join('')}
@@ -1429,16 +1426,6 @@ async function showAddNestsModal() {
14291426
</div>
14301427
`;
14311428

1432-
document.querySelectorAll('.custom-checkbox-label').forEach(label => {
1433-
label.addEventListener('click', (e) => {
1434-
e.preventDefault();
1435-
const cb = label.querySelector('.add-nest-checkbox');
1436-
if (!cb) return;
1437-
cb.checked = !cb.checked;
1438-
label.classList.toggle('checked', cb.checked);
1439-
});
1440-
});
1441-
14421429
$a('#btn-confirm-add-nests')?.addEventListener('click', async () => {
14431430
const checked = document.querySelectorAll('.add-nest-checkbox:checked');
14441431
if (checked.length === 0) {

0 commit comments

Comments
 (0)