ludwa6 <
wlud...@gmail.com> 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});
}
})();