add Tag component

This commit is contained in:
Florian Scholdei
2019-09-16 17:16:56 +02:00
parent e7d08e4564
commit dd6458b1cb
2 changed files with 42 additions and 0 deletions

View 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}`)} />&nbsp;
</>
);
}
return (
<span
className={classNames("tag", `is-${color}`, className)}
title={title}
>
{showIcon}
{label}
</span>
);
}
}
export default Tag;

View File

@@ -23,6 +23,7 @@ export { default as FileSize } from "./FileSize.js";
export { default as ProtectedRoute } from "./ProtectedRoute.js";
export { default as Help } from "./Help";
export { default as HelpIcon } from "./HelpIcon";
export { default as Tag } from "./Tag";
export { default as Tooltip } from "./Tooltip";
// TODO do we need this? getPageFromMatch is already exported by urls
export { getPageFromMatch } from "./urls";