Dropdown Arrow

155 views
Skip to first unread message

Game Dungeon

unread,
Oct 20, 2020, 4:22:12 PM10/20/20
to TiddlyWiki
I wish to emulate the drop-down arrow in the table of content for my own use, but I'm having trouble breaking down the table of contents code. Can anyone help me break it down? 

BTW: My use case is having a title with text that I can open and close under it So it takes up less of my screen.

odin...@gmail.com

unread,
Oct 21, 2020, 9:25:01 AM10/21/20
to TiddlyWiki
You could use the display on demand feature from the Shiraz plugin.

https://kookma.github.io/TW-Shiraz/#Tutorial%20Display%20on%20Demand

Op dinsdag 20 oktober 2020 om 22:22:12 UTC+2 schreef ethan.w...@gmail.com:

Eric Shulman

unread,
Oct 21, 2020, 10:56:24 AM10/21/20
to tiddl...@googlegroups.com
On Tuesday, October 20, 2020 at 1:22:12 PM UTC-7, Game Dungeon wrote:
I wish to emulate the drop-down arrow in the table of content for my own use, but I'm having trouble breaking down the table of contents code. Can anyone help me break it down? 
BTW: My use case is having a title with text that I can open and close under it So it takes up less of my screen.

see "Accordion or Slider" in https://tiddlywiki.com/#RevealWidget

Try this:

First, create a tiddler, "ToggleTiddler", tagged with $:/tags/Macro, containing:
\define toggle(title)
<$vars toggle_id=<<qualify "$:/state/toggle/$title$">>>
<$reveal state=<<toggle_id>> type="nomatch" text="show">
   
<$button class="tc-btn-invisible" set=<<toggle_id>> setTo="show">
     
<$text text="""$title$"""/> {{$:/core/images/right-arrow}}
   
</$button>
</
$reveal>
<$reveal state=<<toggle_id>> type="match" text="show">
   
<$button class="tc-btn-invisible" set=<<toggle_id>> setTo="hide">
     
<$text text="""$title$"""/> {{$:/core/images/down-arrow}}
   
</$button>
   <$transclude tiddler="""$title$""" mode="block"/
>
</$reveal>
\end

Then, in any other tiddler, you can use it like this:
<<toggle "NameOfTiddler">>

Notes:
* The $vars constructs a "state tiddler" title that incorporates the target tiddler title.  The state tiddler keeps track of whether the content is shown or hidden.
* <<qualify "...">> is used to ensure that each use of the toggle macro is unique
* The first $reveal displays a $button when the target tiddler content is not being shown
* The $button then sets the state tiddler's value to "show"
* The $button uses class="tc-btn-invisible" so that it appears as normal text (i.e., without the usual button appearance)
* The $button label displays the title of the target tiddler followed by the right-arrow image
* The second $reveal does the opposite of the first $reveal (i.e., displays a $button that sets the state value to "hide", and uses the down-arrow image)
* The second $reveal also $transcludes the target tiddler content

References:

enjoy,
-e

Game Dungeon

unread,
Oct 21, 2020, 3:41:24 PM10/21/20
to TiddlyWiki
Thanks, A lot to both of you.

I think I will go with Eric's method though because I prefer to build my own library of tools

Game Dungeon

unread,
Oct 21, 2020, 4:00:08 PM10/21/20
to tiddl...@googlegroups.com
Hey eric, 

I'm rather new to Tiddly Wiki. In the past, I was using a list to generate these. With the new macro

<$list filter="[tag[Journal]!sort[created]]">
<br/>
<h2><$link><$transclude field="title" mode="block"/></$link></h2>
<$transclude field="text" mode="block"/>
<br/>
<hr/>
</$list>

Now with the new macro, I tried this:

<$list filter="[tag[Journal]!sort[created]]">
<br/>
<<toggle "<
<currentTiddler>>">>
<br/>
<hr/>
</$list>

It failed quite badly. This is likely a user error as I am quite new. Can you help?

Eric Shulman

unread,
Oct 21, 2020, 4:13:45 PM10/21/20
to TiddlyWiki
On Wednesday, October 21, 2020 at 1:00:08 PM UTC-7, Game Dungeon wrote:
I tried this:
<$list filter="[tag[Journal]!sort[created]]">
<br/>
<<toggle "<
<currentTiddler>>">>
<br/>
<hr/>
</$list>

It failed quite badly. This is likely a user error as I am quite new. Can you help?

The problem is that the <<...>> syntax doesn't "nest", so you can't use <<currentTiddler>> as a parameter value *inside* of the toggle macro.

However, the <<macroname param1 param2 ...etc...>> syntax is actually just a shorthand for a *widget* named $macrocall,
and widgets DO allow you to use <<...>> as parameter values, so you can use this instead:
<$macrocall name="toggle" title=<<currentTiddler>> />

Also note that you don't use quotes when a macro or variable reference is used as a parameter value.

-e

Game Dungeon

unread,
Oct 21, 2020, 6:42:35 PM10/21/20
to TiddlyWiki
Thanks :)

Game Dungeon

unread,
Oct 21, 2020, 6:53:08 PM10/21/20
to TiddlyWiki
Sadly it's still not working. 


On Wednesday, 21 October 2020 at 15:13:45 UTC-5 Eric Shulman wrote:

Eric Shulman

unread,
Oct 21, 2020, 7:03:03 PM10/21/20
to TiddlyWiki
On Wednesday, October 21, 2020 at 3:53:08 PM UTC-7, Game Dungeon wrote:
Sadly it's still not working. 

Oops.. there was a typo in my answer.  use "$name" instead of "name"
<$macrocall $name="toggle" title=<<currentTiddler>> />
 
-e
 

Game Dungeon

unread,
Oct 21, 2020, 7:04:31 PM10/21/20
to TiddlyWiki
Well, now that you fixed the typo it works perfectly. Thanks :)
Reply all
Reply to author
Forward
0 new messages