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

[css-env][css-link-params] Function to access stylesheet URL data #10820

Open
Crissov opened this issue Sep 2, 2024 · 0 comments
Open

[css-env][css-link-params] Function to access stylesheet URL data #10820

Crissov opened this issue Sep 2, 2024 · 0 comments

Comments

@Crissov
Copy link
Contributor

Crissov commented Sep 2, 2024

In #6408, I apparently misremembered the existence of a proposal for a pseudo-function similar to attr(), var() or env(), so I will hereby submit one. ;)

The Link Parameters module specifies several ways to pass parameters
from a stylesheet (link-parameters property, url() function) or a random URL (#param()), e.g. embedded within an HTML document,
to a target resource that understands CSS Custom Properties, i.e. usually a stylesheet or an SVG image.

This proposal is about a more generic way at the receiving end:
A new pseudo-function, say arg() (TBB), gives access to the query parameters used in the URL to include the stylesheet (or HTML/SVG/… document in case of inline styles). It works mostly identical to attr(), just is the same for all elements.

Variant: Instead of the URL parameters of the stylesheet, arg() accesses the query component of the host document. For SVG images with inline styles, the end result is the same.

/* in example.svg?color=green */
:root {
--foo: arg(color); /* green */
}
#test {
  fill: var(--foo);
  stroke-color: arg(color);
}
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

2 participants