Simpler Accordion Macro

Hi All,

This is very interesting to me. I am learning I need to fix part of my personality, the “perfectionist” part. I keep trying to build the ultimate solution, whilst also trying to make it the simplest.

In this implementation we can only use a state “field” on the current tiddler;

\define details(state content summary:"Details")
<$button class="tc-btn-invisible">
<$action-listops $field="$state$" $subfilter="+[toggle[⇱],[⇲]]" />
{{!!$state$}} $summary$
</$button>
<$list filter="[{!!$state$}match[⇱]]" variable=nul>

$content$
</$list>
\end


<<details "details-1"  "{{ButtonWidget}}" "{{!!description}}" >

You need to click the “summary” once/twice to display the “icon” and set the initial state. Because the icon is the state.

Notes;

  • This is making use of 5.2.0 new macro parameters (I now have a compelling use)
    • Except for state/fieldname, content and summary can be any string or “transclusion”
  • Unicode has a large suite of characters we can use, I hope you can see these in tiddlywiki.com

Experiments and futures

  • Use tag=div on the button to display content inside the button
  • Use reveal to allow the “state” to be any “text reference” eg !!fieldname tiddlername tiddlername!!fieldname
  • Enable all parameters to be a literal OR text reference.