-
Notifications
You must be signed in to change notification settings - Fork 213
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
Title bar customization: new CSS properties for easier layout #177
Comments
I'm a bit curious why the existing CSS env() properties for notches don't work here. Why not just consider the close/maximize/minimize buttons as a notch? That way people can code for both phone PWA notches and desktop PWA windows at the same time. |
From W3C CSS Environment Variables:
According to that description, combining all the insets together creates a rectangle that the developer can safely draw in, and we can't shrink this rectangle further than necessary. If we were to return two We could still set |
@domenic How do you envision that exactly? The safe-area-inset-X properties currently seem to describe the largest possible rectangle which can be drawn, unobstructed in the viewport — the “safe” zone for content, with any parts of viewport rect outside the rectangle described by safe-area-inset-X not guaranteed to be visible. If the same vars are used to indicate where overlaid controls are, it seems like the rectangle being described ends up being something pretty different:
I don’t think these are the same concept (we want to draw in the middle top “unsafe” rect in example 2, as well as both allegedly unsafe rects in the second row of example 2), but I’m not sure if I’m missing something... Edit: seems I was writing at the same time as @amandabaker, who addressed the same thing, so this is a bit redundant now that I see that response too. |
I see your point, and the diagram is very helpful. However this feels like a failure of the CSS safe-inset spec to me... or at least an opportunity for extending it, instead of having two specs side by side. In particular, what is really different here?
It's surprising that would need a whole new model. More concretely, referring to your diagram, I'd argue that the top area (between the two notches) should be counted as "unsafe" similar to the iOS "ears". It's where you draw extra information that might jut up against OS/hardware constraints. The side areas being counted as "unsafe", though, is a bit wierd, and perhaps an area to explore tweaking the spec regarding... I'll note that I might be totally wrong, and perhaps the two differences I list are enough to need a whole new model. But I think it's worth exploring, and perhaps getting the CSS WG's opinion. |
I imagine you’re right that a unified API is (or at least would have been...?) possible. The ‘largest real rectangle’ concept has been useful, but it’s pretty tailored to needs related to a specific generation of devices. One currently expects the unsafe zone to be small and effectively decorative (e.g. allowing a header’s background image to extend into that area while ensuring the header’s text doesn’t). But the largest-rectangle model for “safe area” wouldn’t be very helpful at all for handling layout within, say, a circular display ... not that I know of any, but I think that extreme example aligns with your sense that the current safe-inset model may be underbaked. For both notches and titlebar components you can say the data we want to act on is “the effective viewport shape, which might not really be the viewport rect.” I have no idea what an API for that would look like though — it doesn’t seem like css env vars could readily express that if it can be some rando polygon / path. That said, I still tend to think “shape of display” and “positions and dimensions of titlebar chrome” are pretty different. In the latter case, it’s significant that the titlebar area is a titlebar — it’s not just “available space,” it’s space where, if available, one likely wants to render titlebar stuff. So I’m not certain how one would write CSS that works correctly for both titlebar layout and non-rectangular display bleed if the vars were conflated — we need at least some signal that it’s space which exists for that purpose. Plus conflation seems to include an assumption that there’d never be titlebar components within a non-rectangular display, which seems iffy. |
Hello 👋 . I was asked to chime in here since I have experience with safe-insets while adding them to Ionic. After reading over things, I think the safe-area insets take a care of a lot this. For example, given some markup: <header-cmp>
<title-cmp>My App</title-cmp>
</header-cmp>
<content-cmp></content-cmp> We'd want "My App" to be below the safe-area, but still allow the header (and potential background color) to take up the full space
In ionic, we do this by applying padding to the title component and letting the header get cut off by the notch. If the device is rotated and the notch is on the start/end side this can still be handle by safe-insets as just adjust automatically. So far, the safe inset variables work well for us at Ionic, so I'm not sure there is any benefit of adding additional variables that could handle the same thing. As far as the new units, this can be very useful if there's enough by in from other vendors as well. If not new units, maybe env variables? header-cpm {
/* This could be 44px on iOS, 56px on chrome/edge on android, etc etc */
height: env(system-header-height);
} Though this doesn't account for headers that could have mult-line sections. Just some comments from a random dev 🙂 |
@mhartington In your screenshot, are the time and status icons are provided by the OS and you're just placing the background color behind those icons? If they are drawn by the OS, then that's not quite analogous to the problem that we're trying to solve: placing web content next to a resizable "notch" that is anchored in the top left or right corner. However, it could signal that it's not worth trying to sell this as a "notch" problem, and that maybe we should just propose unique CSS If you can control their placement, how do you ensure that they don't flow behind the notch? |
…le bar (#212) Update explainer to use and explain new CSS environment variables: `unsafe-area-top-inset-left/right`. CSS working group proposal: - [[css-env] Add environment variable for left/right bounds of notch](w3c/csswg-drafts#4721) Related issues: - #177 Title bar customization: new CSS properties for easier layout - #203 [Title Bar Customization] Consider using css env variables for `controlsOverlay` bounding rect
Added CSS environment variables in #212 |
We've received feedback from multiple people that the JS APIs for laying out the title bar are not ideal.
The CSS proposals include:
env()
. Maybeenv(caption-controls-inset-left/right/top/bottom)
?th
andtw
which operate similar tovh
andvw
, except within the width of the title barHowever, we have also received feedback that it's not worth adding CSS variables/properties/units that need to be standardized and maintained, when they are intended for such a niche use case, so this is something we should take into consideration as well.
Comments from other issues/discussions
From @mgiuca in #165
From @aarongustafson
The text was updated successfully, but these errors were encountered: