diff --git a/packages/big-design/src/components/Badge/Badge.tsx b/packages/big-design/src/components/Badge/Badge.tsx index e6d01e0c8..030bb3a29 100644 --- a/packages/big-design/src/components/Badge/Badge.tsx +++ b/packages/big-design/src/components/Badge/Badge.tsx @@ -5,9 +5,12 @@ import { MarginProps } from '../../mixins'; import { StyledBadge } from './styled'; export interface BadgeProps extends React.HTMLAttributes, MarginProps { + label: string; variant?: 'danger' | 'secondary' | 'success' | 'warning'; } -export const Badge: React.FC = memo(({ className, style, ...props }) => ); +export const Badge: React.FC = memo(({ className, style, label, ...props }) => ( + {label} +)); Badge.displayName = 'Badge'; diff --git a/packages/big-design/src/components/Badge/__snapshots__/spec.tsx.snap b/packages/big-design/src/components/Badge/__snapshots__/spec.tsx.snap index a080edd4b..b3b37c8c7 100644 --- a/packages/big-design/src/components/Badge/__snapshots__/spec.tsx.snap +++ b/packages/big-design/src/components/Badge/__snapshots__/spec.tsx.snap @@ -7,9 +7,10 @@ exports[`render danger Badge 1`] = ` display: inline-block; font-size: 0.75rem; font-weight: 600; + line-height: 1.25rem; text-align: center; text-transform: uppercase; - padding: 0.25rem 0.5rem; + padding: 0 0.5rem; background-color: #DB3643; } @@ -27,9 +28,10 @@ exports[`render default Badge 1`] = ` display: inline-block; font-size: 0.75rem; font-weight: 600; + line-height: 1.25rem; text-align: center; text-transform: uppercase; - padding: 0.25rem 0.5rem; + padding: 0 0.5rem; background-color: #5E637A; } @@ -47,9 +49,10 @@ exports[`render secondary Badge 1`] = ` display: inline-block; font-size: 0.75rem; font-weight: 600; + line-height: 1.25rem; text-align: center; text-transform: uppercase; - padding: 0.25rem 0.5rem; + padding: 0 0.5rem; background-color: #5E637A; } @@ -67,9 +70,10 @@ exports[`render success Badge 1`] = ` display: inline-block; font-size: 0.75rem; font-weight: 600; + line-height: 1.25rem; text-align: center; text-transform: uppercase; - padding: 0.25rem 0.5rem; + padding: 0 0.5rem; background-color: #208831; } @@ -87,9 +91,10 @@ exports[`render warning Badge 1`] = ` display: inline-block; font-size: 0.75rem; font-weight: 600; + line-height: 1.25rem; text-align: center; text-transform: uppercase; - padding: 0.25rem 0.5rem; + padding: 0 0.5rem; color: #313440; background-color: #FFBF00; } diff --git a/packages/big-design/src/components/Badge/spec.tsx b/packages/big-design/src/components/Badge/spec.tsx index d081e8cb1..ff0574135 100644 --- a/packages/big-design/src/components/Badge/spec.tsx +++ b/packages/big-design/src/components/Badge/spec.tsx @@ -6,45 +6,45 @@ import React from 'react'; import { Badge } from './index'; test('has margin props', () => { - const { container, rerender } = render(); + const { container, rerender } = render(); expect(container.firstChild).not.toHaveStyle('margin: 1rem'); - rerender(); + rerender(); expect(container.firstChild).toHaveStyle('margin: 1rem'); }); test('render default Badge', () => { - const { container } = render(Badge); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toHaveStyle(`background-color: ${theme.colors.secondary60}`); }); test('render success Badge', () => { - const { container } = render(Badge); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toHaveStyle(`background-color: ${theme.colors.success50}`); }); test('render danger Badge', () => { - const { container } = render(Badge); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toHaveStyle(`background-color: ${theme.colors.danger40}`); }); test('render warning Badge', () => { - const { container } = render(Badge); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toHaveStyle(`background-color: ${theme.colors.warning40}`); }); test('render secondary Badge', () => { - const { container } = render(Badge); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); expect(container.firstChild).toHaveStyle(`background-color: ${theme.colors.secondary60}`); diff --git a/packages/big-design/src/components/Badge/styled.tsx b/packages/big-design/src/components/Badge/styled.tsx index a6644bf9a..339e6eb2b 100644 --- a/packages/big-design/src/components/Badge/styled.tsx +++ b/packages/big-design/src/components/Badge/styled.tsx @@ -5,7 +5,7 @@ import { withMargins } from '../../mixins'; import { BadgeProps } from './Badge'; -export const StyledBadge = styled.span` +export const StyledBadge = styled.span>` ${withMargins()}; color: ${({ theme }) => theme.colors.white}; @@ -13,9 +13,10 @@ export const StyledBadge = styled.span` display: inline-block; font-size: ${({ theme }) => theme.helpers.remCalc(12)}; font-weight: ${({ theme }) => theme.typography.fontWeight.semiBold}; + line-height: ${({ theme }) => theme.lineHeight.small}; text-align: center; text-transform: uppercase; - padding: ${({ theme }) => `${theme.spacing.xxSmall} ${theme.spacing.xSmall}`}; + padding: 0 ${({ theme }) => theme.spacing.xSmall}; ${({ theme, variant }) => variant === 'secondary' && diff --git a/packages/docs/PropTables/BadgePropTable.tsx b/packages/docs/PropTables/BadgePropTable.tsx index f32596605..02010c058 100644 --- a/packages/docs/PropTables/BadgePropTable.tsx +++ b/packages/docs/PropTables/BadgePropTable.tsx @@ -3,6 +3,12 @@ import React from 'react'; import { Prop, PropTable, PropTableWrapper } from '../components'; const badgeProps: Prop[] = [ + { + name: 'label', + types: 'string', + description: 'The text applied to the component.', + required: true, + }, { name: 'variant', types: ['danger', 'secondary', 'success', 'warning'], diff --git a/packages/docs/pages/Badge/BadgePage.tsx b/packages/docs/pages/Badge/BadgePage.tsx index 592d8a81b..5794b5c26 100644 --- a/packages/docs/pages/Badge/BadgePage.tsx +++ b/packages/docs/pages/Badge/BadgePage.tsx @@ -19,7 +19,7 @@ export default () => ( {/* jsx-to-string:start */} - active + {/* jsx-to-string:end */} @@ -40,10 +40,10 @@ export default () => ( {/* jsx-to-string:start */} - secondary - success - warning - danger + + + + {/* jsx-to-string:end */}