-
Notifications
You must be signed in to change notification settings - Fork 8
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
Discuss how to customize appearance #7
Comments
Related: designers and developers often include the words "on" and "off" coupled with the switch. While there's an argument that such a decision could be left up to authors, I think it'd be good if there was an out of the box option to print the current state. Since the control itself should announce its state as "on" and "off", it'd be good to mitigate developers having to add in separate text reflecting the appropriate state, resulting in screen readers then potentially announcing "name of control, on, switch, on". The control should only need to announce its state once. Personally, I prefer Microsoft's approach, where the state is printed outside of the control as it is far more suitable for different languages. Developers could then use CSS to position the text, provided by the control, as they need to. Thanks |
Again, thanks for prompting this discussion. I've been digging into controls and components quite a bit lately and I think we have to standardize on the guts in order for these to be successful (I've spun up a repo to begin collating controls we plan to standardize here. This can be done in a myriad of ways but we already see issues across the web where developers either want to add one additional thing or add a style that isn't reachable within the component. So I think shadow parts are the way to go. That said, style is only one aspect of appearance so I think that each piece should also be a slot itself. For example, here is a more extreme version of a switch control that I feel should be possible using this control if provided slots & parts.
I think if we polled people we would get numerous different opinions and why I think we should make everything adjustable and where possible extensible. Although, for this one - let's not scope creep on the extensibility. One final question @tkent-google, I was under the impression that UA based web components could have their shadow roots interacted with (is this incorrect)? Or are you bypassing this by utilizing this as module include? |
+1 on external text. I am wary of localization factors (including automated translation) and poor contrast decisions by developers. |
To clarify my above statements, I agree that the solution that we have out of the box should be the best accessible option - so +1 to the external text. That said, I ultimately want authors to have free reign over the control so that they keep the majority of the good while not feeling like they're trapped to where they resort to creating their own (our current state of the web) which usually results in some type of accessibility issue (be it keyboard, name computation, color contrast, or all of the above). |
completely agree @gregwhitworth and thanks. I definitely don't want to go nuts with feature creep here / anything too flashy out of the box. But give authors a good base of the options we commonly see (a track, grip/knob, optional text, and maybe the allowance for |
Shadow parts and custom properties. A few custom properties if you just need to tweak the colors to fit your site and shadow parts for when you need more control. When the label/color occupies the space where the thumb would be if it were in the opposite state, my first thought is always that I need to slide the thumb there to put the control into that state—I have to stop and remind myself that, no, it's like a light switch rotated clockwise so that's an indication of the current state. It's worse than no label/color as it short circuits my intuition. The MS approach of putting the label next to the control is much clearer to me. |
We made a prototype and a demo page. https://tkent-google.github.io/std-switch/demo.html The prototype supports some custom properties As for text labels, I think
I don't understand the intention of this question. Anyway, any built-in modules including |
BTW, thanks for the demo. |
Hi @tkent-google, just looking for clarification here. Do you mean text labels as in providing the switches with their accessible names? (i see in the demo the switches have been wrapped in a Or when you say text labels are you referring to my request to allow for the state to be displayed in a text format? If the latter would you mind explaining why you don't think they are necessary to be supported? Thanks |
Note that proper accessibility support is blocked on whatwg/html#4658, although we can certainly add patches to make it easier to evaluate in the meantime, even if it won't be full fidelity like a native control yet. In general the idea is that this should be like a built-in HTML control in all ways possible, including accessibility, label-ability, or how the presence of shadow stuff is unobservable (e.g. you can't notice that select or details or input type=date are implemented using shadow DOM in Chrome; same for std-switch). I'm hopeful that we can still expose shadow parts (track and thumb). I think the predefined set of variables is a bit too limiting, for cases such as @gregwhitworth's demo. Exposing them would definitely constrain future evolution, but I think in practice it's more important that this be flexibly style-able, than that it be forever changeable. This is something to explore further, probably. |
Following up on @scottaohara's note, the |
Should we rename this thread to be broader and close all the other accessibility threads? It seems all the accessibility review is happening here, instead of talking about appearance customization. |
No. Appearance has an accessibility aspect. Closing the other threads does not resolve any concerns in those threads. All parts of this control potentially have an accessibility aspect. If we try to move all accessibility concerns into one thread then as another discussion of appearance happens you can expect accessibility concerns will be raised in that discussion. I would rather not see the accessibility concerns relegated to a corner (like Baby for "Dirty Dancing" fans). For example, using |
@domenic my comment is related to accessibility / UX of the control, but allowing for text of the visible state is also related to the customization of the visual appearance. |
Yes, I meant text on the control like the image in your first post in this thread. If a web developer really needs to add such text, he/she can specify background images containing text to the control even with the current prototype, or can place text outside of the control on the control by However, I have an idea to make it easier. I updated the demo and the prototype so that we can add text by child nodes of |
Thank you for the response @tkent-google A bit of a clarification regarding the state text though. You said "Apple's design guide discourages it", which is true, but that's because there's a built in option to display, and Apple is trying to discourage duplicate state announcements: I appreciate you adding the |
I saw this and I'm curious how this is intended to work in production. I'm assuming that we wouldn't spec
Shadow parts are intended for this exact use case, so I hope we can find the right balance between customizability and encapsulation here. Otherwise, we have a lot of work to do still on styling primitives. Given that shadow parts only expose elements specifically marked, and not their children or context, I'm hopeful that the current ::part() implementation (outside of the obvious need for ::theme() here) is sufficient. We did talk about property white- and black-lists at the last web components face-to-face, but there was nothing conclusive. Currently some protection of critical properties should be possible by have rules in the shadow root that select by part attributes. |
Now I think preserving CSS custom property names by 'standard' elements would be harmful. |
In the latest Chrome Canary,
I think this structure is enough. We can customize (The source CSS is here) |
Agreed, that seems to work pretty well. I think documenting it in the readme and closing this issue makes sense. |
@tkent-google I'm not seeing this in canary, did the name change or was it reverted? |
Chrome Canary has the implementation with the part names in my previous comment. It's still behind the experimental feature flag chrome://flags/#enable-experimental-web-platform-features and need |
CSS Shadow Parts or CSS custom properties?
The text was updated successfully, but these errors were encountered: