DocSpace-client/packages/common/components/AlertComponent/index.js

105 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-04-03 10:52:06 +00:00
import React from "react";
import { inject, observer } from "mobx-react";
2023-04-13 08:33:08 +00:00
2023-04-03 10:52:06 +00:00
import styled from "styled-components";
import Text from "@docspace/components/text";
import commonIconsStyles from "@docspace/components/utils/common-icons-style";
import ArrowRightIcon from "PUBLIC_DIR/images/arrow.right.react.svg";
import CrossReactSvg from "PUBLIC_DIR/images/cross.react.svg";
import Loaders from "../Loaders";
import { StyledAlertComponent } from "./StyledComponent";
2023-04-03 12:42:51 +00:00
import Link from "@docspace/components/link";
2023-04-03 10:52:06 +00:00
const StyledArrowRightIcon = styled(ArrowRightIcon)`
margin: auto 0;
path {
2023-04-03 12:42:51 +00:00
fill: ${(props) => props.theme.alertComponent.iconColor};
2023-04-03 10:52:06 +00:00
}
`;
const StyledCrossIcon = styled(CrossReactSvg)`
position: absolute;
right: 0px;
margin-right: 8px;
margin-top: 8px;
2023-04-03 12:42:51 +00:00
cursor: pointer;
2023-04-03 10:52:06 +00:00
${commonIconsStyles}
path {
fill: ${(props) => props.color};
}
`;
2023-04-03 12:42:51 +00:00
const AlertComponent = (props) => {
const {
id,
description,
title,
titleFontSize,
additionalDescription,
needArrowIcon = false,
needCloseIcon = false,
link,
linkColor,
linkTitle,
onAlertClick,
onCloseClick,
titleColor,
borderColor,
theme,
} = props;
2023-04-03 10:52:06 +00:00
return (
<StyledAlertComponent
2023-04-03 12:42:51 +00:00
theme={theme}
titleColor={titleColor}
borderColor={borderColor}
2023-04-03 10:52:06 +00:00
onClick={onAlertClick}
needArrowIcon={needArrowIcon}
id={id}
>
<div>
<Text
className="alert-component_title"
fontSize={titleFontSize ?? "12px"}
fontWeight={600}
>
{title}
</Text>
{additionalDescription && (
<Text fontWeight={600}>{additionalDescription}</Text>
)}
2023-04-03 12:42:51 +00:00
<Text
noSelect
fontSize="12px"
color={theme.alertComponent.descriptionColor}
>
2023-04-03 10:52:06 +00:00
{description}
</Text>
{link && (
2023-04-03 12:42:51 +00:00
<Link type="page" href={link} noHover color={linkColor}>
2023-04-03 10:52:06 +00:00
{linkTitle}
</Link>
)}
</div>
{needCloseIcon && (
2023-04-03 12:42:51 +00:00
<StyledCrossIcon size="extraSmall" onClick={onCloseClick} />
2023-04-03 10:52:06 +00:00
)}
{needArrowIcon && (
<StyledArrowRightIcon className="alert-component_arrow" />
)}
</StyledAlertComponent>
);
};
2023-04-13 08:33:08 +00:00
export default inject(({ auth }) => {
const { settingsStore } = auth;
2023-04-03 10:52:06 +00:00
2023-04-13 08:33:08 +00:00
const { theme } = settingsStore;
2023-04-03 10:52:06 +00:00
2023-04-13 08:33:08 +00:00
return {
theme,
};
})(observer(AlertComponent));