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

Root stylesheet refresh - Stylesheets in single <style> tags #8130

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

BurningTreeC
Copy link
Contributor

This PR is a follow-up to #8106 , #8118 and #8125
It's also related to the discussion #8128

This puts every tiddler tagged $:/tags/Stylesheet into its own <style> tag at the BOTTOM of the <head> section.
Why at the bottom? The list widget in $:/core/ui/RootStylesheet handles inserting and removing its list items all by itself. It does so by appending at the end of the <head> section. That's why from the beginning in render.js and windows.js I render the styleWidgetNode into the end of the <head> section and let the list widget do its "natural" flow.

This uses a modified view widget that's included in this PR. I'm not sure if I got @Jermolene right how it should be done but that's my try on it. It updates the textContent of its generated domNode in case the format is plainwikified, htmlwikified or htmlencodedplainwikified and the content changes, through a contained macro for example that changes.

The $:/core/ui/RootStylesheet distinguishes between standard Stylesheet tiddlers and Stylesheet tiddlers tagged $:/tags/Stylesheet/Static. In the latter case they are rendered as text and not refreshed which (I hope) makes it possible to save refresh time if we put static content into static Stylesheet tiddlers.

I open this as a draft PR since it has Performance Instrumentation enabled and the code might change based on the feedback I get.

Copy link

vercel bot commented Apr 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Apr 12, 2024 4:10am

Copy link
Contributor

@pmario pmario left a comment

Choose a reason for hiding this comment

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

Please take my ViewHandler comments with a "bit of salt", I think I'm not 100% sure what it actually should do.

The wiki itself seems to work, and the styles are added to the HEAD element

$tw.styleElement.innerHTML = $tw.styleWidgetNode.assignedStyles;
document.head.insertBefore($tw.styleElement,document.head.firstChild);

var styleParser = $tw.wiki.parseTiddler("$:/core/ui/RootStylesheet",{parseAsInline: true}),
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO $:/core/ui/RootStylesheet should also be added as a constant at the beginning of the code. see: PAGE_STYLESHEET_TITLE but it should be named PAGE_STYLESHEET_ROOT now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, I forgot to change that. Good thinking about the new name

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 @pmario - I wasn't sure about how to name the constant, so I left PAGE_STYLESHEET_TITLE untouched and added ROOT_STYLESHEET_TITLE and use that title

core/ui/RootStylesheet.tid Outdated Show resolved Hide resolved
@@ -1,5 +1,7 @@
title: $:/themes/tiddlywiki/vanilla/reset
type: text/css
tags: $:/tags/Stylesheet $:/tags/Stylesheet/Static
list-before: $:/themes/tiddlywiki/vanilla/base
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm, IMO that's not possible. If a user modifies the sort order by hand this shadow tiddler is converted to a system-tiddler and the list-before field is removed. -> That can lead to future problems for the user, if we change the reset.css again, because it is no shadow anymore

We will probably need to rename the tiddler to $:/themes/tiddlywiki/vanilla/_reset, so it will be automatically listed in front.

@Jermolene -- The problem is, that renaming is not 100% backwards compatible

core/modules/widgets/view.js Outdated Show resolved Hide resolved
core/modules/widgets/view.js Outdated Show resolved Hide resolved
core/modules/widgets/view.js Outdated Show resolved Hide resolved
core/modules/widgets/view.js Show resolved Hide resolved
@BurningTreeC
Copy link
Contributor Author

This PR now uses the view widget changes from #8135 for testing purposes

core/ui/RootStylesheet.tid Outdated Show resolved Hide resolved
core/ui/RootStylesheet.tid Outdated Show resolved Hide resolved
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.

None yet

2 participants