Skip to content

Commit

Permalink
fix: Badge and Tag rendering a span (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored Apr 22, 2020
1 parent ca620a0 commit d8a5ed2
Show file tree
Hide file tree
Showing 27 changed files with 33 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/fuselage/src/components/Badge/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Tag } from '../..';
import { Tag } from '../Tag';

export function Badge(props) {
return <Tag round {...props} />;
return <Tag {...props} round />;
}

Badge.propTypes = {
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
disabled: PropTypes.bool,
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
};
10 changes: 10 additions & 0 deletions packages/fuselage/src/components/Badge/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';

import { Badge } from '.';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Badge />, div);
ReactDOM.unmountComponentAtNode(div);
});
4 changes: 2 additions & 2 deletions packages/fuselage/src/components/Badge/stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';

import { Badge } from '../..';

<Meta title='Tags & Badges/Badges' parameters={{ jest: ['Button/spec'] }} />
<Meta title='Data Display/Badge' parameters={{ jest: ['Badge/spec'] }} />

# Badge

Used for mentions.
Shows a count.

<Preview>
<Story name='Default'>
Expand Down
13 changes: 4 additions & 9 deletions packages/fuselage/src/components/Tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import PropTypes from 'prop-types';
import { Box } from '../..';

export function Tag({
variant = 'secondary',
disabled,
textStyle = 'micro',
round,
variant = 'secondary',
onClick,
...props
}) {
return <Box
is='div'
textStyle={textStyle}
componentClassName='rcx-tag'
is='span'
mod-secondary={variant === 'secondary'}
mod-primary={variant === 'primary'}
mod-danger={variant === 'danger'}
Expand All @@ -28,10 +26,7 @@ export function Tag({
}

Tag.propTypes = {
textStyle: PropTypes.oneOf([
'h1', 's1', 's2', 'p1', 'p2', 'c1', 'c2', 'micro',
]),
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
round: PropTypes.bool,
disabled: PropTypes.bool,
round: PropTypes.bool,
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
};
10 changes: 10 additions & 0 deletions packages/fuselage/src/components/Tag/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';

import { Tag } from '.';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Tag />, div);
ReactDOM.unmountComponentAtNode(div);
});
2 changes: 1 addition & 1 deletion packages/fuselage/src/components/Tag/stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';

import { Tag } from '../..';

<Meta title='Tags & Badges/Tags' parameters={{ jest: ['Button/spec'] }} />
<Meta title='Data Display/Tag' parameters={{ jest: ['Tag/spec'] }} />

# Tag

Expand Down
3 changes: 3 additions & 0 deletions packages/fuselage/src/components/Tag/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use '../../styles/colors.scss';
@use '../../styles/lengths.scss';
@use '../../styles/typography.scss';

$tag-colors-secondary-color: theme('tag-colors-secondary-color', colors.foreground(primary));
$tag-colors-secondary-background-color: theme('tag-colors-secondary-background-color', colors.primary(100));
Expand Down Expand Up @@ -31,6 +32,8 @@ $tag-colors-disabled-background-color: theme('tag-colors-disabled-background-col

border-radius: lengths.border-radius(4);

@include typography.use-font-scale(micro);

&--secondary {
color: $tag-colors-secondary-color;
background-color: $tag-colors-secondary-background-color;
Expand Down

0 comments on commit d8a5ed2

Please sign in to comment.