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:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user