dracula / dracula/wolfram-notebooks

Add button toggle for light/dark mode

Open
#1 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Mathematica
Stars
38
Forks
12
PR merge metrics
No merged PRs in 30d

Description

I want to add a docked cell in the stylesheet definition that will toggle between "Dracula.nb" and "Default.nb" as the style definitions for a notebook.

Default.nb doesn't contain a definition for a toggle, so as soon as you toggle in a notebook with a Dracula theme, it will disappear. So, how I see it working, is that a separate stylesheet that inherits from Default.nb will be used...What I'm not sure about is if

1. users will need to have a new "Default-2.nb" stylesheet installed or if

2. the Notebook expression that contains the new stylesheet can be iconized and stored somewhere hidden like within the docked cell

The docked cell will need to be added to the notebook style definition, if at all

Other things to consider:

- a docked cell with just a toggle button is weird at best, annoying at worst. It will need to contain some other things
- is this something that would even be useful for other people 🤣

Basic prototype:
```
ex1 = Button[ "Toggle Light/Dark Mode",
Module[{nb, dark, light, current},
nb = EvaluationNotebook[];
dark = "Dracula.nb";
light = "Default.nb";
current = StyleDefinitions -> "Dracula.nb";

If[
First@Options[nb, StyleDefinitions] === current,
SetOptions[nb, StyleDefinitions -> light],
SetOptions[nb, StyleDefinitions -> dark]
]
]];

CreateWindow[DockedCells -> Cell[BoxData[ToBoxes[ex1]], "DockedCell"]]
```

---

If anyone has any thoughts, please comment below.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.