Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
290 stars 76 forks source link

[Enhancement] Use `part` html attribute to make styling easier #7353

Closed maxpatiiuk closed 1 year ago

maxpatiiuk commented 1 year ago

Check existing issues

Description

A part html attribute exists to allow developers using web components to style elements in shadow DOM.

Calcite does not appear to be using it at all at the moment.

Acceptance Criteria

part and exportparts html attributes are utilized generously in Calcite web components to make styling easier

Alternatively, add more css variables and props to give more control of web component internals

Relevant Info

Stencil docs:

MDN docs:

Which Component

I need this in <calcite-action> and <calcite-slider> at the moment, but theoretically in all components

Example Use Case

I am using <calcite-action> and <calcite-slider> inside of <calcite-action-group>.

At the moment, I solve these issues by injecting my styles into the web component by creating a <style> tag inside of it using JavaScript, but that solution is hacky and fragile:

Screenshot 2023-07-20 at 15 55 35

Priority impact

p3 - want for upcoming milestone

Calcite package

Esri team

ArcGIS Maps SDK for JavaScript

macandcheese commented 1 year ago

Following up from Teams - At this point we aren't planning to add css parts. We've discussed it as something to re-evaluate in the future, but for now we plan to use css variables to expose intended theming.

That said - our upcoming work to introduce design tokens should make overriding things like box-shadow, border-radius, etc., much easier with system or component level theming. This effort can be tracked here: https://github.com/Esri/calcite-design-system/issues/7180

The Action Pad should be able to achieve that layout in the meantime: https://codepen.io/mac_and_cheese/pen/mdQzRXo?editors=1000