mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-26 05:07:39 +00:00 
			
		
		
		
	Introduce a PageMacros tiddler containing a tabs macro
This is a hacky way of having macro definitions that behave as if they are global to the wiki. The new tabs macro itself is cool, though: neatly encapsulates most of the gubbins around a tab control, and the rendering is quite easy to style.
This commit is contained in:
		| @@ -102,8 +102,8 @@ exports.startup = function() { | ||||
| 		$tw.rootWidget.addEventListener("tw-clear-password",function(event) { | ||||
| 			$tw.crypto.setPassword(null); | ||||
| 		}); | ||||
| 		// Display the PageTemplate | ||||
| 		var templateTitle = "$:/core/ui/PageTemplate", | ||||
| 		// Display the PageMacros, which includes the PageTemplate | ||||
| 		var templateTitle = "$:/core/ui/PageMacros", | ||||
| 			parser = $tw.wiki.new_parseTiddler(templateTitle); | ||||
| 		$tw.pageWidgetNode = $tw.wiki.makeWidget(parser,{document: document, parentWidget: $tw.rootWidget}); | ||||
| 		$tw.pageContainer = document.createElement("div"); | ||||
|   | ||||
							
								
								
									
										17
									
								
								core/ui/PageMacros.tid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								core/ui/PageMacros.tid
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| title: $:/core/ui/PageMacros | ||||
|  | ||||
| \define tabs(tabsList,default,state:"$:/currentTab") | ||||
| <div class="tw-tab-buttons"><$list filter="$tabsList$" variable="currentTab"><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tw-tab-selected"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/> </$button> | ||||
| </$list> | ||||
| </div> | ||||
| <div class="tw-tab-divider"> | ||||
| </div> | ||||
| <div class="tw-tab-content"> | ||||
| <$list filter="$tabsList$" variable="currentTab"> | ||||
| <$reveal type="match" state=<<qualify "$state$">> text=<<currentTab>> default="$default$"> | ||||
| <$transclude tiddler=<<currentTab>>/> | ||||
| </$reveal> | ||||
| </$list> | ||||
| </div> | ||||
| \end | ||||
| {{$:/core/ui/PageTemplate}} | ||||
| @@ -1,3 +1,3 @@ | ||||
| title: $:/state/moreSideBarTabSet-{$:/core/ui/MoreSideBar|$:/core/ui/MoreSideBar||}{$:/core/ui/SideBar|$:/core/ui/SideBar||} | ||||
| title: $:/state/moreSideBarTabSet-{$:/core/ui/MoreSideBar|$:/core/ui/MoreSideBar||}{$:/core/ui/SideBar|$:/core/ui/SideBar||}{$:/core/ui/PageTemplate|$:/core/ui/PageTemplate||} | ||||
|  | ||||
| tagsTab | ||||
| @@ -1,3 +1,3 @@ | ||||
| title: $:/state/sideBarTabSet-{$:/core/ui/SideBar|$:/core/ui/SideBar||} | ||||
| title: $:/state/sideBarTabSet-{$:/core/ui/SideBar|$:/core/ui/SideBar||}{$:/core/ui/PageTemplate|$:/core/ui/PageTemplate||} | ||||
|  | ||||
| openTab | ||||
							
								
								
									
										8
									
								
								editions/tw5.com/tiddlers/samples/TabsExample.tid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								editions/tw5.com/tiddlers/samples/TabsExample.tid
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| title: TabsExample | ||||
| tags: samples | ||||
|  | ||||
| Here is an example of the tabs macro: | ||||
|  | ||||
| <<tabs "Docs WikiText Features RoadMap" "WikiText" 1>> | ||||
|  | ||||
| <<tabs "[tag[tips]]" "GoogleChromeTips" 2>> | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston