TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.09k stars 1.19k forks source link

Improve access to button icons and tooltips #1349

Closed aelocson closed 9 years ago

aelocson commented 9 years ago

The way button tiddlers are implemented, as at

https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/PageControls/newtiddler.tid

means that, given the title of a button tiddler, there's no way to individually transclude the icon and tooltip. The ability to do this would allow the creation of a general documentation macro to reliably yield the correct name for a button.

The best that's available is the caption field, but that gives you a hard-coded combination of the icon and a string that isn't necessarily the tooltip.

It would be better to give each button tiddler two dedicated fields, for icon and tooltip.

tobibeer commented 9 years ago

The problem with giving those buttons fields is that you may override more than you want to.

Imagine wanting to swap just the button icons but not the tooltips. Doing that at the button template will prevent it from getting core updates.

Jermolene commented 9 years ago

means that, given the title of a button tiddler, there's no way to individually transclude the icon and tooltip. The ability to do this would allow the creation of a general documentation macro to reliably yield the correct name for a button.

You can independently transclude the button and the text by setting the two variables tv-config-toolbar-icons and tv-config-toolbar-text outside the transclusion. It's not super elegant, but it makes it easier to globally configure buttons vs. text choices.

aelocson commented 9 years ago

@tobibeer: The field values would be transclusions. For example, the value of the icon field for the New Tiddler button, for example, would be {{$:/core/images/new-button}}, and the value of the tooltip field would be {{$:/language/Buttons/NewTiddler/Hint}}.

@Jermolene: Yes, but that gives me a functioning button widget. I want to just display an inert phrase like the ‘Create a new tiddler’ button by writing something like the <<doc-button-name "$:/core/ui/Buttons/new-tiddler">> button.

However, I've just realised that each button has a description field that contains its tooltip (and hence its user-facing name). That would do nicely, except it would be good to have access to the icon as well.

tobibeer commented 9 years ago

The field values would be transclusions. For example, the value of the icon field for the New Tiddler button, for example, would be {{$:/core/images/new-button}}, and the value of the tooltip field would be {{$:/language/Buttons/NewTiddler/Hint}}.

Ah, ok. That indeed appears to be fine.

Jermolene commented 9 years ago

However, I've just realised that each button has a description field that contains its tooltip (and hence its user-facing name). That would do nicely, except it would be good to have access to the icon as well.

I think in docs we might want the caption more than the hint/description.

My concern with all of this is that we might end up with quite a lot of redundancy in the individual button instances. If so, there's a good chance that we should do a more thorough overhaul of how buttons are handled, and try to make them a good deal more declarative.

aelocson commented 9 years ago

Ah, of course! The caption is what's displayed on the buttons in the Tools sidebar tab, or if you tick "Include text" in the Control Panel settings. I've been hunting the wrong beast :)

For now, I'll stick with transcluding the button's caption field into a span whose CSS reduces the icon to a less preposterous size.