Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle Logo Sidebar by theme #297

Closed
mocfaisal opened this issue Jun 24, 2024 · 2 comments
Closed

Toggle Logo Sidebar by theme #297

mocfaisal opened this issue Jun 24, 2024 · 2 comments

Comments

@mocfaisal
Copy link
Contributor

Hi,
Can you add a switch logo when changing themes

i already made one of my versions, but it could be better by just changing the attributes for the 2 logo modes (light, dark).

My code :

const toggler = document.getElementById("toggle-dark")

// Function for toggling logo when theme mode changed
function toggleTheme() {
    let currTheme = document.documentElement.getAttribute("data-bs-theme");

    // NOTE Add Condition to change logo
    let logo_path = '/static/images/logo/';
    let currLogo = app_asset_url + logo_path + "/logo.png";

    if (currTheme !== "dark") {
        // Dark Mode
        currLogo = app_asset_url + logo_path + "/logo2.png";
    } else {
        // Light Mode
        currLogo = app_asset_url + logo_path + "/logo.png";
    }

    document.getElementById("logo_img").setAttribute('src', currLogo);
}

if (toggler) {
    toggler.checked = theme === "dark"

    toggler.removeEventListener("input", toggleTheme);

    toggler.addEventListener("input", toggleTheme);
}
@mocfaisal mocfaisal changed the title Toggle Logo by theme Toggle Logo Sidebar by theme Jun 25, 2024
@alfianchii
Copy link
Collaborator

WDYT @zuramai

@zuramai
Copy link
Owner

zuramai commented Jul 2, 2024

Hi, this is a great additionial feature. But for the starter template, we only need one logo unaffected by the dark/light mode. You can implement it into your own application.

@zuramai zuramai closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants