[260112]
- 모드 전환 기능 - 솔라리스 모드 추가
This commit is contained in:
50
script.js
50
script.js
@@ -92,18 +92,52 @@ document.querySelectorAll('.card').forEach((card, cardIndex) => {
|
||||
});
|
||||
});
|
||||
|
||||
// 1. 사용할 테마 리스트
|
||||
const themes = ['semi-nova', 'nova', 'semi-solaris', 'solaris'];
|
||||
const STORAGE_KEY = 'selected-theme';
|
||||
|
||||
// 2. 초기 로드 시 테마 적용 (기본값: semi-nova)
|
||||
const savedTheme = localStorage.getItem(STORAGE_KEY) || themes[0];
|
||||
document.body.classList.add(savedTheme);
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
// OS별 수정 키 판별 (Mac: Command, Win: Control)
|
||||
const isMac = navigator.platform.toUpperCase().includes('MAC');
|
||||
const isModifierPressed = isMac ? e.metaKey : e.ctrlKey;
|
||||
|
||||
// 방향키 좌/우 확인
|
||||
const isLeft = e.code === 'ArrowLeft';
|
||||
const isRight = e.code === 'ArrowRight';
|
||||
|
||||
if (
|
||||
isMac &&
|
||||
e.metaKey &&
|
||||
e.shiftKey &&
|
||||
e.code === 'KeyD' &&
|
||||
!['INPUT', 'TEXTAREA'].includes(document.activeElement?.tagName)
|
||||
isModifierPressed &&
|
||||
(isLeft || isRight) &&
|
||||
// 입력창 안에서 커서 이동을 방해하지 않도록 체크
|
||||
!['INPUT', 'TEXTAREA'].includes(document.activeElement?.tagName) &&
|
||||
!document.activeElement?.isContentEditable // 에디터 영역 대응
|
||||
) {
|
||||
e.preventDefault();
|
||||
document.body.classList.toggle('is-nova');
|
||||
}
|
||||
});
|
||||
|
||||
// 현재 인덱스 찾기
|
||||
let currentIndex = themes.findIndex(t => document.body.classList.contains(t));
|
||||
if (currentIndex === -1) currentIndex = 0;
|
||||
|
||||
// 3. 좌/우 방향에 따른 인덱스 순환
|
||||
if (isRight) {
|
||||
// 오른쪽 화살표: 다음 테마
|
||||
currentIndex = (currentIndex + 1) % themes.length;
|
||||
} else if (isLeft) {
|
||||
// 왼쪽 화살표: 이전 테마
|
||||
currentIndex = (currentIndex - 1 + themes.length) % themes.length;
|
||||
}
|
||||
|
||||
const nextTheme = themes[currentIndex];
|
||||
|
||||
// 4. 클래스 교체 및 저장
|
||||
themes.forEach(t => document.body.classList.remove(t));
|
||||
document.body.classList.add(nextTheme);
|
||||
localStorage.setItem(STORAGE_KEY, nextTheme);
|
||||
|
||||
console.log(`Current Theme: ${nextTheme}`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user