|
433 | 433 | <p class="dotfiles-hint">Cloned & deployed via GNU Stow after install.</p> |
434 | 434 | </div> |
435 | 435 |
|
436 | | - <div class="system-prefs"> |
437 | | - <div class="prefs-top"> |
438 | | - <span class="prefs-title">macOS Preferences</span> |
439 | | - {#if macosPrefs.length > 0} |
440 | | - <span class="prefs-count">{macosPrefs.length} configured</span> |
441 | | - {/if} |
442 | | - </div> |
443 | | - |
444 | | - <!-- Accordion groups by category --> |
445 | | - <div class="pref-accordion"> |
446 | | - {#each CATALOG_CATEGORIES as cat} |
447 | | - {@const items = catalogByCategory[cat]} |
448 | | - {@const count = addedCountByCategory[cat] || 0} |
449 | | - {@const total = items.length} |
450 | | - {@const expanded = expandedPrefCats.has(cat)} |
451 | | - <div class="pref-acc-group" class:pref-acc-has-items={count > 0}> |
452 | | - <button class="pref-acc-header" onclick={() => togglePrefCat(cat)}> |
453 | | - <svg class="pref-acc-chevron" class:pref-acc-chevron-open={expanded} width="12" height="12" viewBox="0 0 12 12"><path d="M4 2l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg> |
454 | | - <span class="pref-acc-name">{cat}</span> |
455 | | - {#if count > 0} |
456 | | - <span class="pref-acc-badge">{count}/{total}</span> |
457 | | - {:else} |
458 | | - <span class="pref-acc-total">{total}</span> |
459 | | - {/if} |
460 | | - </button> |
461 | | - {#if expanded} |
462 | | - <div class="pref-acc-body"> |
463 | | - {#each items as item} |
464 | | - {@const added = isPrefAdded(item)} |
465 | | - {@const prefIdx = getAddedPrefIndex(item)} |
466 | | - <div class="pref-row" class:pref-row-active={added}> |
467 | | - <button |
468 | | - class="pref-toggle-btn" |
469 | | - onclick={() => addPrefFromCatalog(item)} |
470 | | - > |
471 | | - <span class="pref-check" class:pref-check-on={added}>{added ? '✓' : ''}</span> |
472 | | - </button> |
473 | | - <div class="pref-info"> |
474 | | - <span class="pref-label">{item.label}</span> |
475 | | - <span class="pref-meta">{item.description}</span> |
476 | | - </div> |
477 | | - {#if added && prefIdx >= 0} |
478 | | - <div class="pref-control"> |
479 | | - {#if item.options} |
480 | | - <select |
481 | | - class="pref-sel" |
482 | | - value={macosPrefs[prefIdx].value} |
483 | | - onchange={(e) => updatePrefValue(prefIdx, e.currentTarget.value)} |
484 | | - > |
485 | | - {#each item.options as opt} |
486 | | - <option value={opt.value}>{opt.label}</option> |
487 | | - {/each} |
488 | | - </select> |
489 | | - {:else if item.type === 'bool'} |
490 | | - <button |
491 | | - class="pref-bool" |
492 | | - class:on={macosPrefs[prefIdx].value === 'true'} |
493 | | - onclick={() => updatePrefValue(prefIdx, macosPrefs[prefIdx].value === 'true' ? 'false' : 'true')} |
494 | | - > |
495 | | - {macosPrefs[prefIdx].value === 'true' ? 'ON' : 'OFF'} |
496 | | - </button> |
497 | | - {:else} |
498 | | - <input |
499 | | - type={(item.type === 'int' || item.type === 'float') ? 'number' : 'text'} |
500 | | - class="pref-val" |
501 | | - value={macosPrefs[prefIdx].value} |
502 | | - min={item.min} |
503 | | - max={item.max} |
504 | | - oninput={(e) => updatePrefValue(prefIdx, e.currentTarget.value)} |
505 | | - /> |
506 | | - {/if} |
507 | | - </div> |
508 | | - {/if} |
509 | | - </div> |
510 | | - {/each} |
511 | | - </div> |
512 | | - {/if} |
513 | | - </div> |
514 | | - {/each} |
515 | | - </div> |
516 | | - |
517 | | - <!-- Custom prefs not in catalog --> |
518 | | - {#if customPrefs.length > 0} |
519 | | - <div class="pref-acc-group pref-acc-has-items"> |
520 | | - <div class="pref-acc-header pref-acc-header-static"> |
521 | | - <span class="pref-acc-name">Custom</span> |
522 | | - <span class="pref-acc-badge">{customPrefs.length}</span> |
523 | | - </div> |
524 | | - <div class="pref-acc-body"> |
525 | | - {#each customPrefs as { pref, index }} |
526 | | - <div class="pref-row pref-row-active"> |
527 | | - <button class="pref-toggle-btn" onclick={() => removePref(index)}> |
528 | | - <span class="pref-check pref-check-on">✓</span> |
529 | | - </button> |
530 | | - <div class="pref-info"> |
531 | | - <span class="pref-label">{pref.domain}.{pref.key}</span> |
532 | | - {#if pref.desc} |
533 | | - <span class="pref-meta">{pref.desc}</span> |
534 | | - {/if} |
535 | | - </div> |
536 | | - <div class="pref-control"> |
537 | | - <input |
538 | | - type="text" |
539 | | - class="pref-val" |
540 | | - value={pref.value} |
541 | | - oninput={(e) => updatePrefValue(index, e.currentTarget.value)} |
542 | | - /> |
543 | | - </div> |
544 | | - <button class="pref-rm" onclick={() => removePref(index)}>×</button> |
545 | | - </div> |
546 | | - {/each} |
547 | | - </div> |
548 | | - </div> |
549 | | - {/if} |
550 | | - |
551 | | - <button |
552 | | - class="custom-pref-toggle" |
553 | | - onclick={() => (showCustomPref = !showCustomPref)} |
554 | | - > |
555 | | - {showCustomPref ? '− Hide' : '+ Custom defaults key'} |
556 | | - </button> |
557 | | - {#if showCustomPref} |
558 | | - <div class="custom-pref-row"> |
559 | | - <input |
560 | | - type="text" |
561 | | - class="custom-pref-input" |
562 | | - bind:value={prefInput} |
563 | | - placeholder="com.apple.dock.tilesize=48" |
564 | | - onkeydown={(e) => e.key === 'Enter' && (e.preventDefault(), addPref())} |
565 | | - /> |
566 | | - <select class="custom-pref-type" bind:value={prefTypeInput}> |
567 | | - <option value="">auto</option> |
568 | | - <option value="string">string</option> |
569 | | - <option value="int">int</option> |
570 | | - <option value="bool">bool</option> |
571 | | - <option value="float">float</option> |
572 | | - </select> |
573 | | - <button class="custom-pref-add" onclick={addPref}>Add</button> |
574 | | - </div> |
575 | | - {#if prefInputError} |
576 | | - <p class="pref-error">{prefInputError}</p> |
577 | | - {:else} |
578 | | - <p class="pref-hint">Format: domain.key=value</p> |
579 | | - {/if} |
580 | | - {/if} |
581 | | - </div> |
| 436 | + <MacOSPreferencesEditor |
| 437 | + bind:macosPrefs |
| 438 | + bind:expandedPrefCats |
| 439 | + {catalogByCategory} |
| 440 | + {addedCountByCategory} |
| 441 | + {customPrefs} |
| 442 | + /> |
582 | 443 | </section> |
583 | 444 |
|
584 | 445 | <!-- SCRIPT --> |
|
0 commit comments