mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
add Tag component
This commit is contained in:
41
scm-ui-components/packages/ui-components/src/Tag.js
Normal file
41
scm-ui-components/packages/ui-components/src/Tag.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
//@flow
|
||||||
|
import * as React from "react";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
className?: string,
|
||||||
|
color?: string,
|
||||||
|
icon?: string,
|
||||||
|
label: string,
|
||||||
|
title?: string
|
||||||
|
};
|
||||||
|
|
||||||
|
class Tag extends React.Component<Props> {
|
||||||
|
static defaultProps = {
|
||||||
|
color: "light"
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { icon, label, title, color, className } = this.props;
|
||||||
|
let showIcon = null;
|
||||||
|
if (icon) {
|
||||||
|
showIcon = (
|
||||||
|
<>
|
||||||
|
<i className={classNames("fas", `fa-${icon}`)} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={classNames("tag", `is-${color}`, className)}
|
||||||
|
title={title}
|
||||||
|
>
|
||||||
|
{showIcon}
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Tag;
|
||||||
@@ -23,6 +23,7 @@ export { default as FileSize } from "./FileSize.js";
|
|||||||
export { default as ProtectedRoute } from "./ProtectedRoute.js";
|
export { default as ProtectedRoute } from "./ProtectedRoute.js";
|
||||||
export { default as Help } from "./Help";
|
export { default as Help } from "./Help";
|
||||||
export { default as HelpIcon } from "./HelpIcon";
|
export { default as HelpIcon } from "./HelpIcon";
|
||||||
|
export { default as Tag } from "./Tag";
|
||||||
export { default as Tooltip } from "./Tooltip";
|
export { default as Tooltip } from "./Tooltip";
|
||||||
// TODO do we need this? getPageFromMatch is already exported by urls
|
// TODO do we need this? getPageFromMatch is already exported by urls
|
||||||
export { getPageFromMatch } from "./urls";
|
export { getPageFromMatch } from "./urls";
|
||||||
|
|||||||
Reference in New Issue
Block a user