This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
[terra-badge] Example Doc Update #3952
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fb2fd89
Update: Terra-Badge Doc update
MadanKumarGovindaswamy 7f8df15
Update CHANGELOG.md
MadanKumarGovindaswamy f4763f9
Merge branch 'main' into Terra-Badge-Doc-Update
MadanKumarGovindaswamy 15696b5
Update: terra badge doc update
MadanKumarGovindaswamy ec3e8e3
Update lint error
MadanKumarGovindaswamy de73e29
Merge branch 'main' into Terra-Badge-Doc-Update
MadanKumarGovindaswamy a50bc40
Update: Doc page
MadanKumarGovindaswamy fc7d101
update: changelog file and lint error
MadanKumarGovindaswamy 59a80d1
Update: add badge in doc
MadanKumarGovindaswamy b6e884a
Merge branch 'main' into Terra-Badge-Doc-Update
MadanKumarGovindaswamy 7c93729
Update: Implementation page
MadanKumarGovindaswamy 54298b2
Update About.1.doc.mdx
MadanKumarGovindaswamy a0e816f
Update: corrections
MadanKumarGovindaswamy 87207dc
Merge branch 'main' into Terra-Badge-Doc-Update
MadanKumarGovindaswamy c1be69b
Update: remove visually hidden text for intent type
MadanKumarGovindaswamy cfb6aa9
Merge branch 'Terra-Badge-Doc-Update' of https://github.com/cerner/te…
MadanKumarGovindaswamy b7717dd
Update CHANGELOG.md
MadanKumarGovindaswamy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ const propTypes = { | |
icon: PropTypes.element, | ||
/** | ||
* Sets the badge color scheme. One of `default`, `primary`, `secondary`, `positive`, `negative`, `warning`, `info`. | ||
* | ||
* ![IMPORTANT](https://badgen.net/badge/UX/Accessibility/blue) | ||
* Follow the accessibility guidance for color to ensure color is not the only method used to convey information. | ||
*/ | ||
intent: PropTypes.oneOf(['default', 'primary', 'secondary', 'info', 'warning', 'positive', 'negative']), | ||
/** | ||
|
@@ -55,11 +58,16 @@ const propTypes = { | |
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'huge']), | ||
/** | ||
* Sets the badge text. | ||
* | ||
* ![IMPORTANT](https://badgen.net/badge/UX/Accessibility/blue) | ||
* It is best practice to always use text. Use text that conveys the meaning or purpose of the badge. | ||
*/ | ||
text: PropTypes.string, | ||
/** | ||
* Text that describes the badge to a screen reader. Use this | ||
* for creating an accessible badge. | ||
* Additional text that can be visually hidden but supports people that use assistive technologies like screen readers. | ||
* | ||
* ![IMPORTANT](https://badgen.net/badge/UX/Accessibility/blue) | ||
* Follow the Accessibility Guidance for visually hidden text above to better understand when to use this prop. | ||
*/ | ||
visuallyHiddenText: PropTypes.string, | ||
}; | ||
|
@@ -98,9 +106,8 @@ const Badge = ({ | |
); | ||
|
||
const textContent = text ? <span className={styles.text}>{text}</span> : null; | ||
const intentText = intent !== BadgeIntent.DEFAULT ? <VisuallyHiddenText text={intl.formatMessage({ id: `Terra.badge.intent.${intent}` })} /> : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to know why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @supreethmr , Thanks |
||
const visuallyHiddenTextContent = visuallyHiddenText ? <VisuallyHiddenText text={visuallyHiddenText} /> : null; | ||
const content = isReversed ? [intentText, textContent, visuallyHiddenTextContent, icon, customProps.children] : [icon, intentText, textContent, visuallyHiddenTextContent, customProps.children]; | ||
const content = isReversed ? [textContent, visuallyHiddenTextContent, icon, customProps.children] : [icon, textContent, visuallyHiddenTextContent, customProps.children]; | ||
return React.createElement('span', { ...customProps, className: badgeClassNames }, ...content); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/terra-core-docs/src/terra-dev-site/doc/badge/example/BadgeInDoc.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Badge from 'terra-badge'; | ||
|
||
const propTypes = { text: PropTypes.string, intent: PropTypes.string, visuallyHiddenText: PropTypes.string }; | ||
|
||
const BadgeInDoc = ({ | ||
...props | ||
}) => ( | ||
<Badge text={props.text} intent={props.intent} visuallyHiddenText={props.visuallyHiddenText} /> | ||
); | ||
|
||
BadgeInDoc.propTypes = propTypes; | ||
export default BadgeInDoc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 41 additions & 21 deletions
62
packages/terra-core-docs/src/terra-dev-site/doc/badge/example/BadgeIntent.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
import React from 'react'; | ||
import Badge from 'terra-badge'; | ||
import Avatar from 'terra-avatar'; | ||
import classNames from 'classnames/bind'; | ||
import styles from './Badge.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
const BadgeIntent = () => ( | ||
<div className={cx('badge-container')}> | ||
<div className={cx('badge')}> | ||
<Badge text="Patient Arrival" /> | ||
<React.Fragment> | ||
<p> | ||
The Intent prop can be used to apply colors to badges. Please refer to the | ||
<strong> VisuallyHiddenText prop examples further below </strong> | ||
to ensure proper | ||
<strong> context is provided for assistive technology users to understand the purpose of the badge. </strong> | ||
</p> | ||
<p> | ||
Intent Badge Colors: The following Badge example only illustrates badge colors. This example is not intended to illustrate how Badges should be used. As noted above, multiple badges should not be used together. Instead, see Pills or Tag. | ||
</p> | ||
<div className={cx('badge-container')}> | ||
<div className={cx('badge')}> | ||
<Badge text="No Risk" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="primary" text="Low" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="secondary" text="Moderate" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="warning" text="High" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="negative" text="Critical" /> | ||
</div> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="primary" text="Admitted" /> | ||
<p> | ||
Example usage of the Intent Badge. Please note that this use case does not require the VisuallyHiddenText prop because the badge is visually and programmatically grouped in a semantic container. Other use cases will require the VisuallyHiddenText prop. To effectively communicate context to assistive technology users. | ||
</p> | ||
<div className={cx('profile-container')}> | ||
<Avatar alt="Segun Adebayo" initials="SA" /> | ||
<div className={cx('profile-name-container')}> | ||
<span className={cx('profile-name')}>Segun Adebayo </span> | ||
<br /> | ||
<span>UI Engineer</span> | ||
</div> | ||
<div className={cx('profile-badge')}> | ||
<Badge intent="secondary" text="NEW" visuallyHiddenText="New User" /> | ||
</div> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="secondary" text="Discharged" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="positive" text="Recovery" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="negative" text="Complications" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="warning" text="Urgent" /> | ||
</div> | ||
<div className={cx('badge')}> | ||
<Badge intent="info" text="Medical Notes" /> | ||
</div> | ||
</div> | ||
</React.Fragment> | ||
); | ||
|
||
export default BadgeIntent; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this PR has more changes than just prop description updates in the terra badge, can you also add logs for the src code changes
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 . Thanks
Commit Link -- b7717dd