DocSpace-client/web/ASC.Web.Components/src/components/empty-screen-container/index.js

142 lines
2.9 KiB
JavaScript
Raw Normal View History

import React from "react";
2020-10-07 07:59:31 +00:00
import styled from "styled-components";
import PropTypes from "prop-types";
import Text from "../text";
2020-10-05 18:22:03 +00:00
import { mobile } from "../../utils/device";
const EmptyContentBody = styled.div`
2019-11-11 08:00:58 +00:00
margin: 0 auto;
padding: 64px 0;
display: grid;
grid-template-areas:
2020-10-07 07:59:31 +00:00
"img headerText"
${(props) => props.subheadingText && `"img subheadingText"`}
${(props) => props.descriptionText && `"img descriptionText"`}
"img button";
grid-column-gap: 16px;
2020-10-12 13:56:34 +00:00
grid-row-gap: 10px;
2020-10-07 07:59:31 +00:00
max-width: 800px;
2020-10-12 13:56:34 +00:00
grid-template-rows: max-content;
.ec-image {
grid-area: img;
margin: 0 0 0 auto;
}
.ec-header {
2020-10-07 07:59:31 +00:00
grid-area: headerText;
2020-10-12 13:56:34 +00:00
padding-top: 16px;
}
.ec-subheading {
2020-10-07 07:59:31 +00:00
grid-area: subheadingText;
}
.ec-desc {
2020-10-07 07:59:31 +00:00
grid-area: descriptionText;
2020-10-12 13:56:34 +00:00
line-height: 18px;
}
.ec-buttons {
grid-area: button;
}
2019-11-11 08:00:58 +00:00
@media (orientation: portrait) {
2020-10-12 13:56:34 +00:00
@media (max-width: 768px) {
padding-top: 0px;
max-width: 700px;
2020-10-05 18:22:03 +00:00
2019-11-11 08:00:58 +00:00
.ec-image {
max-height: 100px;
2019-11-11 08:00:58 +00:00
}
}
2020-10-05 18:22:03 +00:00
@media ${mobile} {
2020-10-07 07:59:31 +00:00
min-width: 343px;
grid-template-areas:
"img"
2020-10-07 07:59:31 +00:00
"headerText"
${(props) => props.subheadingText && `"subheadingText"`}
${(props) => props.descriptionText && `"descriptionText"`}
"button";
2020-10-07 07:59:31 +00:00
.ec-header {
padding-top: 0px;
2020-10-05 18:22:03 +00:00
}
.ec-header,
.ec-subheading,
.ec-desc,
.ec-buttons {
padding-left: 16px;
2019-11-11 08:00:58 +00:00
}
2020-10-07 07:59:31 +00:00
.ec-image {
2020-10-07 07:59:31 +00:00
height: 75px;
margin-left: 0;
2019-11-11 08:00:58 +00:00
}
}
2019-11-11 08:00:58 +00:00
}
`;
const EmptyContentImage = styled.img.attrs((props) => ({
src: props.imageSrc,
alt: props.imageAlt,
}))`
background: no-repeat 0 0 transparent;
`;
const EmptyScreenContainer = (props) => {
const {
imageSrc,
imageAlt,
headerText,
subheadingText,
descriptionText,
buttons,
} = props;
return (
<EmptyContentBody {...props}>
<EmptyContentImage
imageSrc={imageSrc}
imageAlt={imageAlt}
className="ec-image"
/>
{headerText && (
<Text as="span" fontSize="19px" fontWeight="600" className="ec-header">
{headerText}
</Text>
)}
{subheadingText && (
<Text as="span" fontWeight="600" className="ec-subheading">
{subheadingText}
</Text>
)}
{descriptionText && (
<Text as="span" color="#6A7378" fontSize="12px" className="ec-desc">
{descriptionText}
</Text>
)}
{buttons && <div className="ec-buttons">{buttons}</div>}
</EmptyContentBody>
);
};
EmptyScreenContainer.propTypes = {
imageSrc: PropTypes.string,
imageAlt: PropTypes.string,
headerText: PropTypes.string,
subheadingText: PropTypes.string,
descriptionText: PropTypes.string,
buttons: PropTypes.any,
className: PropTypes.string,
id: PropTypes.string,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
};
export default EmptyScreenContainer;