Sha256: 54d448434b3a7aeae22d0113f25100086ac6e3cc3224c78e0b80109dd90fc615

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

import BrandsModel from './BrandsModel.js';
import BrandsView from './BrandsView.js';
import BrandsController from './BrandsController.js';

const modeToggle = document.getElementById('modeToggle');
const body = document.body;
const icon = modeToggle.querySelector('i');

function applyMode(mode) {
    if (mode === 'dark') {
        body.classList.add('dark-mode');
        icon.classList.remove('fa-sun');
        icon.classList.add('fa-moon');
    } else {
        body.classList.remove('dark-mode');
        icon.classList.remove('fa-moon');
        icon.classList.add('fa-sun');
    }
}

const savedMode = localStorage.getItem('mode');
if (savedMode) {
    applyMode(savedMode);
} else {
    const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
    applyMode(systemPrefersDark ? 'dark' : 'light');
}

modeToggle.addEventListener('click', () => {
    const currentMode = body.classList.contains('dark-mode') ? 'dark' : 'light';
    const newMode = currentMode === 'dark' ? 'light' : 'dark';
    applyMode(newMode);
    localStorage.setItem('mode', newMode);
});

document.addEventListener('DOMContentLoaded', async () => {
    const model = new BrandsModel();
    const view = new BrandsView(model.source);
    const controller = new BrandsController(model, view);
    await controller.init();
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/dashboard/brands/Brands.js
solara-0.7.3 solara/lib/core/dashboard/brands/Brands.js
solara-0.7.2 solara/lib/core/dashboard/brands/Brands.js
solara-0.7.1 solara/lib/core/dashboard/brands/Brands.js
solara-0.7.0 solara/lib/core/dashboard/brands/Brands.js
solara-0.6.0 solara/lib/core/dashboard/brands/Brands.js
solara-0.5.0 solara/lib/core/dashboard/brands/Brands.js