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/87wnwfnug8.fsf%40petton.fr.

Attachment: signature.asc
Description: PGP signature

Reply via email to