Giter VIP home page Giter VIP logo

Comments (5)

kinglouie avatar kinglouie commented on June 19, 2024

I put the localstorage theme code first thing in the body tag. Works flawlessly without flash of wrong theme.

Example: https://github.com/sveltejs/svelte/blob/main/sites/svelte.dev/src/app.html

from skeleton.

Hugos68 avatar Hugos68 commented on June 19, 2024

Hey @kinglouie Thanks for the comment but like I said, though it happens so quickly on smaller sites, if your site is reasonably large and you will load the body first you might notice a flash of unstyled/wrongly styled content. I think we can both agree determining the style before the body tag is even loaded would be optimal.

from skeleton.

endigo9740 avatar endigo9740 commented on June 19, 2024

My concern with this isn't so much a technical one, but one of education. Users will need to be informed that we diverge from Tailwind's recommend here. All their examples show the .dark class appended to the HTML element. Their toggle code shows changing this.

https://tailwindcss.com/docs/dark-mode#supporting-system-preference-and-manual-selection

from skeleton.

Hugos68 avatar Hugos68 commented on June 19, 2024

My concern with this isn't so much a technical one, but one of education. Users will need to be informed that we diverge from Tailwind's recommend here. All their examples show the .dark class appended to the HTML element. Their toggle code shows changing this.

https://tailwindcss.com/docs/dark-mode#supporting-system-preference-and-manual-selection

Isn't is the opposite in this case? Instead of the user defining theme and mode in different places they both are applied to the HTML element. The only confusing part is that Skeleton calls dark/light "mode" and Tailwind calls this "theme". (IMO Tailwind is in the wrong here, but whatever)

from skeleton.

endigo9740 avatar endigo9740 commented on June 19, 2024

The value of theme is just what they use as their localstorage key in the example. It's poor semantics on their part!

But what I'm referring to is this:

document.documentElement.classList.add('dark')

This modifies the <html> tag, not the <body>.

I bring this up as folks that are familiar with Tailwind may be used to setting/adjusting this value on the <html> element, per the official Tailwind docs recommending this approach. We can inform folks that we differ from the Tailwind norm here, but just stating the obvious that this may trip up some folks and cause some support issues :)

from skeleton.

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.