Changing TW colors

38 views
Skip to first unread message

skye riquelme

unread,
Apr 18, 2012, 8:46:26 PM4/18/12
to TiddlyWiki
Hi All

In the style sheet I can set colors using code like "background-color:
[[Cor::background]];"..... where the background will be the sliced
pair to "background" in tiddler "Cor". Great.

What I want to do is have the contents of Cor read -
<<wikify {{'|background|'+localStorage.cor+'|"}}>> ..... when I open
the tiddler Cor, I see "|background|color (stored in localStorage
parameter)|"..... I can see it....but StyleSheet doesnt see
it.....guess it a question of what gets rendered first......

Is there any way to have Style sheet read a calculated value like
this?

Thanks in Advance
Skye
Message has been deleted

Tobias Beer

unread,
Apr 19, 2012, 5:40:16 PM4/19/12
to tiddl...@googlegroups.com
One way to do it would be to put something like this into your zzConfig:

//shadow tiddler for styles
config.shadowTiddlers.StyleSheetLocalStorage ='/*{{{*/\n'+
'.myClass {background-color:[[' + someJavascript(param) + ';;}\n'+ '/*}}}*/'; store.addNotification("StyleSheetLocalStorage", refreshStyles);

So essentially, this adds a shadow tiddler by the name of StyleSheetLocalStorage into which your localStorage thingy would have to be computed and which then is invoked via addNotification.

Note, however that if you chose to overwrite this ShadowTiddler, you will lose the computed value.

As I have no idea, what your localStoragy thingy is about, you might need to figure that part out yourself.

Cheers, Tobias.

skye riquelme

unread,
Apr 19, 2012, 8:21:13 PM4/19/12
to TiddlyWiki
Hi All....Todias

I came up with what I think is something similar. A tiddler has some
nice colores icones (Erics SetIconPlugin) which activate (when hit) a
bit o javascript that simply creates the color combinations in sliced
format (var text="|background|color|\n|text|othercolor......)....and
then makes a tiddler called Color.....which the StyleSheet is
reading...so I have to reload the StyleSheet...but thats simple
enough. Each colored icon creates a different set of colors in the
sliced format...and when clicked...simply rewrites the Color file!!!!

The localStorage thingy...is a part of HTML5...where you can store
parameters in the localStorage of the browser...a bit like cookies,
only the parameter values are available across windows ou tabs of the
browser.....dont have to send values between TWS...for example dont
need to use [[open in new tab|otherFolder/
TWfile.html#txtParameter:parameterValue.....]].... if parameterValue
is set in localStorage its available in TWfile automatically ------
PROVIDED the calling TW and receiving TW have the same browser address
- thats a heavy restriction sometimes....but often not.

I am findng setting and using localStorage, generally easier and more
useful that config.options.txt.... but its a personal thing!!!

Thanks for your suggestion

Skye
Reply all
Reply to author
Forward
0 new messages