-
Notifications
You must be signed in to change notification settings - Fork 16
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
Name (key) parts of components #497
Comments
Relative to @zcorpan's question, I was wondering what the pros and cons of going this route vs allowing the user to turn controls off / prune the set of controls that are presented, and subsequently provide their own controls, per how Relative to developers providing their own controls, it might be useful to consider a special 'static' layer, that the user could declaratively add and add their own controls to, and render / layout with CSS Grid, which would not pan or zoom with the map, i.e. would behave similar to what the Leaflet |
An important consideration and difference between adding custom controls (for styling purposes) vs styling default controls is that in the latter accessibility & localization is mostly handled by the UA for the author. I think defining parts for (default) controls in particular can be viewed as a precedent for potentially future standard pseudo-elements (although currently only vendor-prefixed ones are available for styling video controls, such as:
Video and other native elements will not be updated to use
After defining all necessary parts (possibly (and parts of) features, layers, controls, etc.), I think anything that is not defined as such can be considered noise (there are a lot of "unnecessary"
I think that'd complicate |
Another example is setting ::part(layer) { mix-blend-mode: /*<blend-mode>*/ } |
An alternative/additional way to enable custom CSS is to utilize Custom Properties, as they apply cross shadow boundaries. Example: <style>
mapml-viewer {
--mapml-controls--size: 24px; /* overrides the value defined in mapml.css due to higher selector specificity */
}
</style>
<mapml-viewer>
#shadow-root
<link rel="stylesheet" src="mapml.css">
<!-- mapml.css:
:host {
--mapml-controls--size: 44px;
}
.leaflet-control a {
height: var(--mapml-controls--size);
width: var(--mapml-controls--size);
}
-->
</mapml-viewer> This approach would probably require a lengthy list of variable definitions though, depending on which parts of the map UI we want to allow customization of (controls (size, color, bg-color, etc.), features (fill, stroke, etc.), and so on). |
In line with Open UI's component spec template we should name parts of components using the HTML
part
attribute.This would enable author- and user style sheets (requested in #297) via the CSS
::part()
pseudo-element. And to some extent help us answer how styling MapML with CSS works.Example
If we set
part="reload-button"
on the reload button, authors (and users/user style sheets) can now style the reload button:Notes
We should document any named parts as eligible for styling (related: Maps4HTML/web-map-doc#26).
References
part
attribute definition: https://www.w3.org/TR/css-shadow-parts/#part-attr (91%~ browser support)::part
pseudo-element definition: https://www.w3.org/TR/css-shadow-parts/#part (91%~ browser support)The text was updated successfully, but these errors were encountered: