Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: $:/snippets/peek-stylesheets to use modern tiddlywiki features #8794

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 35 additions & 59 deletions core/wiki/peek-stylesheets.tid
Original file line number Diff line number Diff line change
@@ -1,76 +1,52 @@
title: $:/snippets/peek-stylesheets

\define expandable-stylesheets-list()
\whitespace trim
<ol>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/Stylesheet]!has[draft.of]]">
<$vars state=<<qualify "$:/state/peek-stylesheets/open/">>>
<$set name="state" value={{{ [<state>addsuffix<currentTiddler>] }}}>
<li>
<$reveal type="match" state=<<state>> text="yes" tag="span">
<$button set=<<state>> setTo="no" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
<$reveal type="nomatch" state=<<state>> text="yes" tag="span">
<$button set=<<state>> setTo="yes" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$link>
<$view field="title"/>
</$link>
<$reveal type="match" state=<<state>> text="yes" tag="div">
<$set name="source" tiddler=<<currentTiddler>>>
<$wikify name="styles" text=<<source>>>
\procedure expandable-content()
<$wikify name="styles" text={{!!text}}>
<$codeblock code=<<styles>> language="css"/>
</$wikify>
</$set>
</$reveal>
</li>
</$set>
</$vars>
</$list>
</ol>
\end

\define stylesheets-list()
\procedure toggle-content()
<$parameters openState="" open="[<openState>substitute[]get[text]else[no]]" openImage="$:/core/images/down-arrow" closedImage="$:/core/images/right-arrow" openCaption="" closedCaption="">
<%if [<openState>!is[blank]] %>
<$checkbox tiddler={{{ [<openState>substitute[]] }}} field="text" checked="yes" style.appearance="none">
<span style.cursor="pointer">
<%if [subfilter<open>match[yes]] %>
<$transclude $tiddler=<<openImage>> size="1em" /> <<openCaption>>
<%else%>
<$transclude $tiddler=<<closedImage>> size="1em" /> <<closedCaption>>
<%endif%>
</span>
</$checkbox>
<%endif%>
</$parameters>
\end

\procedure expandable-list()
\whitespace trim
<$parameters filter="" openState="" open="[<openState>substitute[]get[text]else[no]]">
<ol>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/Stylesheet]!has[draft.of]]">
<$list filter=<<filter>> >
<li>
<$link>
<$view field="title"/>
</$link>
<$set name="source" tiddler=<<currentTiddler>>>
<$wikify name="styles" text=<<source>>>
<pre>
<code>
<$text text=<<styles>>/>
</code>
</pre>
</$wikify>
</$set>
<$transclude $variable="toggle-content" open=<<open>> openState=<<openState>> />
<$link/>
<%if [subfilter<open>match[yes]]%>
<<expandable-content>>
<%endif%>
</li>
</$list>
</ol>
</$parameters>
\end
\whitespace trim

<$vars modeState=<<qualify "$:/state/peek-stylesheets/mode/">>>
<$let modeState=`$:/state/peek-stylesheets/mode/$(qualify)$` mode={{{ [<modeState>get[text]else[expand]] }}} listFilter="[all[shadows+tiddlers]tag[$:/tags/Stylesheet]!has[draft.of]]">

<$reveal type="nomatch" state=<<modeState>> text="expanded" tag="div">
<$button set=<<modeState>> setTo="expanded" class="tc-btn-invisible">{{$:/core/images/chevron-right}} {{$:/language/ControlPanel/Stylesheets/Expand/Caption}}</$button>
</$reveal>
<$reveal type="match" state=<<modeState>> text="expanded" tag="div">
<$button set=<<modeState>> setTo="restored" class="tc-btn-invisible">{{$:/core/images/chevron-down}} {{$:/language/ControlPanel/Stylesheets/Restore/Caption}}</$button>
</$reveal>
<$transclude $variable="toggle-content" openImage="$:/core/images/chevron-right" closedImage="$:/core/images/chevron-down" openState=<<modeState>> openCaption={{$:/language/ControlPanel/Stylesheets/Expand/Caption}} closedCaption={{$:/language/ControlPanel/Stylesheets/Restore/Caption}}/>

<$reveal type="nomatch" state=<<modeState>> text="expanded" tag="div">
<<expandable-stylesheets-list>>
</$reveal>
<$reveal type="match" state=<<modeState>> text="expanded" tag="div">
<<stylesheets-list>>
</$reveal>
<%if [<mode>match[expand]]%>
<$transclude $variable="expandable-list" filter=<<listFilter>> open="yes"/>
Copy link
Member

@pmario pmario Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "open", "closed" state value is wrong. It is expanded and restored
Have a look at the state: https://tiddlywiki.com/#%24%3A%2Fstate%2Fpeek-stylesheets%2Fmode%2F-1116772087 at tiddlywiki.com and at: https://deploy-preview-8794--tiddlywiki-previews.netlify.app/#%24%3A%2Fstate%2Fpeek-stylesheets%2Fmode%2F-1116772087

current Version v5.3.6

image

PR version

image

It is not possible to change those values for backwards compatibility reasons. There may be unwanted side effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, sorry for the oversight 😅 I'm marking this PR as a draft for now and will request a review after more thorough testing.

<%else%>
<$transclude $variable="expandable-list" filter=<<listFilter>> openState="$:/state/peek-tiddler/open/$(currentTiddler)$$(qualify)$"/>
<%endif%>

</$vars>
</$let>
Loading