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-anchor-1] Area-specific styling #9332

Open
fantasai opened this issue Sep 9, 2023 · 2 comments
Open

[css-anchor-1] Area-specific styling #9332

fantasai opened this issue Sep 9, 2023 · 2 comments

Comments

@fantasai
Copy link
Collaborator

fantasai commented Sep 9, 2023

There are a number of things an author might want to change depending on which fallback position an anchor-positioned element lands in. Accommodating tethers is just one example, e.g. you might want a background gradient drawing outward from the anchor or other effects. We might not want this right away, but we probably want it eventually, so we should design a system that can easily accommodate it.

The current proposal uses a limited set of properties inside the @try blocks. In theory this list could be expanded. But

  • the more styling we allow, the more awkward this becomes, since the author can't organize their styles in more sophisticated ways
  • the more styling we allow, the worse the cascade problem becomes

Note: It's not totally worked out in Apple's proposal, but the fact that each fallback position can be identified and selected against lays out a path for extending styling as far as we want to go in the future.

@kizu
Copy link
Member

kizu commented Sep 10, 2023

The more I thought about it, the more, in my opinion, something container-query-like could be the best.

If children of an absolutely positioned element could query that element's position, we would be able to style them in any way we'd want (we'd need to have some containment on the element, though, I imagine? Which is usually ok for absolutely positioned elements).

This way, we could cover both area-specific styling and a more low-level anchor positioning if we somehow query any anchors' values:

  1. If we have area-specific styling with or without fallbacks, we could query which quadrant(s) our element is currently positioned into. Something like “is our popover in its block-start position?” or “is it in both block-start and inline-end”?

  2. If we have regular absolute positioning with anchors, what I'd want to test is something like “is inset-block-start of element1 smaller than inset-block-start of element2?”, basically, manually querying anchor() and anchor-size() and comparing them.

The main limitation of this is that we would have to have the containment on our absolutely positioned element, so the styles of children won't affect the positioning, so if we'd want our popover to visually collapse to content, that would have to happen on an element inside our popover, which can be a bit cumbersome. Unless we'd find a way to make it just work in some way?

@una
Copy link
Contributor

una commented Sep 13, 2023

I was imagining that we could use state queries for this and target the current position name (i.e. in current spec, the named @try block`)

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

4 participants