Code Monkey home page Code Monkey logo

Comments (5)

Nemo157 avatar Nemo157 commented on August 21, 2024

The default theme only works on first page load, once any other docs have been loaded and stored their preference into local storage it will not be used. (It does also appear to be buggy, if you clear local storage then load that page no theme at all is used, but given that's a situation that essentially never happens I don't see any reason to fix it).

from docs.rs.

lexi-the-cute avatar lexi-the-cute commented on August 21, 2024

I was hoping to make sure the correct theme was chosen for people loading it for the first time. It's kind of the reason why I set the default theme. To make it look nicer and not completely blind people on the first load (I absolutely hate light themes cause of the problems it causes me)

from docs.rs.

syphar avatar syphar commented on August 21, 2024

The default theme only works on first page load, once any other docs have been loaded and stored their preference into local storage it will not be used. (It does also appear to be buggy, if you clear local storage then load that page no theme at all is used, but given that's a situation that essentially never happens I don't see any reason to fix it).

So the setting is a user setting and will be used for all of docs.rs then? Or do we have some potential optimization here?

from docs.rs.

lexi-the-cute avatar lexi-the-cute commented on August 21, 2024

The default theme only works on first page load, once any other docs have been loaded and stored their preference into local storage it will not be used. (It does also appear to be buggy, if you clear local storage then load that page no theme at all is used, but given that's a situation that essentially never happens I don't see any reason to fix it).

So the setting is a user setting and will be used for all of docs.rs then? Or do we have some potential optimization here?

From my understanding, the default theme only applies if the user hasn't set one yet and the user setting applies site-wide

from docs.rs.

Nemo157 avatar Nemo157 commented on August 21, 2024

The default theme only applies if the user has never visited a page, as soon as a page (that doesn't have a default-theme) is visited the settings are stored into local storage and apply site-wide. Docs.rs' theming (of the topbar and the crates pages) also relies on the settings being stored into local storage, so don't work with a default theme.

I have identified why it's not applying any styling though, rustdoc has migrated to using <body data-theme="ayu"> at some point instead of loading separate css files, which is what docs.rs has been using too, so because the default theme doesn't get stored into local storage we override that with data-theme="null". I can fix that so at least we don't cause issues with conflicting with rustdoc (e.g. for defaults like this, or more usefully if the default theme-set changes we don't break theming till we update our set too).

from docs.rs.

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.