[ic-theme dx] consider replacing 'foreground selection' logic of slotted components with CSS Shadow Parts #161
Labels
card component
The generic component, includes both the web component and the React component
component: ic-theme
The generic component, includes both the web component and the React component
dx
Related to developers' experience
footer component
The generic component, includes both the web component and the React component
hero component
The generic component, includes both the web component and the React component
link component
The generic component, includes both the web component and the React component
spike
This issue needs to be researched and explored before determining a course of action
Summary
Currently, slotted components choose their 'foreground appearance' based off some non-trivial
getThemeFromContext
logic inutils/helpers.ts
on line 154. While this reduces the burden on developers implementing themed and slotted components (in any framework), it is not clean code to maintain.💬 Description
Take the below example. You will note that a custom theme of a yellow colour
rgb(255, 201, 60)
is used. The button used will be a 'dark foreground' variant (it will be black background and white text). Yet, the implementer has not had to set any props or configure that behaviour. The benefit of this, in the very edge case, that a theme changes during a render, relevant child components will choose an accurate appearance.However, this requires some non-trivial configuration in
src/utils/constants.ts
and code to be included in relevant 'clever' components. See lines 131 and 199 ofic-button.tsx
.💰 Use value
CSS Shadow Parts allow component authors to expose 'parts' of their DOM to implementers and allow CSS styling (almost all properties work) on those expose DOM elements.
I'm not suggesting we expose/document this to implementers, but it might streamline/clean up our implementation of themeing.
In future, this could also be exposed to ui-kit implementers, like the IONIC framework does, to allow further customisation of components (or parts thereof).
You can see this in action. The example below will add a yellow background to all
ic-card
s that are slotted intoic-hero
s, but only when theic-hero
is 'dark foreground'.Additional info
Read more:
::part
in every situation, for example: [css-shadow-parts] Can I use ::slotted and ::part together? w3c/csswg-drafts#5161The text was updated successfully, but these errors were encountered: