use Tag component instead

This commit is contained in:
Florian Scholdei
2019-09-16 17:39:22 +02:00
parent cab4f0fcce
commit 0c138e46d6
4 changed files with 31 additions and 38 deletions

View File

@@ -1,10 +1,18 @@
//@flow //@flow
import React from "react"; import React from "react";
import {Change, Diff as DiffComponent, DiffObjectProps, File, getChangeKey, Hunk} from "react-diff-view"; import {
Change,
Diff as DiffComponent,
DiffObjectProps,
File,
getChangeKey,
Hunk
} from "react-diff-view";
import injectSheets from "react-jss"; import injectSheets from "react-jss";
import classNames from "classnames"; import classNames from "classnames";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import { Button, ButtonGroup } from "../buttons"; import { Button, ButtonGroup } from "../buttons";
import Tag from "../Tag";
const styles = { const styles = {
panel: { panel: {
@@ -183,24 +191,18 @@ class DiffFile extends React.Component<Props, State> {
value = file.type; value = file.type;
} }
const color = const color =
value === "added" value === "added" ? "success" : value === "deleted" ? "danger" : "info";
? "is-success"
: value === "deleted"
? "is-danger"
: "is-info";
return ( return (
<span <Tag
className={classNames( className={classNames(
"tag",
"is-rounded", "is-rounded",
"has-text-weight-normal", "has-text-weight-normal",
color,
classes.changeType classes.changeType
)} )}
> color={color}
{value} label={value}
</span> />
); );
}; };

View File

@@ -10,7 +10,7 @@ type Props = {
class ChangesetTag extends React.Component<Props> { class ChangesetTag extends React.Component<Props> {
render() { render() {
const { tag } = this.props; const { tag } = this.props;
return <ChangesetTagBase icon={"fa-tag"} label={tag.name} />; return <ChangesetTagBase icon="tag" label={tag.name} />;
} }
} }

View File

@@ -1,31 +1,19 @@
//@flow //@flow
import React from "react"; import React from "react";
import injectSheet from "react-jss"; import Tag from "../../Tag";
import classNames from "classnames";
const styles = {
spacing: {
marginRight: ".25rem"
}
};
type Props = { type Props = {
icon: string, icon: string,
label: string, label: string
// context props
classes: Object
}; };
class ChangesetTagBase extends React.Component<Props> { class ChangesetTagBase extends React.Component<Props> {
render() { render() {
const { icon, label, classes } = this.props; const { icon, label } = this.props;
return ( return (
<span className={classNames("tag", "is-info")}> <Tag color="info" icon={icon} label={label} />
<span className={classNames("fa", icon, classes.spacing)} /> {label}
</span>
); );
} }
} }
export default injectSheet(styles)(ChangesetTagBase); export default ChangesetTagBase;

View File

@@ -1,24 +1,27 @@
//@flow //@flow
import React from "react"; import React from "react";
import type { Tag } from "@scm-manager/ui-types";
import ChangesetTagBase from "./ChangesetTagBase";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import type { Tag } from "@scm-manager/ui-types";
import Tooltip from "../../Tooltip"; import Tooltip from "../../Tooltip";
import ChangesetTagBase from "./ChangesetTagBase";
type Props = { type Props = {
tags: Tag[], tags: Tag[],
// context props // context props
t: (string) => string t: string => string
}; };
class ChangesetTagsCollapsed extends React.Component<Props> { class ChangesetTagsCollapsed extends React.Component<Props> {
render() { render() {
const { tags, t } = this.props; const { tags, t } = this.props;
const message = tags.map((tag) => tag.name).join(", "); const message = tags.map(tag => tag.name).join(", ");
return ( return (
<Tooltip location="top" message={message}> <Tooltip location="top" message={message}>
<ChangesetTagBase icon={"fa-tags"} label={ tags.length + " " + t("changeset.tags") } /> <ChangesetTagBase
icon="tags"
label={tags.length + " " + t("changeset.tags")}
/>
</Tooltip> </Tooltip>
); );
} }