Brilliant solution, @Nico! But: how do i get the script to run? I copy/pasted this script verbatim- i.e. from /*\ to })(); -into a new tiddler of type:application/javascript, titled "ThemeSwitch"... but i guess that's not going to run by itself unless it gets activated somehow. Do i need to make that into a system tiddler, or shadow or some such ( all those $:/_ prefixes on all those "meta" tiddlers are greek to me still :-(
/walt On Thursday, January 14, 2021 at 8:18:46 PM UTC Nicolas Petton wrote: > ludwa6 <[email protected]> writes: > > Hi! > > > SO: What's needed is a theme-switching affordance that is as agile as > the > > context-switching dynamic of my work/life-style. Drilling down thru > > Control Panel / Appearance tab/ Theme menu/ Theme select is a PITA on > > desktop, and an absolute non-starter on mobile. Ideally, i would have a > > one-click way to switch from one theme to the other, ideally via nice > fat > > toolbar button. > > You could try something like the following (admittedly hackish) tiddler > for switching the theme on startup based on the width of the viewport. > > I've set the breakpoint to 960px in the example below, and the "desktop" > theme to snowwhite, but you can change those values (do not forget to > set the Type field to "application/javascript"). > > /*\ > title: $:/hacks/startup/setup-mobile-theme.js > type: application/javascript > module-type: startup > \*/ > > /*global $tw: false */ > (function() { > exports.name = "setup-mobile-theme"; > exports.platforms = ["browser"]; > exports.after = ["startup"]; > > var mobileTheme = "$:/themes/nico/notebook"; > var desktopTheme = "$:/themes/tiddlywiki/snowwhite"; > > var breakpoint = 960; > > exports.startup = function() { > var theme, palette; > if (document.documentElement.clientWidth <= breakpoint) { > theme = mobileTheme; > } else { > theme = desktopTheme; > } > > setup(theme); > }; > > function setup(theme, palette) { > $tw.wiki.addTiddler({title: "$:/theme", text: theme}); > } > })(); > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/bb14c1bf-127f-43f1-bfb2-c0eaf55c0befn%40googlegroups.com.

