사이드바 너비, 카드 크기 정보 저장, 앱 실행시 적용 + 개발 모드 실행시 로그 출력

This commit is contained in:
2026-05-18 11:14:10 +09:00
parent d74c2e055d
commit 0ef8a28d54
16 changed files with 234 additions and 44 deletions
+3 -3
View File
@@ -94,12 +94,12 @@ function nodeIcon(nodeEl) {
return nodeEl.dataset.isRoot === 'true' ? ICON_HOME : ICON_OPEN;
}
function selectNode(nodeEl) {
function selectNode(nodeEl, { notify = true } = {}) {
const path = nodeEl.dataset.path;
document.querySelectorAll('.tree-row.active').forEach(r => r.classList.remove('active'));
nodeEl.querySelector(':scope > .tree-row').classList.add('active');
_selectedPath = path;
if (_onSelect) _onSelect(path);
if (notify && _onSelect) _onSelect(path);
}
function collapseNode(nodeEl) {
@@ -149,7 +149,7 @@ async function expandNode(nodeEl, autoExpandPath) {
// Reached the target — select it
if (autoExpandPath === nodeEl.dataset.path) {
selectNode(nodeEl);
selectNode(nodeEl, { notify: false });
}
}
+14 -3
View File
@@ -2,11 +2,15 @@ const THUMB_MIN = 150;
const THUMB_MAX = 400;
let _thumbSizeHint;
let _onChange = null;
let thumbSize = 250;
let thumbHintTimer = null;
let saveTimer = null;
export function init({ gridContainer, thumbSizeHint }) {
export function init({ gridContainer, thumbSizeHint, initialSize, onChange }) {
_thumbSizeHint = thumbSizeHint;
_onChange = onChange;
if (initialSize) setThumbSize(initialSize, { showHint: false, notify: false });
gridContainer.addEventListener('wheel', (e) => {
if (!e.ctrlKey) return;
@@ -15,10 +19,11 @@ export function init({ gridContainer, thumbSizeHint }) {
}, { passive: false });
}
export function setThumbSize(size) {
export function setThumbSize(size, { showHint = true, notify = true } = {}) {
thumbSize = Math.round(Math.max(THUMB_MIN, Math.min(THUMB_MAX, size)));
document.documentElement.style.setProperty('--thumb-size', thumbSize + 'px');
_showHint(thumbSize);
if (showHint) _showHint(thumbSize);
if (notify) _scheduleSave(thumbSize);
}
function _showHint(size) {
@@ -27,3 +32,9 @@ function _showHint(size) {
clearTimeout(thumbHintTimer);
thumbHintTimer = setTimeout(() => _thumbSizeHint.classList.remove('show'), 1000);
}
function _scheduleSave(size) {
if (!_onChange) return;
clearTimeout(saveTimer);
saveTimer = setTimeout(() => _onChange(size), 250);
}