Files
SCM-Manager/scm-ui/ui-webapp/src/components/InfoBox.tsx

97 lines
3.1 KiB
TypeScript
Raw Normal View History

/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import * as React from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { InfoItem } from "./InfoItem";
import { Icon } from "@scm-manager/ui-components";
2019-08-13 08:23:37 +02:00
type Props = WithTranslation & {
type: "plugin" | "feature";
item: InfoItem;
2019-08-13 08:23:37 +02:00
};
const BottomMarginA = styled.a`
display: blocK;
margin-bottom: 1.5rem;
`;
const FixedSizedIconWrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 160px;
height: 160px;
`;
const LightBlueIcon = styled(Icon)`
margin-bottom: 0.5em;
color: #bff1e6;
`;
2019-08-13 08:23:37 +02:00
const ContentWrapper = styled.div`
2019-10-09 17:47:29 +02:00
min-height: 10.5rem;
margin-left: 1.5em;
`;
class InfoBox extends React.Component<Props> {
2019-08-13 08:23:37 +02:00
renderBody = () => {
const { item, t } = this.props;
const title = item ? item.title : t("login.loading");
const summary = item ? item.summary : t("login.loading");
2019-08-13 08:23:37 +02:00
return (
<ContentWrapper className={classNames("media-content", "content")}>
2019-08-15 10:30:48 +02:00
<h4 className="has-text-link">{title}</h4>
2019-08-13 08:23:37 +02:00
<p>{summary}</p>
</ContentWrapper>
2019-08-13 08:23:37 +02:00
);
};
render() {
const { item, type, t } = this.props;
const icon = type === "plugin" ? "puzzle-piece" : "star";
2019-08-13 08:23:37 +02:00
return (
<BottomMarginA href={item._links.self.href}>
2019-08-13 08:23:37 +02:00
<div className="box media">
<figure className="media-left">
<FixedSizedIconWrapper
2019-10-21 10:57:56 +02:00
className={classNames("image", "box", "has-text-weight-bold", "has-text-white", "has-background-info")}
>
<LightBlueIcon className="fa-2x" name={icon} color="inherit" />
<div className="is-size-4">{t("login." + type)}</div>
<div className="is-size-4">{t("login.tip")}</div>
</FixedSizedIconWrapper>
2019-08-13 08:23:37 +02:00
</figure>
{this.renderBody()}
</div>
</BottomMarginA>
2019-08-13 08:23:37 +02:00
);
}
}
export default withTranslation("commons")(InfoBox);