I have played a lot with the details tag and would be happy to take on this challenge.
What do you see as the value of the simpler macro using details tag?
The above macro does not indicate it is an accordion ie click to open may be missed
Are you happy for the solution to demand a manual “state reference”? eg you used stateTid="temp/02"
Are you keen to see the details “icon”?
[Edited]
Actually I am starting to think, the simplicity is in the use of the macro. ie if it is close in behaviour to the details tag yet is customisable with good defaults. I will return with a solution.
[Edit 2]
Attached is a work in progress creates a “details” macro. Includes examples. If a state mechaisium is used its honored all I need now is to;
Hide the existing icon
Allow the whole of “summary” to respond as the button.
This certainly demonstrates alternative ways to code and simplify the Accordion macro, but in this case it is simplifying the use not the macro.
Thank you Tones!
I was looking for a simpler solution! I though maybe we can find a way to keep status of details tag which can work without JS even in exported html!
To keep the state you have no way to use a permanent variable e.g. tiddler! but you can have code to generate stat tiddler! as I was looking for simple solution I ignored all those complexity!
Using inline style definition as in the example is very hacky. It makes it impossible to style the content by themes or use user settings to define font styles.
I got derailed by the possibilities, but I believe within my code there lays some tricks, and few more are “fermenting” and I believe there is an easier way.
For example all one needs to indicate the state is to have a way to determine if the details open parameter exists or not, perhaps a “filtered transclusion”. Then all you need is a trigger to change that state, in fact there is already a trigger the details “button”. However I am looking at hijacking that button (Remove the icon with CSS) and replace it with my own, a button in the summary will work.
Little quirks appear when pushing but then other quirks can help solve is as well.
Since you can’t use the summary button, nor see it’s open/close arrow, I’m wondering if there is any benefit to using the detail/summary tags?
Like you could instead just manipulate the display state of a div to make it hide/show. And it would manipulate the display state of two icons ( down arrow, up arrow) at the same time to emulate the summary arrows.
You could add a simple detail/summary to your macro and give it a class “exportable”. Add class “nonexportable” to the div based portion. When you run from tiddlywiki, have your stylesheet:
.nonexportable { }
.exportable {display: none;}
but before you export, or in your export stylesheet, have
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;
Given the icon I use in this last example, does any one know how to use css on the open content to put a corner in the top left and bottom right? Like a boarder that only goes 5% of the way from the corners?
Here is a simple more… or …less, Like the last example but with an obvious button to set the state field for the first time.
I need to test this in different situations, viewTemplate, transclusions, nested etc… But this may be my new more solution. One could plump it up with class or styles on the buttons and content.
Open https://tiddlywiki.com/ and drop your code into a new tiddler with tiny modification as below:
\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
This is a test by Tones see <<details "details-1" summary:"Example" content:"This is a long description" >>