1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

Add tc-tag-missing or tc-tag-exists to tag pills including docs (#7951)

* add tc-tag-missing or tc-tag-exists to tag pills including docs

* changes as requested

* macros not needed anymore - so remove

* fix the tag Macro docs
This commit is contained in:
Mario Pietsch 2024-03-28 20:07:54 +01:00 committed by GitHub
parent b4d7e34a5a
commit 2e0e541ebf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 7 deletions

View File

@ -21,7 +21,9 @@ color:$(foregroundColor)$;
>
<<__actions__>>
<$transclude tiddler=<<__icon__>>/>
<$view tiddler=<<__tag__>> field="title" format="text" />
<span class={{{ [<__tag__>is[missing]then[tc-tag-missing]else[tc-tag-exists]] }}}>
<$view tiddler=<<__tag__>> field="title" format="text" />
</span>
</$element-tag$>
</$let>
\end

View File

@ -1,6 +1,6 @@
caption: tag
created: 20141206130540337
modified: 20230725201240201
modified: 20240228131301798
tags: Macros [[Core Macros]]
title: tag Macro
type: text/vnd.tiddlywiki
@ -11,7 +11,35 @@ The <<.def tag>> [[macro|Macros]] generates a tag pill for a specified tag. Clic
!! Parameters
;tag
; tag
: The title of the tag, defaulting to the [[current tiddler|Current Tiddler]]
!! CSS classes
<<.from-version "v5.3.4">>
; `tc-tag-missing`
: This class is defined if a tag does ''not exist'' as a tiddler.
; `tc-tag-exists`
: This class is defined if a tag does exist as a tiddler
!!! Defining the class
To define the `tc-tag-missing` class a stylesheet tiddler needs to be created. The default font-style for missing tiddler links is //italic//, so it's used for the example code below. Eg:
''title:'' `myTagsStylesheet`<br>
''tag:'' `$:/tags/Stylesheet`
<<copy-to-clipboard-above-right src:"""
.tc-tag-missing {
font-style: italic;
}
""">>
```
.tc-tag-missing {
font-style: italic;
}
```
<<.macro-examples "tag">>

View File

@ -1,5 +1,5 @@
created: 20150221211317000
modified: 20230725203751870
modified: 20240228131331605
tags: [[tag Macro]] [[Macro Examples]]
title: tag Macro (Examples)
type: text/vnd.tiddlywiki
@ -7,22 +7,26 @@ type: text/vnd.tiddlywiki
<$macrocall $name=".example" n="1" eg="""<<tag>>"""/>
<$macrocall $name=".example" n="2" eg="""<<tag Concepts>>"""/>
The Following tag can be shown with a font-style: //italic// if the corresponding stylesheet exists. See: [[tag Macro]]
<$macrocall $name=".example" n="3" eg="""<<tag "Does not exist">>"""/>
If a [[list widget|ListWidget]] generates multiple tag macros for the same tag, clicking any of them opens dropdowns on all of them, as in the example below. This is usually unwanted.
<$macrocall $name=".example" n="3" eg="""<$list filter="[tag[HelloThere]]">
<$macrocall $name=".example" n="4" eg="""<$list filter="[tag[HelloThere]]">
* <$link/> is tagged with: <$list filter="[<currentTiddler>tags[]]"> <<tag>> </$list>
</$list>"""/>
Adding the `counter="transclusion"` attribute to the list widget that generates multiple identical tag macros causes each of them to be identified as a unique one. Clicking on any of them opens only a single dropdown.
<$macrocall $name=".example" n="4" eg="""<$list filter="[tag[HelloThere]]" counter="transclusion">
<$macrocall $name=".example" n="5" eg="""<$list filter="[tag[HelloThere]]" counter="transclusion">
* <$link/> is tagged with: <$list filter="[<currentTiddler>tags[]]"> <<tag>> </$list>
</$list>"""/>
A slightly more performant option is to use the `variable="transclusion"` attribute in the list widget. In this case, the variable `<<transclusion>>` has to be used inside the list widget instead of the `<<currentTiddler>>` .
<$macrocall $name=".example" n="5" eg="""<$list filter="[tag[HelloThere]]" variable="transclusion">
<$macrocall $name=".example" n="6" eg="""<$list filter="[tag[HelloThere]]" variable="transclusion">
* <$link to=<<transclusion>>/> is tagged with: <$list filter="[<transclusion>tags[]]"> <<tag>> </$list>