Skip to content

Commit b739cde

Browse files
authored
feat: Tags and Badges (#167)
1 parent 26ab2b5 commit b739cde

25 files changed

+184
-0
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import { Tag } from '../..';
5+
6+
export function Badge(props) {
7+
return <Tag round {...props} />;
8+
}
9+
10+
Badge.propTypes = {
11+
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
12+
disabled: PropTypes.bool,
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';
2+
3+
import { Badge } from '../..';
4+
5+
<Meta title='Tags & Badges|Badges' parameters={{ jest: ['Button/spec'] }} />
6+
7+
# Badge
8+
9+
Used for mentions.
10+
11+
<Preview>
12+
<Story name='Default'>
13+
<Badge>99</Badge>
14+
</Story>
15+
</Preview>
16+
17+
<Props of={Badge} />
18+
19+
### Primary
20+
21+
<Preview>
22+
<Story name='Primary'>
23+
<Badge variant='primary'>99</Badge>
24+
</Story>
25+
</Preview>
26+
27+
### Danger
28+
29+
<Preview>
30+
<Story name='Danger'>
31+
<Badge variant='danger'>99</Badge>
32+
</Story>
33+
</Preview>
34+
35+
### Disabled
36+
37+
<Preview>
38+
<Story name='Disabled'>
39+
<Badge disabled>99</Badge>
40+
</Story>
41+
</Preview>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import { Box } from '../..';
5+
6+
export function Tag({
7+
variant = 'secondary',
8+
disabled,
9+
round,
10+
onClick,
11+
...props
12+
}) {
13+
return <Box
14+
is='div'
15+
componentClassName='rcx-tag'
16+
mod-secondary={variant === 'secondary'}
17+
mod-primary={variant === 'primary'}
18+
mod-danger={variant === 'danger'}
19+
mod-disabled={!!disabled}
20+
mod-round={!!round}
21+
mod-clickable={!!onClick}
22+
onClick={onClick}
23+
{...props}
24+
/>;
25+
}
26+
27+
Tag.propTypes = {
28+
variant: PropTypes.oneOf(['secondary', 'primary', 'danger']),
29+
round: PropTypes.bool,
30+
disabled: PropTypes.bool,
31+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';
2+
3+
import { Tag } from '../..';
4+
5+
<Meta title='Tags & Badges|Tags' parameters={{ jest: ['Button/spec'] }} />
6+
7+
# Tag
8+
9+
Used for mentions.
10+
11+
<Preview>
12+
<Story name='Default'>
13+
<Tag>john.doe</Tag>
14+
</Story>
15+
</Preview>
16+
17+
<Props of={Tag} />
18+
19+
### With Pointer Cursor
20+
21+
<Preview>
22+
<Story name='Pointer'>
23+
<Tag onClick={()=>{}}>john.doe</Tag>
24+
</Story>
25+
</Preview>
26+
27+
### Primary
28+
29+
<Preview>
30+
<Story name='Primary'>
31+
<Tag variant='primary'>john.doe</Tag>
32+
</Story>
33+
</Preview>
34+
35+
### Danger
36+
37+
<Preview>
38+
<Story name='Danger'>
39+
<Tag variant='danger'>john.doe</Tag>
40+
</Story>
41+
</Preview>
42+
43+
### Disabled
44+
45+
<Preview>
46+
<Story name='Disabled'>
47+
<Tag disabled>john.doe</Tag>
48+
</Story>
49+
</Preview>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.rcx-tag {
2+
display: inline-block;
3+
4+
padding-block: $spaces-x2;
5+
6+
padding-inline: $spaces-x4;
7+
8+
text-decoration: none;
9+
10+
word-break: keep-all;
11+
12+
border-radius: $spaces-x4;
13+
14+
@include use-text-style(micro);
15+
16+
&--secondary {
17+
color: $colors-b500;
18+
background-color: $colors-b100;
19+
}
20+
21+
&--primary {
22+
color: $colors-white;
23+
background-color: $colors-b500;
24+
}
25+
26+
&--danger {
27+
color: $colors-white;
28+
background-color: $colors-r500;
29+
}
30+
31+
&--disabled {
32+
color: $colors-n600;
33+
background-color: $colors-n400;
34+
}
35+
36+
&--round {
37+
overflow: hidden;
38+
39+
text-align: center;
40+
41+
border-radius: $spaces-x20;
42+
}
43+
44+
&--clickable {
45+
@include clickable();
46+
}
47+
}

packages/fuselage/src/components/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ export * from './Select';
3939
export * from './Tooltip';
4040
export * from './Modal';
4141
export * from './Throbber';
42+
export * from './Tag';
43+
export * from './Badge';

packages/fuselage/src/components/index.scss

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
@import './Tooltip/styles.scss';
3232
@import './Modal/styles.scss';
3333
@import './Throbber/styles.scss';
34+
@import './Tag/styles.scss';

0 commit comments

Comments
 (0)