Designer 28th January 2024 at 8:40am

Welcome "" to "Conditional elements" adding conditional display to tabs, buttons and more

?

Conditional tabs
  • This wiki has a modified version of the tabs macro $:/core/macros/tabs with $:/PSaT/conditional-suit/$:/core/macros/tabs
    • There are two key edits, one for the tab buttons, one for the display of the body
    • If the condition changes the visibility of the current tab, the emptyMessage suggests a tab be selected.
    • Other modifications make the tabs macro much more readable
  • If you add a condition field to any tab, containing a filter, it will be tested before the tab is displayed
  • For example the tiddler Designer Dashboard has the sidebar tag, but also contains a condition field "[{$:/config/design-mode}match[yes]]"
Conditional Page Control's . Toolbars
Conditional view and Edit toolbars
Conditional tags
  • To be done, add an optional condition field on "tag tiddlers" as to if they will appear on the view template
  • <$list filter="[{!!title}tags[]sort[title]] :filter[{!!condition}]" template="$:/core/ui/TagTemplate"storyview=pop/>
    • The Filter "filter run is used as it "removes every input title for which the filter run output is an empty list" as the tag is the current tiddler durring listing
  • The conditions will not apply to the tags when in edit mode. we do not change $:/core/ui/EditTemplate/tags otherwise tags would be hard to find and remove.

has the condition [{$:/config/design-mode}match[yes]] on it.

Conditional TOC items?

We know How to change the sort order of sub-branches in a TOC macro but this is a limited sort. What if we have other reasons to apply a condition or filter to a larger table of contents such as;

  • Hide the children of the current TOC item
  • Hide the current TOC item, thus its children
  • Only list children in the TOC that meet a particular criteria and or is a calculated order.
  • Show a tooltip or description?

In this wiki I will explore enhancing the toc macros as follows.

  • Allow the user to provide a fieldname to use as a condition text (default condition) condition-field:"condition"
  • Allow the user to provide a fieldname to use instead of the filter given to the TOC macro (child-filter) can include sort order of the children child-filter-field:"child-filter"
  • condition-field:"condition" child-filter-field:"child-filter"
Research
  • $:/core/macros/toc imported from tiddlywiki.com because this wiki had external core installed and was compressed
  • Macros that we call
    • toc *
    • toc-tabbed-internal-nav *
    • toc-tabbed-external-nav *
    • toc-expandable *
    • toc-selective-expandable *
      • toc-selective-expandable-empty-message
      • toc-unlinked-selective-expandable-body
      • toc-linked-selective-expandable-body
      • toc-expandable-empty-message ?
      • toc-unlinked-expandable-body
      • toc-linked-expandable-body
      • toc-body
      • toc-caption
      • more?
Structure
  • toc-selective-expandable * > toc-unlinked-selective-expandable-body | empty see below
    • < toc-tabbed-internal-nav *
    • < toc-tabbed-external-nav *
  • toc-unlinked-expandable-body
    • < toc-expandable
  • toc-linked-expandable-body
    • < toc-expandable-empty-message
      • < toc-expandable
  • toc-body
    • < toc
Ideas;
  • Perhaps all the above changes can be implemented using the methods discussed here, override not overwrite.
  • Perhaps all conditional solutions above can have a fieldname set defaulting to the condition field.
    • This would allow the sets of tiddlers to be configured for multiple alternative sets of conditions