-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Badge): Migrate to styled-components
- Loading branch information
Showing
9 changed files
with
288 additions
and
244 deletions.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
} | ||
} | ||
|
||
.rn-phase-banner .rn-badge { | ||
.rn-phase-banner__badge { | ||
margin: 0; | ||
text-transform: capitalize; | ||
} |
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
64 changes: 22 additions & 42 deletions
64
packages/react-component-library/src/components/Badge/Badge.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,61 +1,41 @@ | ||
import React from 'react' | ||
import classNames from 'classnames' | ||
|
||
import { ComponentWithClass } from '../../common/ComponentWithClass' | ||
import { StyledBadge } from './partials/StyledBadge' | ||
|
||
import { BADGE_COLOR, BADGE_COLOR_VARIANT, BADGE_SIZE } from './constants' | ||
import { | ||
BADGE_COLOR, | ||
BADGE_COLOR_VARIANT, | ||
BADGE_SIZE, | ||
BADGE_VARIANT, | ||
} from './constants' | ||
|
||
export type BadgeColorType = | ||
| typeof BADGE_COLOR.ACTION | ||
| typeof BADGE_COLOR.DANGER | ||
| typeof BADGE_COLOR.NEUTRAL | ||
| typeof BADGE_COLOR.SUCCESS | ||
| typeof BADGE_COLOR.WARNING | ||
|
||
export type BadgeSizeType = | ||
| typeof BADGE_SIZE.XSMALL | ||
| typeof BADGE_SIZE.SMALL | ||
| typeof BADGE_SIZE.REGULAR | ||
| typeof BADGE_SIZE.LARGE | ||
| typeof BADGE_SIZE.XLARGE | ||
BadgeColorType, | ||
BadgeColorVariantType, | ||
BadgeSizeType, | ||
BadgeVariantType, | ||
} from './types' | ||
|
||
export interface BadgeProps extends ComponentWithClass { | ||
color?: BadgeColorType | ||
colorVariant?: | ||
| typeof BADGE_COLOR_VARIANT.FADED | ||
| typeof BADGE_COLOR_VARIANT.SOLID | ||
colorVariant?: BadgeColorVariantType | ||
size?: BadgeSizeType | ||
variant?: typeof BADGE_VARIANT.PILL | ||
variant?: BadgeVariantType | ||
} | ||
|
||
export const Badge: React.FC<BadgeProps> = ({ | ||
children, | ||
className, | ||
color = BADGE_COLOR.NEUTRAL, | ||
color: badgeColor = BADGE_COLOR.NEUTRAL, | ||
colorVariant = BADGE_COLOR_VARIANT.SOLID, | ||
size = BADGE_SIZE.REGULAR, | ||
variant, | ||
...rest | ||
}) => { | ||
const classes = classNames( | ||
'rn-badge', | ||
`rn-badge--${color}`, | ||
`rn-badge--${colorVariant}`, | ||
`rn-badge--${size}`, | ||
`rn-badge--${variant}`, | ||
className | ||
) | ||
|
||
return ( | ||
<span className={classes} data-testid="badge" {...rest}> | ||
{children} | ||
</span> | ||
) | ||
} | ||
}) => ( | ||
<StyledBadge | ||
$color={badgeColor} | ||
$colorVariant={colorVariant} | ||
$size={size} | ||
$variant={variant} | ||
data-testid="badge" | ||
{...rest} | ||
> | ||
{children} | ||
</StyledBadge> | ||
) | ||
|
||
Badge.displayName = 'Badge' |
Oops, something went wrong.