Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Adds Decorative and Informative Icon support in terra-button #3640

Merged
merged 18 commits into from
Jul 18, 2022

Conversation

supreethmr
Copy link
Contributor

@supreethmr supreethmr commented Jul 7, 2022

Summary

New sub component terra-icon-button has been created to display icon. Terra-Icon-button has two required props icon and iconType. 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 and isReversed 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

@supreethmr supreethmr requested a review from a team as a code owner July 7, 2022 20:35
@supreethmr supreethmr requested a review from saket2403 July 8, 2022 10:18
@@ -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>);
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.

Copy link
Contributor Author

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]),
Copy link
Contributor

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?

Copy link
Contributor Author

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

@ShettyAkarsh
Copy link
Contributor

should this changes be released as MVB ?

/**
* Whether or not the button should only display as an icon.
*/
isIconOnly: PropTypes.bool,
Copy link
Contributor

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

Copy link
Contributor Author

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.

@supreethmr
Copy link
Contributor Author

supreethmr commented Jul 12, 2022

should this changes be released as MVB ?

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}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* 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`.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Copy link
Contributor Author

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]),
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 11 to 12
* `icon`, `isIconOnly` and `isReversed` props have been moved to terra-icon-button.
* `Utility` variant have been moved to terra-icon-button.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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')} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<IconButton icon={Icon} text="icon" iconType="informative" isReversed className={cx('button')} />
<IconButton icon={Icon} text="icon" iconType={IconTypes.INFORMATIVE} isReversed className={cx('button')} />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@supreethmr supreethmr merged commit 8b6e77d into A11y-MVB Jul 18, 2022
@supreethmr supreethmr deleted the button-icon-support branch July 18, 2022 14:46
@saket2403 saket2403 restored the button-icon-support branch July 18, 2022 14:48
sdadn pushed a commit that referenced this pull request Sep 30, 2022
* 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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants