mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-17 03:20:02 +00:00
Update core tabs-macro to make it easier to extend for plugin authors. (#6578)
* tabs activate v5.2.2 tests add whitespace trim * tabs-macro -- add indentation and code preview * tabs-macro -- replace substitutions with variables * split tabs-macro macro into different elements - tabs-button - tabs-tab - tabs-tab-list - tabs-tab-body - tabs ... main macro * tabs: add cascade to button and reaveal widgets This will allow users to create "default tab" configurations similar to the tiddler info tab handling. * tabs-macro -- add code_body: yes
This commit is contained in:
parent
778581b4ff
commit
ff42a9e4d4
@ -1,41 +1,63 @@
|
||||
title: $:/core/macros/tabs
|
||||
tags: $:/tags/Macro
|
||||
code_body: yes
|
||||
|
||||
\define tabs-button()
|
||||
\whitespace trim
|
||||
<$button set=<<tabsState>> setTo=<<currentTab>> default=<<__default__>> selectedClass="tc-tab-selected" tooltip={{!!tooltip}}>
|
||||
<$tiddler tiddler=<<save-currentTiddler>>>
|
||||
<$set name="tv-wikilinks" value="no">
|
||||
<$transclude tiddler=<<__buttonTemplate__>> mode="inline">
|
||||
<$transclude tiddler=<<currentTab>> field="caption">
|
||||
<$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
|
||||
</$transclude>
|
||||
</$transclude>
|
||||
</$set>
|
||||
</$tiddler>
|
||||
<<__actions__>>
|
||||
</$button>
|
||||
\end
|
||||
|
||||
\define tabs-tab()
|
||||
\whitespace trim
|
||||
<$set name="save-currentTiddler" value=<<currentTiddler>>>
|
||||
<$tiddler tiddler=<<currentTab>>>
|
||||
<<tabs-button>>
|
||||
</$tiddler>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define tabs-tab-list()
|
||||
\whitespace trim
|
||||
<$list filter=<<__tabsList__>> variable="currentTab" storyview="pop">
|
||||
<<tabs-tab>>
|
||||
</$list>
|
||||
\end
|
||||
|
||||
\define tabs-tab-body()
|
||||
\whitespace trim
|
||||
<$list filter=<<__tabsList__>> variable="currentTab">
|
||||
<$reveal type="match" state=<<tabsState>> text=<<currentTab>> default=<<__default__>> retain=<<__retain__>> tag="div">
|
||||
<$transclude tiddler=<<__template__>> mode="block">
|
||||
<$transclude tiddler=<<currentTab>> mode="block"/>
|
||||
</$transclude>
|
||||
</$reveal>
|
||||
</$list>
|
||||
\end
|
||||
|
||||
\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate,retain,actions,explicitState)
|
||||
\whitespace trim
|
||||
<$let
|
||||
qualifiedState=<<qualify "$state$">>
|
||||
tabsState={{{ [<__explicitState__>minlength[1]] ~[<qualifiedState>] }}}>
|
||||
<div class="tc-tab-set $class$">
|
||||
<div class="tc-tab-buttons $class$">
|
||||
<$list filter="$tabsList$" variable="currentTab" storyview="pop"><$set name="save-currentTiddler" value=<<currentTiddler>>>
|
||||
<$tiddler tiddler=<<currentTab>>>
|
||||
<$button set=<<tabsState>> setTo=<<currentTab>> default="$default$" selectedClass="tc-tab-selected" tooltip={{!!tooltip}}>
|
||||
<$tiddler tiddler=<<save-currentTiddler>>>
|
||||
<$set name="tv-wikilinks" value="no">
|
||||
<$transclude tiddler="$buttonTemplate$" mode="inline">
|
||||
<$transclude tiddler=<<currentTab>> field="caption">
|
||||
<$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
|
||||
</$transclude>
|
||||
</$transclude>
|
||||
</$set></$tiddler>$actions$</$button></$tiddler></$set></$list>
|
||||
</div>
|
||||
<div class="tc-tab-divider $class$"/>
|
||||
<div class="tc-tab-content $class$">
|
||||
<$list filter="$tabsList$" variable="currentTab">
|
||||
|
||||
<$reveal type="match" state=<<tabsState>> text=<<currentTab>> default="$default$" retain="""$retain$""">
|
||||
|
||||
<$transclude tiddler="$template$" mode="block">
|
||||
|
||||
<$transclude tiddler=<<currentTab>> mode="block"/>
|
||||
|
||||
</$transclude>
|
||||
|
||||
</$reveal>
|
||||
|
||||
</$list>
|
||||
</div>
|
||||
</div>
|
||||
</$let>
|
||||
<$qualify title=<<__state__>> name="qualifiedState">
|
||||
<$set name="tabsState" filter={{{ [<__explicitState__>minlength[1]] ~[<qualifiedState>] }}}>
|
||||
<div class={{{ [[tc-tab-set]addsuffix[ ]addsuffix<__class__>] }}}>
|
||||
<div class={{{ [[tc-tab-buttons]addsuffix[ ]addsuffix<__class__>] }}}>
|
||||
<<tabs-tab-list>>
|
||||
</div>
|
||||
<div class={{{ [[tc-tab-divider]addsuffix[ ]addsuffix<__class__>] }}}/>
|
||||
<div class={{{ [[tc-tab-content]addsuffix[ ]addsuffix<__class__>] }}}>
|
||||
<<tabs-tab-body>>
|
||||
</div>
|
||||
</div>
|
||||
</$set>
|
||||
</$qualify>
|
||||
\end
|
||||
|
@ -54,31 +54,32 @@ describe("Tabs-macro HTML tests", function() {
|
||||
/ Run the tests
|
||||
--------------------*/
|
||||
// horizontal
|
||||
it("should render horizontal tabs v5.2.1", function() {
|
||||
/*
|
||||
xit("should render horizontal tabs v5.2.1", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal")).toBe(expected.fields.text);
|
||||
});
|
||||
|
||||
it("should render horizontal tabs macro with all parameters modified V5.2.1", function() {
|
||||
xit("should render horizontal tabs macro with all parameters modified V5.2.1", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal-all")).toBe(expectedAll.fields.text);
|
||||
});
|
||||
|
||||
// vertical
|
||||
it("should render tabs vertical tabs v5.2.1", function() {
|
||||
xit("should render tabs vertical tabs v5.2.1", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-vertical")).toBe(expectedVert.fields.text);
|
||||
});
|
||||
|
||||
*/
|
||||
// Future tests
|
||||
// horizontal
|
||||
xit("should render 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
it("should render 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal")).toBe(expected.fields.text.replace(/\n/g,""));
|
||||
});
|
||||
|
||||
xit("should render 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
it("should render 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal-all")).toBe(expectedAll.fields.text.replace(/\n/g,""));
|
||||
});
|
||||
|
||||
// vertical
|
||||
xit("should render 'vertical' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
it("should render 'vertical' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-vertical")).toBe(expectedVert.fields.text.replace(/\n/g,""));
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user