-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Sidebar-resizer: change $:/themes/...
tiddlers
#8663
base: master
Are you sure you want to change the base?
Sidebar-resizer: change $:/themes/...
tiddlers
#8663
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Confirmed: BurningTreeC has already signed the Contributor License Agreement (see contributing.md) |
sorry for tagging you 😸 The calculations are now done in wikitext in the procedures. |
This works now with all absolute css metrics: Including percentage, which is easy to calculate. The internal calculations are all done in pixel, so this first converts everything to pixel, then calculates, then converts back to the corresponding value. I don't know if this can also support other relative css metrics... |
As I said above, in fixed-fluid mode I'm not settled about how the gap between story-river and sidebar should be handled. |
@BurningTreeC -- I did checkout this branch and did run it, but I can not find any resizer. I think I'm missing something |
|
||
\procedure get_theme-tweaks_lingo() <$transclude $variable="lingo" title={{{ [[Metrics/]addsuffix<metricName>] }}}/> | ||
|
||
\procedure get_theme-tweaks_lingo-hint() <$transclude $variable="lingo" title={{{ [[Metrics/]addsuffix<metricName>addsuffix[/Hint]] }}}/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not use underscores in the core at the moment and you should not start with it. It will cause consistency problems. So get-theme-...
should be fine
If you think it is too similar to the function names, getThemeTweaksLingo()
may be an option too
@@ -2,6 +2,12 @@ title: $:/themes/tiddlywiki/vanilla/themetweaks | |||
tags: $:/tags/ControlPanel/Appearance | |||
caption: {{$:/language/ThemeTweaks/ThemeTweaks}} | |||
|
|||
\function get.theme-tweaks.metric() [get.theme<metric>] | |||
|
|||
\procedure get_theme-tweaks_lingo() <$transclude $variable="lingo" title={{{ [[Metrics/]addsuffix<metricName>] }}}/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try substitution instead of a filtered transclusion <$transclude $variable="lingo" title=`Metrics/$(metricName)$`/>
It is simpler
core/wiki/macros/sliders.tid
Outdated
</$let> | ||
\end | ||
|
||
\procedure two-cell-slider(width:"100%",minHeight:"10px",templateLeft:"",templateRight:"",mode:"block",sliderWidth:"12px",padding:"12px",sliderCondition:"yes",leftMinWidth:"100px",rightMinWidth:"100px") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
procedure parameters allow newlines. So it should be possible to make this line more readable
core/wiki/macros/sliders.tid
Outdated
tv-set-storywidth-storyright="no" | ||
tv-set-sidebarwidth="yes" | ||
tv-set-centralised="no" | ||
storyLeftTiddler={{{ [<storyLeftTiddler>!is[blank]] :else[<qualify>addsuffix[-]addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyleft-]] }}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the :else
path the first addsuffix[-]
after <qualify>
is redundant, since it is turned into a number with sha256[]
So removing the first addsuffix[-]
should make the string a little bit shorter
\function convert.to.in(value) [<value>divide[96]] | ||
\function convert.to.pc(value) [convert.to.in<value>multiply[6]] | ||
\function convert.to.pt(value) [convert.to.in<value>multiply[72]] | ||
\function convert.to.em(value) [[storyTiddler]is[variable]then<value>divide{$:/themes/tiddlywiki/vanilla/metrics/bodyfontsize}] [[storyTiddler]!is[variable]then<value>divide{$:/themes/tiddlywiki/vanilla/metrics/fontsize}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure, but I think if storyTiddler
in the function above is a variable the then
will create a value. But there is a second element without an :else
-- So I am not sure if this filter will work. Did you test it?
@@ -26,17 +28,34 @@ Metrics/FontSize: Font size | |||
Metrics/LineHeight: Line height | |||
Metrics/BodyFontSize: Font size for tiddler body | |||
Metrics/BodyLineHeight: Line height for tiddler body | |||
Metrics/PreviewSliderWidth: Preview slider width | |||
Metrics/PreviewSliderWidth/Hint: the width of the slider between editor and editor preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those hints within a sentence? Otherwise they should start with capital letters
list-after: $:/core/ui/PageTemplate/story | ||
code-body: yes | ||
|
||
\import [function[get.base.functions.theme],<get.current.theme>first[]is[tiddler]] :else[function[get.base.functions.theme],<get.current.theme>first[]is[shadow]] :else[[$:/themes/tiddlywiki/vanilla/functions]] [[$:/core/procedures/sidebar-resizer]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add an empty line after \import
for better readability
\function drag.direction.reverse() [<get.theme.option sidebarposition>match[left]then[yes]] :else[[no]] | ||
\whitespace trim | ||
|
||
<%if [<get.theme.explicit.option sidebarresizer>match[show]] %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<%if %> should not need an empty line, if the block is indented.
storyPaddingRightTiddler=<<get.story-padding-right.tiddler>> | ||
> | ||
|
||
<$transclude $variable="sidebar-resizer"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the leading and trailing new-lines should be removed. I am not sure if <$transclude
will need a $mode="block"
or not. But there should be no empty lines here
made also a quick change that broke the styling of the slider - sorry |
No need to be sorry. It's still WIP. At the moment I do have a look, if we can make some functions simpler. BTW -- you can add some I use comments whenever my own functions or procs, "trick" me and I change something. Just to find out, that I introduced an error. just some thoughts |
I don't even know what I'm doing 😉 so how should I comment it? |
@@ -1,18 +1,18 @@ | |||
title: $:/core/ui/EditTemplate/body/default | |||
|
|||
\function get.edit-preview-state() | |||
\function edit-preview-state() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions need a dot .
in the function name. Otherwise thy can only be used with [function[get-preview-state]]
-- For the core we need the possibility to use it with [tf.get-preview-state<something>]
too.
That's why I did start with tf.
prefix eg: tf.function-name-with-hyphens
for TW global functions. If you search the source code for tf.
, you will see some of them in the TW core code already.
At the moment they are only used for $:/tags/Global
functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the draft pr branch https://github.com/pmario/TiddlyWiki5/blob/toc-v5.3.x-rewrite/core/wiki/macros/toc.tid you can see it used extensively. Otherwise the code would be unreadable. There is some info about the naming schema in code.
Try use GPT o1 for this. BTW, I'm trying to use LLM to add comment to all TW core wikitext, if you aleady add some, LLM will thank you for making it easier :P |
Hi @Jermolene @saqimtiaz @pmario @linonetwo I've now done some experiments using Anyway, now this PR fixed an important problem which is the editor and preview redrawing when resizing. Fixed 🥳 ! I had to use some JS for |
This PR uses the same mechanism as #8644 but changes the
$:/themes/tiddlywiki/vanilla/metrics/...
tiddlers directly.Note that in fixed-fluid mode thestory-river
actually changes its width but thetiddlerwidth
remains fixed width as there was no discussion yet how we handle this. I just made the tiddlers adapt to the story-river if the story-river-width goes below the tiddlerwidth.There are some design questions:
I haven't yet added the ControlPanel configurations used for storyminwidth and sidebarminwidth.This PR is just for completeness, I will update it so that we can compare with other possible solutions.
In the meantime this PR has been updated quite a bit, I've put a current build here:
https://sidebar-resizer-config.tiddlyhost.com/