Skip to content

Commit 78875b7

Browse files
committed
WIP
1 parent d2bd7a8 commit 78875b7

File tree

6 files changed

+78
-2
lines changed

6 files changed

+78
-2
lines changed

src/components/Tag/Tag.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Variant } from '@/components';
4+
import clsx from 'clsx';
5+
6+
export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
7+
variant: Variant | string;
8+
}
9+
10+
const Tag = React.forwardRef<HTMLDivElement, TagProps>((
11+
{
12+
children,
13+
className,
14+
variant
15+
},
16+
ref
17+
): React.ReactElement => (
18+
<div
19+
ref={ref}
20+
className={clsx(
21+
'tag',
22+
`tag-${variant}`,
23+
className
24+
)}
25+
>
26+
{children}
27+
</div>
28+
));
29+
30+
Tag.displayName = 'Tag';
31+
Tag.propTypes = {
32+
children: PropTypes.node,
33+
className: PropTypes.string,
34+
variant: PropTypes.string.isRequired
35+
}
36+
37+
export default Tag;

src/components/Tag/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Tag } from './Tag';

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from './Icon';
88
export * from './utils';
99
export * from './TextField';
1010
export * from './SelectField';
11+
export * from './Tag';

src/style/components/_tags.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.tag {
2+
display: inline-block;
3+
align-items: center;
4+
5+
&.tag-primary, &.tag-purple {
6+
background: var(--primary-color-light-background);
7+
color: var(--primary-color);
8+
padding: calc(var(--base-gutter) / 2);
9+
border-radius: var(--base-border-radius);
10+
font: {
11+
weight: 500;
12+
}
13+
}
14+
15+
&.tag-danger, &.tag-red {
16+
background: var(--danger-color-light-background);
17+
color: var(--danger-color);
18+
padding: calc(var(--base-gutter) / 2);
19+
border-radius: var(--base-border-radius);
20+
font: {
21+
weight: 500;
22+
}
23+
}
24+
25+
+ .tag {
26+
margin-left: var(--base-gutter);
27+
}
28+
}

src/style/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@use "components/card";
1818
@use "components/icons";
1919
@use "components/forms";
20+
@use "components/tags";
2021

2122
/**
2223
* 3. Layout

www/src/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from 'react';
2+
import { useState } from 'react';
23
import * as ReactDom from 'react-dom';
34

45
import '../../src/style/index.scss';
5-
import { Button, Card, Col, Grid, Icon, Page, Row, SelectField, TextField, Variant } from '../../src';
6+
import { Button, Card, Col, Grid, Icon, Page, Row, SelectField, Tag, TextField, Variant } from '../../src';
67
import Container from '../../src/components/Container/Container';
78
import FormGroup from '../../src/components/Form/Group';
89
import FormLabel from '../../src/components/Form/Label';
910
import FormMessage from '../../src/components/Form/Message';
10-
import { useState } from 'react';
1111

1212
const TestControllable = () => {
1313
const [value, setValue] = useState('');
@@ -173,6 +173,14 @@ ReactDom.render(
173173
<TestControllable />
174174
</Card.Content>
175175
</Card>
176+
<Card>
177+
<Card.Header title="Tags" />
178+
<Card.Content>
179+
test text
180+
<Tag variant={Variant.PRIMARY}>Primary</Tag>
181+
<Tag variant={Variant.DANGER}>Primary</Tag>
182+
</Card.Content>
183+
</Card>
176184
</Row>
177185
<Row>
178186
<Grid columns={10} gap={4}>

0 commit comments

Comments
 (0)