Skip to content

Commit

Permalink
Fixed #1723 - New Component: Tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcandu committed Dec 17, 2020
1 parent c8133a0 commit f847bc6
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 0 deletions.
8 changes: 8 additions & 0 deletions public/showcase/menu/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,14 @@
"captcha",
"recaptcha"
]
},
{
"name": "Tag",
"to": "/tag",
"meta": [
"tag"
],
"badge": "new"
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions src/AppRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ import { BadgeDemo } from './showcase/badge/BadgeDemo';
import { RippleDemo } from './showcase/ripple/RippleDemo';
import { TimelineDemo } from './showcase/timeline/TimelineDemo';
import { AvatarDemo } from './showcase/avatar/AvatarDemo';
import { TagDemo } from './showcase/tag/TagDemo';

class AppRouter extends Component {

Expand Down Expand Up @@ -335,6 +336,7 @@ class AppRouter extends Component {
<Route path="/timeline" component={TimelineDemo} />
<Route path="/avatar" component={AvatarDemo} />
<Route path="/badge" component={BadgeDemo} />
<Route path="/tag" component={TagDemo} />
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/assets/style/primereact.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
@import '../../components/timeline/Timeline.css';
@import '../../components/avatar/Avatar.css';
@import '../../components/avatargroup/AvatarGroup.css';
@import '../../components/tag/Tag.css';
15 changes: 15 additions & 0 deletions src/components/tag/Tag.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.p-tag {
display: inline-flex;
align-items: center;
justify-content: center;
}

.p-tag-icon,
.p-tag-value,
.p-tag-icon.pi {
line-height: 1.5;
}

.p-tag.p-tag-rounded {
border-radius: 10rem;
}
12 changes: 12 additions & 0 deletions src/components/tag/Tag.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';

interface Tag {
value: any,
severity: string,
rounded: boolean,
icon: string,
className: string,
style: object
}

export class Tag extends React.Component<Tag,any> {}
45 changes: 45 additions & 0 deletions src/components/tag/Tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';

export class Tag extends Component {

static defaultProps = {
value: null,
severity: null,
rounded: false,
icon: null,
style: null,
className: null
}

static propTypes = {
value: PropTypes.any,
severity: PropTypes.string,
rounded: PropTypes.bool,
icon: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object
};


render() {
const tagClassName = classNames('p-tag p-component', {
'p-tag-info': this.props.severity === 'info',
'p-tag-success': this.props.severity === 'success',
'p-tag-warning': this.props.severity === 'warning',
'p-tag-danger': this.props.severity === 'danger',
'p-tag-rounded': this.props.rounded
}, this.props.className);

const iconClass = classNames('p-tag-icon', this.props.icon);

return (
<span className={tagClassName} style={this.props.style}>
{this.props.icon && <span className={iconClass}></span>}
<span className="p-tag-value">{this.props.value}</span>
<span>{this.props.children}</span>
</span>
);
}
}
45 changes: 45 additions & 0 deletions src/showcase/tag/TagDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { Component } from 'react';
import { Tag } from '../../components/tag/Tag';
import { TagDoc } from './TagDoc';

export class TagDemo extends Component {
render() {
return (
<div>
<div className="content-section introduction">
<div className="feature-intro">
<h1>Tag</h1>
<p>Tag component is used to categorize content.</p>
</div>
</div>

<div className="content-section implementation">
<div className="card">
<h5>Tags</h5>
<Tag className="p-mr-2" value="Primary"></Tag>
<Tag className="p-mr-2" severity="success" value="Success"></Tag>
<Tag className="p-mr-2" severity="info" value="Info"></Tag>
<Tag className="p-mr-2" severity="warning" value="Warning"></Tag>
<Tag severity="danger" value="Danger"></Tag>

<h5>Pills</h5>
<Tag className="p-mr-2" value="Primary" rounded></Tag>
<Tag className="p-mr-2" severity="success" value="Success" rounded></Tag>
<Tag className="p-mr-2" severity="info" value="Info" rounded></Tag>
<Tag className="p-mr-2" severity="warning" value="Warning" rounded></Tag>
<Tag severity="danger" value="Danger" rounded></Tag>

<h5>Icons</h5>
<Tag className="p-mr-2" icon="pi pi-user" value="Primary"></Tag>
<Tag className="p-mr-2" icon="pi pi-check" severity="success" value="Success"></Tag>
<Tag className="p-mr-2" icon="pi pi-info-circle" severity="info" value="Info"></Tag>
<Tag className="p-mr-2" icon="pi pi-exclamation-triangle" severity="warning" value="Warning"></Tag>
<Tag icon="pi pi-times" severity="danger" value="Danger"></Tag>
</div>
</div>

<TagDoc />
</div>
);
}
}
Loading

0 comments on commit f847bc6

Please sign in to comment.