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

Sidebar-resizer: change $:/themes/... tiddlers #8663

Open
wants to merge 82 commits into
base: master
Choose a base branch
from

Conversation

BurningTreeC
Copy link
Contributor

@BurningTreeC BurningTreeC commented Oct 4, 2024

This PR uses the same mechanism as #8644 but changes the $:/themes/tiddlywiki/vanilla/metrics/... tiddlers directly.
Note that in fixed-fluid mode the story-river actually changes its width but the tiddlerwidth 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:

  • should it be possible to make the story-river overlap the sidebar / the slider?
  • should the tiddlerwidth in fixed-fluid mode be updated? (keeping the gap between sidebar and story-river)

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/

Copy link

stackblitz bot commented Oct 4, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

github-actions bot commented Oct 4, 2024

Confirmed: BurningTreeC has already signed the Contributor License Agreement (see contributing.md)

@BurningTreeC
Copy link
Contributor Author

@Jermolene @saqimtiaz @pmario

sorry for tagging you 😸
But if you have time, could you test?
Especially fixed-fluid mode needs testing.
This here now works with pixel and percentage values.
It updates the $:/themes/... tiddlers directly.
In fixed-fluid mode it updates storyright and storyleft.
There's also the option to slide using ctrl in fixed-fluid mode. ctrl makes it possible to move the sidebar further to the left if there's a gap between story and sidebar. To test that, maybe set the storyright to 75% and the storywidth to 45% and the tiddlerwidth to 100% ... it becomes easier to understand like that.

The calculations are now done in wikitext in the procedures.
One thing I had to limit to not become less than 0 which is the storyleft.

@BurningTreeC
Copy link
Contributor Author

This works now with all absolute css metrics:

Bildschirmfoto vom 2024-10-06 10-41-34

Including percentage, which is easy to calculate.
If a metric was for instance "pt" or "%" before starting to resize, it will be updated as "pt" / "%" and so on.

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...

@BurningTreeC
Copy link
Contributor Author

As I said above, in fixed-fluid mode I'm not settled about how the gap between story-river and sidebar should be handled.
This implementation however can be modified easily in that regards

@pmario
Copy link
Member

pmario commented Oct 6, 2024

@BurningTreeC -- I did checkout this branch and did run it, but I can not find any resizer. I think I'm missing something

@BurningTreeC
Copy link
Contributor Author

Now the "tight" and "tight-heavier" themes use their own metrics for "storywidth", "storyright", "sidebarwidth", "tiddlerwidth" and the new metrics "storypaddingleft" and "storypaddingright"

The centralised theme also uses its own metrics for where it's worth it

Now I don't want to change any more here until some feedback if I'm going in the wrong direction or not

@BurningTreeC BurningTreeC marked this pull request as ready for review October 11, 2024 17:10
@linonetwo
Copy link
Contributor

linonetwo commented Oct 13, 2024

@BurningTreeC Is it possible to reuse this in other layouts, like in your multi-column layout to resize columns?

Surprising that this can be done in pure WikiText.

I think the update logic nees some debounce, for example use https://tiddlywiki.com/#RefreshThrottling . https://github.com/Gk0Wk/TiddlySeq/tree/master/src/sidebar-resizer has some throttle logic using requestAnimationFrame in its TS.

@BurningTreeC
Copy link
Contributor Author

Hi @linonetwo
It should be possible to reuse this in other layouts, if those other layouts use the vanila metrics.
The multi-column layout (TiddlyFlex ? ) doesn't use the vanilla metrics but I plan to change that.
Oh yes! I didn't think about refresh throttling! Thank you!

@BurningTreeC BurningTreeC marked this pull request as draft October 13, 2024 15:11
@BurningTreeC
Copy link
Contributor Author

@Jermolene @pmario @linonetwo @saqimtiaz
This now uses refresh throttling on the $:/themes/... tiddlers involved in the resize process. Idea comes from linonetwo 👍

@BurningTreeC BurningTreeC marked this pull request as ready for review October 13, 2024 15:31
@Jermolene
Copy link
Member

@Jermolene @pmario @linonetwo @saqimtiaz This now uses refresh throttling on the $:/themes/... tiddlers involved in the resize process. Idea comes from linonetwo 👍

I can't try it right now, but doesn't that make the sidebar resizing jerkier?

@BurningTreeC
Copy link
Contributor Author

@Jermolene @pmario @linonetwo @saqimtiaz This now uses refresh throttling on the $:/themes/... tiddlers involved in the resize process. Idea comes from linonetwo 👍

I can't try it right now, but doesn't that make the sidebar resizing jerkier?

No because refresh throttling isn't used for the refresh of the styleWidgetNode in render.js

@BurningTreeC
Copy link
Contributor Author

Maybe not having refresh throttling on the styleWidgetNode is a mistake?

}

<%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fluid-fixed]] %>

html .tc-sidebar-resizer {
left: clamp(calc({{$:/themes/tiddlywiki/vanilla/metrics/storyleft}} + {{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}}),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}}),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}}));
left: clamp(calc({{$:/themes/tiddlywiki/vanilla/metrics/storyleft}} + {{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}}),calc(100% - {{$:/themes/tiddlywiki/tight/metrics/sidebarwidth}}),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}}));
}

<% endif %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean, if I install a user developed theme, then I have to edit it like above to support the sidebar resizer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @kookma - I don't think it's possible to make the resizer compatible with all possible themes out of the box
That's because one theme uses these metrics, another theme uses different metrics, one theme has the sidebar at the left, the other at the right...

Copy link
Contributor

Choose a reason for hiding this comment

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

But seems Gk0Wk's JS version sidebar-resizer can adapt to every themes? At least itonnote theme haven't done any adaption to it. Of course it has limintation, like it force the unit to be vw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it was asked to change the theme metrics directly. If a theme uses different metrics tiddlers than the vanilla ones it becomes a bit more complex. But I think we could make it easier for other themes to adapt the resizer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@linonetwo - having a look at Gk0Wk's JS resizer at https://gk0wk.github.io/TiddlySeq/#%24%3A%2Fplugins%2FGk0Wk%2Fsidebar-resizer%2Fhook.js I doubt that it can work with fixed-fluid vanilla mode for example. In fact, on the demo page try to set the mode to fixed-fluid... It changes the sidebarwidth only and does not adapt to other themes or theme-options.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's possible to make the resizer compatible with all possible themes out of the box

Thank you for the clarification! So, some default core themes will support the sidebar resizer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @kookma , please don't get me wrong. My intention is to make it possible for other themes to adapt the resizer. I will just have to think about it for a while

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the clarification! So, some default core themes will support the sidebar resizer.

All default core themes support the resizer at the moment.
I'm thinking about other themes that have the sidebar at the left for example. Those themes would need to set a specific config tiddler to yes and we could make the resizer adapt to it.
But I believe themes must use the metrics of the currently selected theme, otherwise this isn't possible.
Please ask if you have any questions

@BurningTreeC
Copy link
Contributor Author

I've made the sidebar resizer work for html dir="rtl" - adding a variable html-direction to the eventcatcher widget (documented).
The sidebar resizer is hidden by default, one can enable it in the ControlPanel > Appearance > ThemeTweaks.
The sidebar resizer uses the theme metrics if they are present, so for example if a theme is called $:/themes/burningtreec/theme and it has the metric $:/theme/burningtreec/theme/metrics/storyright, that metric gets updated. Falls back to the vanilla theme metric if not present.

@BurningTreeC
Copy link
Contributor Author

This now adds an option to show the sidebar on the left, it doesn't do so anymore by default if html dir="rtl"
I've put a current build here: https://sidebar-resizer-config.tiddlyhost.com/
Go to the ControlPanel > Appearance > ThemeTweaks tab and play with the options
Also, try the themes centralised and tight

@BurningTreeC
Copy link
Contributor Author

This also adds some sensible adjustments for html dir="rtl" but mostly the tc-tiny-gap / tc-small-gap / tc-big-gap classes

@BurningTreeC BurningTreeC marked this pull request as draft October 20, 2024 17:04
@BurningTreeC
Copy link
Contributor Author

I've fixed the story-river not showing correctly when the sidebar is hidden
https://sidebar-resizer-config.tiddlyhost.com/

@BurningTreeC BurningTreeC marked this pull request as ready for review October 21, 2024 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants