1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-13 13:29:56 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/features/DarkLightChangeActions.tid

39 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-11-01 12:46:09 +00:00
created: 20231101120147664
2023-11-01 18:09:16 +00:00
modified: 20231101180843245
2023-11-01 12:46:09 +00:00
tags: Features
title: DarkLightChangeActions
type: text/vnd.tiddlywiki
<<.from-version "5.3.2">> Actions tagged <<tag "$:/tags/DarkLightChangeActions">> are executed whenever the browser or OS dark / light setting is changed.
2023-11-01 18:07:12 +00:00
<<.tip """Be aware that the browser setting can be independent from the OS setting.<br>
2023-11-01 12:46:09 +00:00
If the browser settings are set to "System theme - auto" for ~FireFox or "System default" for Chrome-like browsers, the OS setting will be shown. """>>
Also see [[SystemTag: $:/tags/DarkLightChangeActions]]
!! Variables
The following variable is defined for all actions DarkLightChangeActions
| Variables | Description |h
|`dark-mode` |`yes` or `no` depending on the browser or OS setting |
2023-11-01 18:06:06 +00:00
!! Example
2023-11-01 12:46:09 +00:00
2023-11-01 18:06:06 +00:00
The following example defines the $:/palette tiddler based on the dark / light mode setting. Palettes are tagged: <<tag "$:/tags/Palette">> -- The tag-pill dropdown can be used to see all possible palette tiddlers.
2023-11-01 12:46:09 +00:00
```
title: test-AutoSwitchPalette
tags: $:/tags/DarkLightChangeActions
\define darkPalette() $:/palettes/GruvboxDark
\define lightPalette() $:/palettes/Vanilla
<$action-setfield $tiddler="$:/palette" text={{{ [<dark-mode>match[yes]then<darkPalette>else<lightPalette>] }}} />
```
!! InfoMechanism
2023-11-01 18:09:16 +00:00
<<.warning """The system info tiddler $:/info/darkmode will be dynamically updated ''after'' the actions have been executed. Therefore it is important to use the variable `dark-mode`""">>