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

Fix stylesheet linking #108

Closed
aphillips opened this issue Jul 14, 2023 · 6 comments
Closed

Fix stylesheet linking #108

aphillips opened this issue Jul 14, 2023 · 6 comments
Assignees

Comments

@aphillips
Copy link
Contributor

Currently the local.css stylesheet is linked using <link rel=stylesheet...

Previously we used <style data-import=..., but this didn't allow the local stylesheet to be tested without committing the changes.

@r12a claims there is a different feature used by LReqs that can fix this. This issue is a placeholder to find and replicate that here.

@aphillips aphillips added the bug label Jul 14, 2023
@aphillips aphillips self-assigned this Jul 14, 2023
@r12a
Copy link
Contributor

r12a commented Jul 18, 2023

The way this is done in the lreq pages is as follows:

[1] Add this to the js configuration.

postProcess: [
		async function importStyleSheet() { 
			const elems = document.querySelectorAll(`link[rel='stylesheet'][data-import]`)
			await Promise.all(
				[...elems].map(async link => {
					const text = await fetch(link.href).then(r => r.text())
					const style = document.createElement("style")
					style.textContent = text
					link.replaceWith(style)
					})
				)
			}
		],

[2] add the following to the head element:

<link rel="stylesheet" data-import href="https://w3c.github.io/i18n-drafts/style/respec_2022.css">

I tried it with a Netlify link that @xfq provided, but it didn't include the styles in respec_2022.css, as far as i can tell. (see w3c/tlreq#10)

@r12a
Copy link
Contributor

r12a commented Jul 18, 2023

But it doesn't seem to have caught the styling from local.css either. Investigating further....

@r12a
Copy link
Contributor

r12a commented Jul 21, 2023

For some reason, Netlify or respec seems to just comment out the line that points to respec_2022.css. At least, that means it's possible to uncomment it using the inspector – then the styles are applied as expected.

@r12a
Copy link
Contributor

r12a commented Jul 21, 2023

And the styles are tweakable in the inspector after uncommenting that line, of course.

@xfq
Copy link
Member

xfq commented Jul 29, 2023

I don't have a good solution for this at the moment, but I think I found the cause of the issue:

For some reason, Netlify or respec seems to just comment out the line that points to respec_2022.css.

After looking at https://github.com/w3c/tlreq/blob/fe34099c58c0927dbe1688e648f8de809cf209e0/index.html#L49-L50

I saw that the first line was already commented out in the source code. The second line won't work in the preview, because it points to a relative link outside the repo. You can't really do a .. in:

https://deploy-preview-10--tlreq.netlify.app/

because it's already in the top level.

@aphillips
Copy link
Contributor Author

fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants