[HowTo] a simple button to cycle in color palettes

121 views
Skip to first unread message

Mohammad

unread,
Dec 13, 2020, 1:34:52 AM12/13/20
to TiddlyWiki
Feature in Tiddlywiki 5.1.23

TW 5.123 has a new filter operator called cycle


Using this filter operator it is simple to build a button to cycle in your color palettes!

See the how to in new Show and tell page of GitHub Discussion board.


--Mohammad

TW Tones

unread,
Dec 13, 2020, 6:53:02 PM12/13/20
to TiddlyWiki
Mohammad,

Thanks for sharing to the forum insight into features in the pre-release. 
  • This pallet switch would be nice to allow users to choose there own pallet.
There are quite a few features that can simplify things people have wanted for a long time in the pre-release. More has being moved into the filters that will allow common use methods to be simpler to improvement.

Thanks for your "educational posts"

Tones

TW Tones

unread,
Dec 14, 2020, 2:09:26 AM12/14/20
to TiddlyWiki
Mohammad,

I was looking at the filter you used and notice a shorter form for [[$:/palette]get[text] is {$:/palette}

<$button actions=<<cycle-palettes>> >
<$text text={{{ [{$:/palette}removeprefix[$:/palettes/]] }}}/>
</$button>

However this made me ask do we have the ability to have replaceable parameters in filters for common actions?
  • This is off topic from your post but I had an interesting thought.

So consider this
\define cycle-palettes()
<$set name=pals filter="[all[tiddlers+shadows]tag[$:/tags/Palette]]">
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>]"/>
</$set>
\end
\define act(palette-name:"{{{ [{$:/palette}removeprefix[$:/palettes/]] }}}")
<$button actions=<<cycle-palettes>> >
<$text text=$palette-name$/>
</$button>
\end
<<act>>

Explanation
  • Above here I simplify the button title by defining it with a parameter, unfortunately there is no short form to insist it be text
    • ultimately this is not shorter because of the overhead, but if  $palette-name$ could be defined once and used in many places it would be useful
    • but that is not how parameters are
  • Using templates however we can make this simpler, see below, but it would be nice if we could have "global" $substitutions$ or similar?
\define cycle-palettes()
<$set name=pals filter={{palettes⒡}}>
<$action-listops $tiddler="$:/palette" $field="text" $subfilter="+[cycle<pals>]"/>
</$set>
\end
<$button actions=<<cycle-palettes>> >
{{<palette-name>}}
</$button>

;Now the tiddler "<palette-name>" contains  the following
```
<$text text={{{ [{$:/palette}removeprefix[$:/palettes/]] }}}/>
```
;Now the tiddler "palettes⒡" contains the following
:yes I am using a special unicode character here

```
[all[tiddlers+shadows]tag[$:/tags/Palette]]
```

Regards
Tony
On Sunday, 13 December 2020 at 17:34:52 UTC+11 Mohammad wrote:

TiddlyTweeter

unread,
Dec 14, 2020, 4:12:25 AM12/14/20
to TiddlyWiki
Ciao Mohammad

Thanks for highlighting the new operator.

Very good! Makes buttons fly. CYCLE toggles are a very neat minimalist way to effect change.

Best wishes
TT
 

Saq Imtiaz

unread,
Dec 14, 2020, 4:55:13 AM12/14/20
to TiddlyWiki
@Mohammad

You can simplify 
<$button actions=<<cycle-palettes>> > <$text text={{{ [[$:/palette]get[text]removeprefix[$:/palettes/]]}}}/> </$button> 

to:

<$button actions=<<cycle-palettes>> >
<$text text={{{ [{$:/palette}get[name]]}}}/>
</$button>

Mohammad

unread,
Dec 14, 2020, 7:39:08 AM12/14/20
to TiddlyWiki
Thank you Saq. Your solution is minimal and semantic!

--Mohammad

Mohammad Rahmani

unread,
Dec 14, 2020, 7:50:08 AM12/14/20
to tiddl...@googlegroups.com

Hi Tony!
 Yes, I think I just focused on the cycle and no the whole snippets. I like your approach.
I myself have the simple solution!

Thank you

--Mohammad



--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/741947d1-9964-4be4-bdcf-311721a4b7aan%40googlegroups.com.

Mohammad Rahmani

unread,
Dec 14, 2020, 12:50:18 PM12/14/20
to tiddl...@googlegroups.com
Hi Josiah,

On Mon, Dec 14, 2020 at 12:42 PM TiddlyTweeter <Tiddly...@assays.tv> wrote:
Ciao Mohammad

Thanks for highlighting the new operator.

I myself am very interested to see new features discussed. This is an effort of what I have discovered! :-)
TW 5.1.23 has a lot of such great features!

 
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages