-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat(Badge): deprecate some props and new UpdateBadge and StatusBadge components #1258
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a73c7bc
feat(Badge): deprecate some props and new UpdateBadge and StatusBadge…
marcinsawicki b4d134c
feat(Badge): styles update
marcinsawicki 59ee900
feat(Badge): changes after review
marcinsawicki cd702a2
feat(Badge): update color token
marcinsawicki 1b01791
Merge branch 'main' into feature/1232
marcinsawicki 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
79 changes: 79 additions & 0 deletions
79
packages/react-components/src/components/StatusBadge/StatusBadge.module.scss
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,79 @@ | ||
$base-class: 'status-badge'; | ||
|
||
@mixin size($size) { | ||
border-radius: $size; | ||
width: $size; | ||
height: $size; | ||
} | ||
|
||
.#{$base-class} { | ||
display: flex; | ||
border-style: solid; | ||
border-color: var(--surface-primary-default); | ||
|
||
&--3XS { | ||
@include size(4px); | ||
|
||
border-width: 1px; | ||
} | ||
|
||
&--2XS { | ||
@include size(5px); | ||
|
||
border-width: 1px; | ||
} | ||
|
||
&--XS { | ||
@include size(6px); | ||
|
||
border-width: 1px; | ||
} | ||
|
||
&--SM { | ||
@include size(8px); | ||
|
||
border-width: 1px; | ||
} | ||
|
||
&--MD { | ||
@include size(9px); | ||
|
||
border-width: 2px; | ||
} | ||
|
||
&--LG { | ||
@include size(10px); | ||
|
||
border-width: 2px; | ||
} | ||
|
||
&--XL { | ||
@include size(12px); | ||
|
||
border-width: 2px; | ||
} | ||
|
||
&--2XL { | ||
@include size(16px); | ||
|
||
border-width: 2px; | ||
} | ||
|
||
&--3XL { | ||
@include size(24px); | ||
|
||
border-width: 3px; | ||
} | ||
|
||
&--offline { | ||
background-color: var(--content-basic-disabled); | ||
} | ||
|
||
&--accept { | ||
background-color: var(--surface-accent-emphasis-high-positive); | ||
} | ||
|
||
&--not-accept { | ||
background-color: var(--surface-accent-emphasis-high-negative); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/react-components/src/components/StatusBadge/StatusBadge.stories.tsx
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,42 @@ | ||
import * as React from 'react'; | ||
|
||
import { StoryDescriptor } from '../../stories/components/StoryDescriptor'; | ||
|
||
import { | ||
IStatusBadgeProps, | ||
StatusBadge, | ||
StatusBadgeSizes, | ||
} from './StatusBadge'; | ||
|
||
export default { | ||
title: 'Components/Badge/StatusBadge', | ||
component: StatusBadge, | ||
}; | ||
|
||
const SIZES: StatusBadgeSizes[] = [ | ||
'3XS', | ||
'2XS', | ||
'XS', | ||
'SM', | ||
'MD', | ||
'LG', | ||
'XL', | ||
'2XL', | ||
'3XL', | ||
]; | ||
|
||
export const Default = (args: IStatusBadgeProps): React.ReactElement => ( | ||
<StatusBadge {...args} /> | ||
); | ||
|
||
export const KindsAndSizes = (): React.ReactElement => ( | ||
<> | ||
{SIZES.map((size) => ( | ||
<StoryDescriptor title={`${size}`}> | ||
<StatusBadge size={size} kind="accept" /> | ||
<StatusBadge size={size} kind="not-accept" /> | ||
<StatusBadge size={size} kind="offline" /> | ||
</StoryDescriptor> | ||
))} | ||
</> | ||
); |
46 changes: 46 additions & 0 deletions
46
packages/react-components/src/components/StatusBadge/StatusBadge.tsx
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,46 @@ | ||
import * as React from 'react'; | ||
|
||
import cx from 'clsx'; | ||
|
||
import styles from './StatusBadge.module.scss'; | ||
|
||
const baseClass = 'status-badge'; | ||
|
||
export type StatusBadgeSizes = | ||
| '3XS' | ||
| '2XS' | ||
| 'XS' | ||
| 'SM' | ||
| 'MD' | ||
| 'LG' | ||
| 'XL' | ||
| '2XL' | ||
| '3XL'; | ||
|
||
export interface IStatusBadgeProps | ||
extends React.HTMLAttributes<HTMLSpanElement> { | ||
/** | ||
* Specify the status badge kind | ||
*/ | ||
kind?: 'offline' | 'accept' | 'not-accept'; | ||
/** | ||
* Specify the status badge size | ||
*/ | ||
size?: StatusBadgeSizes; | ||
} | ||
|
||
export const StatusBadge: React.FC<IStatusBadgeProps> = ({ | ||
className, | ||
kind = 'offline', | ||
size = 'MD', | ||
...spanProps | ||
}) => { | ||
const mergedClassNames = cx( | ||
styles[baseClass], | ||
styles[`${baseClass}--${kind}`], | ||
styles[`${baseClass}--${size}`], | ||
className | ||
); | ||
|
||
return <span className={mergedClassNames} {...spanProps} />; | ||
}; |
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 @@ | ||
export { StatusBadge } from './StatusBadge'; |
13 changes: 13 additions & 0 deletions
13
packages/react-components/src/components/UpdateBadge/UpdateBadge.module.scss
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,13 @@ | ||
$base-class: 'update-badge'; | ||
$size: 9px; | ||
|
||
.#{$base-class} { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: $size; | ||
box-shadow: inset 0 0 0 3.25px var(--surface-accent-emphasis-high-negative); | ||
background-color: var(--content-invert-primary); | ||
width: $size; | ||
height: $size; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/react-components/src/components/UpdateBadge/UpdateBadge.stories.tsx
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,10 @@ | ||
import * as React from 'react'; | ||
|
||
import { UpdateBadge } from './UpdateBadge'; | ||
|
||
export default { | ||
title: 'Components/Badge/UpdateBadge', | ||
component: UpdateBadge, | ||
}; | ||
|
||
export const Default = (): React.ReactElement => <UpdateBadge />; |
9 changes: 9 additions & 0 deletions
9
packages/react-components/src/components/UpdateBadge/UpdateBadge.tsx
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,9 @@ | ||
import * as React from 'react'; | ||
|
||
import styles from './UpdateBadge.module.scss'; | ||
|
||
const baseClass = 'update-badge'; | ||
|
||
export const UpdateBadge: React.FC = () => ( | ||
<span className={styles[baseClass]} /> | ||
); |
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 @@ | ||
export { UpdateBadge } from './UpdateBadge'; |
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
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.
I'd suggest including border-width into the size mixin and make it as a second parameter