Skip to content

Commit

Permalink
feat: Tags and Badges (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh authored Mar 20, 2020
1 parent 26ab2b5 commit b739cde
Show file tree
Hide file tree
Showing 25 changed files with 184 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/fuselage/src/components/Badge/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';

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

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

Badge.propTypes = {
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
disabled: PropTypes.bool,
};
41 changes: 41 additions & 0 deletions packages/fuselage/src/components/Badge/stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';

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

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

# Badge

Used for mentions.

<Preview>
<Story name='Default'>
<Badge>99</Badge>
</Story>
</Preview>

<Props of={Badge} />

### Primary

<Preview>
<Story name='Primary'>
<Badge variant='primary'>99</Badge>
</Story>
</Preview>

### Danger

<Preview>
<Story name='Danger'>
<Badge variant='danger'>99</Badge>
</Story>
</Preview>

### Disabled

<Preview>
<Story name='Disabled'>
<Badge disabled>99</Badge>
</Story>
</Preview>
31 changes: 31 additions & 0 deletions packages/fuselage/src/components/Tag/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';

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

export function Tag({
variant = 'secondary',
disabled,
round,
onClick,
...props
}) {
return <Box
is='div'
componentClassName='rcx-tag'
mod-secondary={variant === 'secondary'}
mod-primary={variant === 'primary'}
mod-danger={variant === 'danger'}
mod-disabled={!!disabled}
mod-round={!!round}
mod-clickable={!!onClick}
onClick={onClick}
{...props}
/>;
}

Tag.propTypes = {
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
round: PropTypes.bool,
disabled: PropTypes.bool,
};
49 changes: 49 additions & 0 deletions packages/fuselage/src/components/Tag/stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';

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

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

# Tag

Used for mentions.

<Preview>
<Story name='Default'>
<Tag>john.doe</Tag>
</Story>
</Preview>

<Props of={Tag} />

### With Pointer Cursor

<Preview>
<Story name='Pointer'>
<Tag onClick={()=>{}}>john.doe</Tag>
</Story>
</Preview>

### Primary

<Preview>
<Story name='Primary'>
<Tag variant='primary'>john.doe</Tag>
</Story>
</Preview>

### Danger

<Preview>
<Story name='Danger'>
<Tag variant='danger'>john.doe</Tag>
</Story>
</Preview>

### Disabled

<Preview>
<Story name='Disabled'>
<Tag disabled>john.doe</Tag>
</Story>
</Preview>
47 changes: 47 additions & 0 deletions packages/fuselage/src/components/Tag/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.rcx-tag {
display: inline-block;

padding-block: $spaces-x2;

padding-inline: $spaces-x4;

text-decoration: none;

word-break: keep-all;

border-radius: $spaces-x4;

@include use-text-style(micro);

&--secondary {
color: $colors-b500;
background-color: $colors-b100;
}

&--primary {
color: $colors-white;
background-color: $colors-b500;
}

&--danger {
color: $colors-white;
background-color: $colors-r500;
}

&--disabled {
color: $colors-n600;
background-color: $colors-n400;
}

&--round {
overflow: hidden;

text-align: center;

border-radius: $spaces-x20;
}

&--clickable {
@include clickable();
}
}
2 changes: 2 additions & 0 deletions packages/fuselage/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ export * from './Select';
export * from './Tooltip';
export * from './Modal';
export * from './Throbber';
export * from './Tag';
export * from './Badge';
1 change: 1 addition & 0 deletions packages/fuselage/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@
@import './Tooltip/styles.scss';
@import './Modal/styles.scss';
@import './Throbber/styles.scss';
@import './Tag/styles.scss';

0 comments on commit b739cde

Please sign in to comment.