-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#341 Reorganize Badge component to reflect Figma designs
- Loading branch information
Szymon Graczyk
committed
Jul 25, 2022
1 parent
65e3c89
commit cce8a2e
Showing
4 changed files
with
155 additions
and
37 deletions.
There are no files selected for viewing
101 changes: 89 additions & 12 deletions
101
packages/react-components/src/components/Badge/Badge.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 |
---|---|---|
@@ -1,23 +1,100 @@ | ||
.badge { | ||
background-color: var(--color-negative-default); | ||
border-radius: 18px; | ||
$base-class: 'badge'; | ||
|
||
@mixin dot($size) { | ||
border-radius: $size; | ||
height: $size; | ||
width: $size; | ||
} | ||
|
||
.#{$base-class} { | ||
align-items: center; | ||
box-sizing: border-box; | ||
color: var(--content-invert-default); | ||
display: inline-block; | ||
font-size: 10px; | ||
display: inline-flex; | ||
flex-direction: column; | ||
font-size: 12px; | ||
font-weight: 600; | ||
height: 18px; | ||
line-height: 18px; | ||
min-width: 18px; | ||
padding: 0 3px; | ||
text-align: center; | ||
gap: 10px; | ||
justify-content: center; | ||
line-height: 16px; | ||
|
||
&__dot { | ||
background-color: var(--content-invert-default); | ||
margin: 0 -2px; | ||
} | ||
|
||
& + & { | ||
margin-left: 4px; | ||
} | ||
|
||
&--large { | ||
border-radius: 24px; | ||
height: 24px; | ||
min-width: 24px; | ||
padding: 4px 8.5px; | ||
|
||
.#{$base-class}__dot { | ||
@include dot(10px); | ||
} | ||
} | ||
|
||
&--medium { | ||
border-radius: 20px; | ||
height: 20px; | ||
min-width: 20px; | ||
padding: 2px 7px; | ||
|
||
.#{$base-class}__dot { | ||
@include dot(8px); | ||
} | ||
} | ||
|
||
&--compact { | ||
border-radius: 24px; | ||
height: 18px; | ||
min-width: 18px; | ||
padding: 1px 6px; | ||
|
||
.#{$base-class}__dot { | ||
@include dot(6px); | ||
} | ||
} | ||
|
||
&--primary { | ||
background-color: var(--color-negative-default); | ||
color: var(--content-invert-default); | ||
|
||
&:hover { | ||
background-color: var(--color-negative-hover); | ||
} | ||
|
||
.#{$base-class}__dot { | ||
background-color: var(--content-invert-default); | ||
} | ||
} | ||
|
||
&--secondary { | ||
background-color: var(--color-action-default); | ||
color: var(--content-invert-default); | ||
|
||
&:hover { | ||
background-color: var(--color-action-hover); | ||
} | ||
|
||
.#{$base-class}__dot { | ||
background-color: var(--content-invert-default); | ||
} | ||
} | ||
|
||
&--tertiary { | ||
background-color: var(--surface-secondary-default); | ||
color: var(--surface-invert-default); | ||
color: var(--content-default); | ||
|
||
&:hover { | ||
background-color: var(--surface-secondary-hover); | ||
} | ||
|
||
.#{$base-class}__dot { | ||
background-color: var(--content-default); | ||
} | ||
} | ||
} |
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
47 changes: 32 additions & 15 deletions
47
packages/react-components/src/components/Badge/Badge.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 |
---|---|---|
@@ -1,24 +1,41 @@ | ||
import { Story } from '@storybook/react'; | ||
import * as React from 'react'; | ||
import { Badge as BadgeComponent, BadgeProps } from './Badge'; | ||
import { Badge, BadgeProps } from './Badge'; | ||
|
||
export default { | ||
title: 'Components/Badge', | ||
component: BadgeComponent, | ||
component: Badge, | ||
}; | ||
|
||
export const Badge = (args: BadgeProps): React.ReactElement => ( | ||
<div | ||
style={{ | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
alignContent: 'center', | ||
}} | ||
> | ||
<BadgeComponent {...args} /> | ||
export const Default: Story<BadgeProps> = ( | ||
args: BadgeProps | ||
): React.ReactElement => <Badge {...args} />; | ||
|
||
Default.storyName = 'Badge'; | ||
Default.args = { | ||
children: '1', | ||
}; | ||
|
||
export const Sizes = (): JSX.Element => ( | ||
<div className="spacer"> | ||
<Badge size="compact">1</Badge> | ||
<Badge size="medium">1</Badge> | ||
<Badge size="large">1</Badge> | ||
</div> | ||
); | ||
|
||
Badge.args = { | ||
secondary: false, | ||
children: '7', | ||
}; | ||
export const Kinds = (): JSX.Element => ( | ||
<div className="spacer"> | ||
<Badge kind="primary">1</Badge> | ||
<Badge kind="secondary">1</Badge> | ||
<Badge kind="tertiary">1</Badge> | ||
</div> | ||
); | ||
|
||
export const Types = (): JSX.Element => ( | ||
<div className="spacer"> | ||
<Badge type="content">3 steps left</Badge> | ||
<Badge type="alert" /> | ||
<Badge type="dot" /> | ||
</div> | ||
); |
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