Clarity is a scalable, accessible, customizable, open-source design system built with web components. Works with any JavaScript framework, created for enterprises, and designed to be inclusive.
cds-icon could be more flexible if the CSS transforms were applied to the svg child element instead of the host.
What is the change?Move CSS transforms from the host into the svg element.
Why should it go in Clarity?It would make cds-icon easier to customize in cases where it is nested further inside other libraries/components. It would be possible to change the transforms with just CSS and without losing the underlying rotation.
Does this change impact existing behaviors? If so how?Yes. Any users with existing workarounds for this issue would have their icons further rotated unless they remove the workaround.
Use case
Current
If I have a caret pointing down, the HMTL looks like this:
This means that I will lose the transform: rotate(180deg); if I try to add any transformations like transform: translateY(10px);. It means I'll have to be mindful and use transform: rotate(180deg) translateY(10px); instead. And if it is a generic style for any cds-icon direction, I'll have to make extra adjustments for that as well.
Proposed
Maybe the current could be improved if cds-icon applied its transforms to the svg instead of the host.
This would leave the host cds-icon without any transforms, making it possible for users to add their own without worrying about overriding clarity's transforms (eg. downward rotation).
Summary
cds-icon
could be more flexible if the CSStransform
s were applied to thesvg
child element instead of the host.transform
s from thehost
into thesvg
element.cds-icon
easier to customize in cases where it is nested further inside other libraries/components. It would be possible to change thetransform
s with just CSS and without losing the underlying rotation.Use case
Current
If I have a caret pointing down, the HMTL looks like this:
and I can see the following style being applied by the constructed stylesheet:
(source)
This means that I will lose the
transform: rotate(180deg);
if I try to add any transformations liketransform: translateY(10px);
. It means I'll have to be mindful and usetransform: rotate(180deg) translateY(10px);
instead. And if it is a generic style for anycds-icon
direction, I'll have to make extra adjustments for that as well.Proposed
Maybe the current could be improved if
cds-icon
applied itstransform
s to thesvg
instead of the host.This would leave the host
cds-icon
without anytransform
s, making it possible for users to add their own without worrying about overriding clarity's transforms (eg. downward rotation).