From 19177964c8297d6ca12b66ebdc6add4608d4f05f Mon Sep 17 00:00:00 2001 From: XLBilly Date: Sat, 1 Nov 2025 21:06:19 +0800 Subject: [PATCH] Improve switcher (UI) accessibility (#9347) * Improve theme switcher accessibility * Improve view switcher accessibility * Replace set widgets with filters * Improve languageswitcher & layoutswitcher accessibility * Add indentation inside list widget * Switch to functions --- core/ui/LayoutSwitcher.tid | 37 +++++++++++++++++----------------- core/wiki/languageswitcher.tid | 24 +++++++++++----------- core/wiki/themeswitcher.tid | 19 ++++++++--------- core/wiki/viewswitcher.tid | 9 +++++---- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/core/ui/LayoutSwitcher.tid b/core/ui/LayoutSwitcher.tid index 0f7e3f15e..4b8508340 100644 --- a/core/ui/LayoutSwitcher.tid +++ b/core/ui/LayoutSwitcher.tid @@ -3,27 +3,26 @@ tags: $:/tags/ControlPanel/Appearance caption: {{$:/language/ControlPanel/LayoutSwitcher/Caption}} \whitespace trim +\function layout.filter() [all[current]field:title[$:/core/ui/PageTemplate]] +\function layout.empty.filter() [all[current]field:title{$:/layout}] + <$linkcatcher to="$:/layout"> -
+
<$list filter="[all[tiddlers+shadows]tag[$:/tags/Layout]] [[$:/core/ui/PageTemplate]] +[!is[draft]sort[name]]"> -<$list - filter="[{$:/layout}!has[text]]" - variable="ignore" - emptyMessage="""\whitespace trim - <$set name="cls" filter="[all[current]field:title{$:/layout}]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item"> -
>> - <$link to={{!!title}}> - ''<$transclude tiddler={{{ [get[icon]] }}}/><$transclude field="name"/>'' - <$transclude field="description"/> -
-"""> -<$set name="cls" filter="[all[current]field:title[$:/core/ui/PageTemplate]]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item"> -
>> -<$link to={{!!title}}> -''<$transclude tiddler={{{ [get[icon]] }}}/><$transclude field="name"/>'' - <$transclude field="description"/> - -
- - + <$list filter="[{$:/layout}!has[text]]" variable="ignore"> + <$list-empty> +
+ <$link to={{!!title}} role="option" aria-selected={{{ [layout.empty.filter[]then[true]else[false]] }}}> + ''<$transclude tiddler={{{ [get[icon]] }}}/><$transclude field="name"/>'' - <$transclude field="description"/> + +
+ +
+ <$link to={{!!title}} role="option" aria-selected={{{ [layout.filter[]then[true]else[false]] }}}> + ''<$transclude tiddler={{{ [get[icon]] }}}/><$transclude field="name"/>'' - <$transclude field="description"/> + +
+
diff --git a/core/wiki/languageswitcher.tid b/core/wiki/languageswitcher.tid index 7d79c0f5c..a3c5ca97f 100644 --- a/core/wiki/languageswitcher.tid +++ b/core/wiki/languageswitcher.tid @@ -1,20 +1,20 @@ title: $:/snippets/languageswitcher \whitespace trim +\function language.filter() [all[current]field:title{$:/language}] + <$linkcatcher to="$:/language"> -
+
<$list filter="[[$:/languages/en-GB]] [plugin-type[language]sort[description]]"> -<$set name="cls" filter="[all[current]field:title{$:/language}]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item"> -
> lang={{!!name}}> -<$link> -<$view field="description"> -<$view field="name"> -<$view field="title"/> - - - -
- +
+ <$link role="option" aria-selected={{{ [language.filter[]then[true]else[false]] }}}> + <$view field="description"> + <$view field="name"> + <$view field="title"/> + + + +
\ No newline at end of file diff --git a/core/wiki/themeswitcher.tid b/core/wiki/themeswitcher.tid index 6259af063..79f4a09ba 100644 --- a/core/wiki/themeswitcher.tid +++ b/core/wiki/themeswitcher.tid @@ -1,17 +1,18 @@ title: $:/snippets/themeswitcher \whitespace trim +\function theme.filter() [all[current]field:title{$:/theme}] [[$:/theme]!has[text]addsuffix[s/tiddlywiki/vanilla]field:title] +[limit[1]] + <$linkcatcher to="$:/theme"> -
+
<$list filter="[plugin-type[theme]sort[title]]"> -<$set name="cls" filter="[all[current]field:title{$:/theme}] [[$:/theme]!has[text]addsuffix[s/tiddlywiki/vanilla]field:title] +[limit[1]]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item"> -
>><$link to={{!!title}}> -''<$view field="name" format="text"/>'' - -<$view field="description" format="text"/> - -
- +
+ <$link to={{!!title}} role="option" aria-selected={{{ [theme.filter[]then[true]else[false]] }}}> + ''<$view field="name" format="text"/>'' + + <$view field="description" format="text"/> + +
\ No newline at end of file diff --git a/core/wiki/viewswitcher.tid b/core/wiki/viewswitcher.tid index b82fcb264..1ff289cdf 100644 --- a/core/wiki/viewswitcher.tid +++ b/core/wiki/viewswitcher.tid @@ -4,13 +4,14 @@ title: $:/snippets/viewswitcher $:/core/images/storyview-$(storyview)$ \end \whitespace trim +\function view.filter() [prefix{$:/view}] + <$linkcatcher to="$:/view"> -
+
<$list filter="[storyviews[]]" variable="storyview"> -<$set name="cls" filter="[prefix{$:/view}]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item">
>> -<$button tag="a" class="tc-tiddlylink tc-btn-invisible" to=<>><$transclude tiddler=<>/><$text text=<>/> +
+<$button tag="a" class="tc-tiddlylink tc-btn-invisible" role="option" to=<> aria-selected={{{ [view.filter[]then[true]else[false]] }}}><$transclude tiddler=<>/><$text text=<>/>
-