-
Notifications
You must be signed in to change notification settings - Fork 86
Update Icon
and Button
for SLDS2
#486
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
Conversation
reg-suit detected visual differences. Check this report, and review them. ⚪ 🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵 What do the circles mean?The number of circles represent the number of changed images.🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items How can I change the check status?If reviewers approve this PR, the reg context status will be green automatically. |
82e31be
to
4c04ff7
Compare
ef12184
to
ea7c2fa
Compare
ea7c2fa
to
7041867
Compare
7041867
to
73109a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/scripts/Icon.tsx
Outdated
} | ||
); | ||
|
||
export const SvgButtonIcon = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any special reason why SvgIcon
can't be reused for button icons? Does it require a different treatment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stomita
Yes, there is.
SvgButtonIcon
differs from SvgIcon
in its logic for generating classnames, and, above all, in the context where it is used.
When I decided to define SvgButtonIcon
separately, I judged it was too much to treat it as DRY.
However, it's also acceptable to unify them into a single component, so I did it in 288d955.
src/scripts/Icon.tsx
Outdated
const { assetRoot = getAssetRoot() } = useContext(ComponentSettingsContext); | ||
|
||
// icon and category prop should not include chars other than alphanumerics, underscore, and hyphen | ||
const icon = (icon_ ?? '').replace(/[^\w-]/g, ''); // eslint-disable-line no-param-reassign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-disable-
comment might not be needed (as the line now using new const for assignment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/scripts/Icon.tsx
Outdated
iconColor: fillIconColor, | ||
}} | ||
/> | ||
const ccontainerClassName = classnames( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containerClassName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9b0c467
to
5a141a3
Compare
src/scripts/Icon.tsx
Outdated
size?: IconSize; | ||
align?: 'left' | 'right'; | ||
container?: IconContainer; | ||
circleContainer?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the container variance may not be limited to just circle
, it's better to keep it as the current container
property rather than making it a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stomita
As far as confirming CSS classes in the spec, for now, only the variant of the container would be just a .slds-icon_container_circle
.
https://v1.lightningdesignsystem.com/components/icons/#CSS-Class-Overview
Thus, I think currently it's enough to define this prop as a boolean.
However, at the same time, I understand your opinion, if we consider changes in the future.
Therefore, I've tried to revert it to the container
prop in da113a2.
src/scripts/Icon.tsx
Outdated
tabIndex?: number; | ||
fillColor?: string; | ||
title?: string; | ||
currentColor?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the textColor
and currentColor
props are intended to be mutually exclusive and will not be used simultaneously, setting the textColor
prop to "currentColor" can accurately reflect the intent of developers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stomita
As you pointed, indeed, the spec says that the currentColor
and the other color settings (default
, success
etc) are mutually exclusive.
https://v1.lightningdesignsystem.com/components/icons/#Color
Therefore, I've tried including currentColor
as one of variants of the textColor
prop in 8235e6f.
Additionally, I added a story that we can confirm the currentColor
behavior in 9bef3e3.
Do you think this solution would be fine?
src/scripts/Icon.tsx
Outdated
align?: 'left' | 'right'; | ||
container?: IconContainer; | ||
circleContainer?: boolean; | ||
color?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe color
is not used, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stomita
The color
prop is used as rprops
.
This usage is as the same as before this PR.
react-lightning-design-system/src/scripts/Icon.tsx
Lines 226 to 234 in 61e9ded
<svg | |
ref={ref} | |
className={iconClassNames} | |
aria-hidden | |
style={style} | |
{...rprops} | |
> | |
<use xlinkHref={iconUrl} /> | |
</svg> |
Although we can remove the color
prop because it's also declared in SVGAttributes<SVGElement>
, I decided to keep it on purpose because I thought it was more explicitly declared as documentation.
react-lightning-design-system/src/scripts/Icon.tsx
Lines 164 to 178 in 61e9ded
export type IconProps = { | |
label?: string; | |
containerClassName?: string; | |
category?: IconCategory; | |
icon: string; | |
size?: IconSize; | |
align?: 'left' | 'right'; | |
container?: IconContainer; | |
color?: string; | |
textColor?: IconTextColor; | |
tabIndex?: number; | |
fillColor?: string; | |
title?: string; | |
flip?: boolean; | |
} & SVGAttributes<SVGElement>; |
Which do you think is better: to keep it or to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is included in SVGAttributes<SVGElement>
type and just passing to <svg>
, it might not be necessary in the props definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/scripts/Icon.tsx
Outdated
(props) => { | ||
const { container, containerClassName, fillColor, ...rprops } = props; | ||
const { | ||
label, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the label
prop is only used for assistive text, it may be misleading, as label
typically refers to something visible to users in other components. It might be better to share it with the title
prop, unless there's a strong need to differentiate between the title and the assistive text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
61e9ded
to
f57f21b
Compare
What I did
References