Coder Social home page Coder Social logo

giscus dark mode about angular-challenges HOT 7 OPEN

tomalaforge avatar tomalaforge commented on May 23, 2024
giscus dark mode

from angular-challenges.

Comments (7)

jdegand avatar jdegand commented on May 23, 2024 1

Giscus has a bug and is down for next few days.

from angular-challenges.

jdegand avatar jdegand commented on May 23, 2024
export class L extends HTMLElement {
    #e = "starlight-theme";
    constructor() {
        super(), this.#n(this.#o());
        const e = this.querySelector("select");
        e && e.addEventListener("change", n => {
            n.currentTarget instanceof HTMLSelectElement && this.#n(this.#t(n.currentTarget.value))
        })
    }
    #t(e) {
        return e === "auto" || e === "dark" || e === "light" ? e : "auto"
    }
    #s() {
        return matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark"
    }
    #n(e) {
        StarlightThemeProvider.updatePickers(e), document.documentElement.dataset.theme = e === "auto" ? this.#s() : e, this.#r(e)
    }
    #r(e) {
        typeof localStorage < "u" && (e === "light" || e === "dark" ? localStorage.setItem(this.#e, e) : localStorage.removeItem(this.#e))
    }
    #o() {
        const e = typeof localStorage < "u" && localStorage.getItem(this.#e);
        return this.#t(e)
    }
}

I used the web components extension and this nested ternary is used for the select.

document.documentElement.dataset.theme = e === "auto" ? this.#s() : e, this.#r(e)

Does this look right to you?

from angular-challenges.

tomalaforge avatar tomalaforge commented on May 23, 2024

I've never used web component, but if it does the job, it's right for me.

from angular-challenges.

jdegand avatar jdegand commented on May 23, 2024

I'm thinking now that there maybe a conditional logic error. The issue mentioned attribute binding but the error still occurs when both attributes are correct.

This issue is worth looking at as well.

from angular-challenges.

tomalaforge avatar tomalaforge commented on May 23, 2024

yes indeed, the change is not done automatically. I need to look at it more closely when I have more time. Or if you want to do it, don't hesitate 😅

from angular-challenges.

github-actions avatar github-actions commented on May 23, 2024

This issue is stale because it has been open for 20 days with no activity.

from angular-challenges.

github-actions avatar github-actions commented on May 23, 2024

This issue is stale because it has been open for 20 days with no activity.

from angular-challenges.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.