Feature design: options-in-templates

39 views
Skip to first unread message

Yakov

unread,
Feb 29, 2024, 4:52:20 AM2/29/24
to TiddlyWikiClassic
Hi everyone,

today I'd like propose a change that will unlock extending TiddlyWiki in various ways and learn what you think.

The initial issue I'd like to solve is that shadows a bad for forward compatibility.

For instance, I'd like to add a "variable" to set border-radius globally (so that one can change it once instead of changing many CSS rules). Where can I define such a "variable"?

Option 1: add it to an existing shadow as a slice. Let's even forget that ColorPalette is not a suitable place, just add BorderRadius: 5px there and then use [[ColorPalette::BorderRadius]] in style sheets. This will cause a problem: some users have a customized ColorPalette, so there will be no BorderRadius, and CSS will break.

Option 2: create a new shadow with slices, like Options, and use [[Options::BorderRadius]] . Well, this is hardly better: once another option is added to Options, users with customized Options will have problems as above.

Option 3: create a shadow per option. Like BorderRadius, with the content of just 5px, and use [[BorderRadius]] in style sheets. This sounds better, but this can lead to the list of Shadow tiddlers getting polluted and difficult to navigate. Note: this still might be a solution, given that there's a good UI to navigate through all the customization bits of TW, but that's not that easy to implement and still breaks some workflows that we are used to.

The proposition is to extend templates instead, so that option values can be used there. For instance, it can look like $txtOptionName, i.e.

#displayArea { border-radius: $txtBorderRadius; }

(this follows the syntax of LESS/SASS), and it's enough to set a default value for txtBorderRadius to add that new "variable" (default option values are not saved in cookies or SystemSettings). Since editing a txt- option via macros won't cause refreshing of styles, it's probably better to use a new type of options, though: cssBorderRadius (and just $borderRadius in style sheets); it will also make sure that the options that were not supposed to be used like this, are not [used like this].

My questions are these:
  1. Do you have any general objections/comments/ideas on this?
  2. What do you think about the specific syntax? (does cssBorderRadius$borderRadius looks good enough? any issues with it?)
  3. naturally, this can be extended to templates (getRecursiveTiddlerText is used also for PageTemplate, ViewTemplate, etc, including themes and updateMarkupBlock), but should it? Have you seen usage of $word in templates that can potentially break? Does this look useful for templates?
Best regards,
Yakov.
Reply all
Reply to author
Forward
0 new messages