Add light theme default with toggle (#8)

Co-authored-by: Cursor <cursoragent@cursor.com>
Reviewed-on: #8
Co-authored-by: diaco <dyaco8464@yahoo.com>
Co-committed-by: diaco <dyaco8464@yahoo.com>
This commit was merged in pull request #8.
This commit is contained in:
2026-10-04 04:57:12 +00:00
committed by rhino
parent 0c1340cf3e
commit 273785c2e9
3 changed files with 83 additions and 19 deletions

View File

@@ -84,6 +84,22 @@ const translations = {
};
let currentLang = localStorage.getItem('slip_lang') || 'en';
let currentTheme = localStorage.getItem('slip_theme') || 'light';
function applyTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
const label = document.getElementById('theme-label');
if (label) {
// show the theme you'll switch to
label.textContent = theme === 'light' ? '🌙' : '☀️';
}
}
function toggleTheme() {
currentTheme = currentTheme === 'light' ? 'dark' : 'light';
localStorage.setItem('slip_theme', currentTheme);
applyTheme(currentTheme);
}
function applyLanguage(lang) {
document.documentElement.lang = lang;
@@ -130,5 +146,6 @@ function showToast(message, isError = false) {
// Initialize on load
document.addEventListener('DOMContentLoaded', () => {
applyTheme(currentTheme);
applyLanguage(currentLang);
});