Pocket-titan / DarkMode

Dark mode for Pluto ๐ŸŽ‰

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can I make it as a default case where I dont require to enable dark theme again after opening a new notebook?

nehamsoni opened this issue ยท comments

+1 on this. I tried putting it in my startup.jl file and apparently Pluto doesn't use that. So then I tried putting an include("...startup.jl") statement at the top of my notebook, and for some reason that doesn't work either. I have to manually put a separate using DarkMode; DarkMode.enable() in addition to my include("...startup.jl") line (which has my other defaults like plot backends and themes).

I can't think of a way to do this without modifying the Julia codebase, which will just get overwritten the next time you update Pluto. So until we have either 1) native support for dark mode or 2) a way to provide a notebook "template" from which your new notebooks are created (a sort of startup.jl but for html/css/js) (basically notebooks within notebooks), you'll have to just make a cell with using DarkMode; DarkMode.enable() in every notebook. But If you manage to get arthritis from repeatedly having to type this single line, I'll happily pay your medical bills ๐Ÿ˜› (I won't, don't sue me)

@jonniedie The reason why that doesn't work is because cells returning an html object have their output inserted into the page by Pluto. However, if you execute html" ... " in a regular Julia process (which is basically what include'ing a file does), you will just have created an unnamed html object. You'll still have to somehow get that html into the page, by getting a cell to return it - you could, for example, have very_cool_html = html"..." in your startup.jl, include("...startup.jl"), and then write very_cool_html in an empty cell & evaluate it. Now, that cell will return that html, and Pluto can do its thing & render it into the page. But you'll still have to write roughly the same amount of characters, so no cigar ๐Ÿค•

By the way, @jonniedie, do you think it's a good idea to also set a default dark theme for Plots in this package? You'll still be able to overwrite it, but this way those that don't know how/want to change it can still have the experience of a "grand unified theme" (like this but for themes - I was first btw they stole my acronym). If you do think it's a good idea, mind sending/linking me some code (maybe from your startup.jl that accomplishes this? I am still a rookie at Julia ๐Ÿ™ƒ

Thanks for the tip with the html"..." thing, I'll give it a try.

I think it would be great to have unified themes for these. Unfortunately I'm having to do some Requires.jl workarounds to get themes set automatically in my startup.jl file and that's not ideal as a common solution for a lot of reasons. The way things are supposed to work is you're supposed to be able to set const PLOTS_DEFAULTS = Dict(:theme => :your_theme_name) in your startup.jl file and Plots.jl will use that, but it doesn't seem to be working for the latest versions (also, I don't think that is a good way to do it; this kind of stuff should be handled with ENV entries). I mentioned it here, but I should open up a real issue as well.

With all that said, I also opened an issues with Pluto.jl here about allowing templates for Pluto so you could open a template with the startup cells already pre-populated. I think doing it this way would allow for this kind of thing while remaining within the fully reproducible model that Pluto aims for.

I ended up making an issue for the Plots.jl part. But if the Pluto templates thing happens, that should fix it without having to wait for the Plots one to happen.