-
Notifications
You must be signed in to change notification settings - Fork 166
Adds Decorative and Informative Icon support in terra-button #3640
Conversation
packages/terra-alert/src/Alert.jsx
Outdated
@@ -89,19 +89,19 @@ const defaultProps = { | |||
const getAlertIcon = (type, customIcon) => { | |||
switch (type) { | |||
case AlertTypes.ALERT: | |||
return (<span className={cx('icon')}><IconAlert /></span>); | |||
return (<span className={cx('icon')}><IconAlert a11yLabel="Alert" /></span>); |
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.
Do we need to localized this a11y label? I can't find a11yLabel
in terra-icon so not sure how it is used.
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.
a11yLabel
is a new prop that was added as part of the accessibility upgrade:
https://github.com/cerner/terra-core/blob/64b6b9fc41d741160887028e6b42155c51d40887/packages/terra-icon/src/IconBase.jsx
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.
Ah, it's in IconBase. Thanks for the reference.
So if this will create a title
element with this label and be read by the screen reader, I wonder if it does need to be localized. Getting the translations for all of these can be tedious.
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.
updated to include translated messages for the terra-search-field and terra-alert which are having translations messages already.
b6652a1
For the other components updated the links to consume decorative icons. we might need to verify all the components that consumes terra-icon to find out the type of icon that should be used to make component accessible.
/** | ||
* Sets the button variant. One of `action` or `utility`. | ||
*/ | ||
variant: PropTypes.oneOf([ButtonVariants.ACTION, ButtonVariants.UTILITY]), |
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.
Should this list also contain neutral as default variant is neutral. Or should the default variant be one of action/utility?
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.
I missed adding back the variants. IconButton supports all the variants.
Added here
should this changes be released as MVB ? |
/** | ||
* Whether or not the button should only display as an icon. | ||
*/ | ||
isIconOnly: PropTypes.bool, |
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.
do we need this prop now ? as this file is specific to icon button
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.
yes we would still need this because icon-button supports both icon and icon with text variants.
yes, this changes should be released as MVB since default Button API no longer supports Icons. Added upgrade guide |
icon={icon} | ||
iconType={iconType} | ||
isDisabled={isDisabled} | ||
isIconOnly={icon != null} |
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.
isIconOnly should always be true here.
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.
packages/terra-button/CHANGELOG.md
Outdated
* Added new subcomponent `terra-icon-button` to display icon. | ||
|
||
* Breaking Changes | ||
* `icon`, `isIconOnly` and `isReveresed` props have been moved from `terra-button` to `terra-icon-button`. |
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.
terra-icon-button
sounds like a package name. Should we be referencing it as IconButton
instead?
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.
packages/terra-button/src/Button.jsx
Outdated
*/ | ||
text: PropTypes.string.isRequired, | ||
/** | ||
* Additional information to display as a native tooltip on hover. | ||
* Buttons declared as `isIconOnly` or `utility` will fallback to using `text` if not provided. | ||
* Additional information to display as a native tooltip on hover. will fallback to using `text` if not provided. |
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.
* Additional information to display as a native tooltip on hover. will fallback to using `text` if not provided. | |
* Additional information to display as a native tooltip on hover. It will fallback to using `text` if not provided. |
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.
/** | ||
* Sets the button variant. One of `action` or `utility`. | ||
*/ | ||
variant: PropTypes.oneOf([ButtonVariants.NEUTRAL, ButtonVariants.EMPHASIS, ButtonVariants.GHOST, ButtonVariants['DE-EMPHASIS'], ButtonVariants.ACTION]), |
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.
Should ButtonVariants.UTILITY
also be one of the variants for IconButton?
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.
I missed it while doing copy paste from button updated
@@ -4,6 +4,7 @@ | |||
|
|||
* Changed | |||
* Updated jest snapshots. | |||
* Updated jest snapshots. |
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.
Should the change log reflex what is really changed in Alert.jsx which is adding a11yLabel to the icons for the alerts?
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.
Updated here
@@ -4,6 +4,13 @@ import { Badge } from 'terra-button/package.json?dev-site-package'; | |||
|
|||
# Terra Button Upgrade Guide | |||
|
|||
## Changes from version 3 to version 4 | |||
* Added new sub-component terra-icon-button to display decorative and informative icons within button. |
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.
* Added new sub-component terra-icon-button to display decorative and informative icons within button. | |
* Added new sub-component IconButton to display decorative and informative icons within button. |
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.
* `icon`, `isIconOnly` and `isReversed` props have been moved to terra-icon-button. | ||
* `Utility` variant have been moved to terra-icon-button. |
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.
* `icon`, `isIconOnly` and `isReversed` props have been moved to terra-icon-button. | |
* `Utility` variant have been moved to terra-icon-button. | |
* `icon`, `isIconOnly` and `isReversed` props have been moved to IconButton. | |
* `Utility` variant have been moved to IconButton. |
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.
<Button icon={Icon} text="icon" isReversed className={cx('button')} /> | ||
<Button icon={Icon} isIconOnly text="Icon Only Button" className={cx('button')} /> | ||
<IconButton icon={Icon} text="icon" iconType={IconTypes.INFORMATIVE} className={cx('button')} /> | ||
<IconButton icon={Icon} text="icon" iconType="informative" isReversed className={cx('button')} /> |
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.
<IconButton icon={Icon} text="icon" iconType="informative" isReversed className={cx('button')} /> | |
<IconButton icon={Icon} text="icon" iconType={IconTypes.INFORMATIVE} isReversed className={cx('button')} /> |
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.
* Added Decorative and Informative support in terra-button * jest snapshot updates * lint error * trailing space removed * change logs added to make terra-bot happy * snapshot update * screenshots updates for alert due to changes in icon style * searchfeild snapshots * added translations for alert searchfield * linter * scrreenshot updates * Added prop types * change log updates to rename terra-icon-button to iconbutton * minor change * minnor doc and jest test corrections * Add Icon Button to A11y Guide * Update A11yButtonLabel.jsx Co-authored-by: saket2403 <saket.bajaj1998@gmail.com> Co-authored-by: Saket Bajaj <42207428+saket2403@users.noreply.github.com>
Summary
New sub component
terra-icon-button
has been created to display icon. Terra-Icon-button has two required propsicon
andiconType
.text
prop is optional since the subcomponent is best suitable to be used when we need to display icon or text with icon.Breaking Changes :
icon
,isIconOnly
andisReversed
prop are removed from terra-button. terra-default button will no longer support displaying icon and requires new sub-component to be used for icon buttons.Terra-Icon has now made
a11yLabel
a required prop. this change requires update in all the components that are consuming terra-icon MVB.This PR updates all the components to consume terra-icon MVB changes.
Closes #
Deployment Link
https://terra-core-deployed-pr-#.herokuapp.com/
Testing
Jest Tests were added to validate terra-icon-button for the prop changes.
Additional Details
Thank you for contributing to Terra.
@cerner/terra