DocSpace-client/web/ASC.Web.Common/src/components/Loaders/RowsLoader/RowsLoader.js

194 lines
4.3 KiB
JavaScript
Raw Normal View History

import React from "react";
2020-11-10 14:29:11 +00:00
import PropTypes from "prop-types";
2020-11-03 22:54:44 +00:00
import styled from "styled-components";
2020-11-06 12:20:06 +00:00
import RectangleLoader from "../RectangleLoader/index";
import CircleLoader from "../CircleLoader/index";
2020-11-03 22:54:44 +00:00
import { utils } from "asc-web-components";
2020-11-10 14:29:11 +00:00
const { desktop } = utils.device;
2020-11-03 22:54:44 +00:00
const StyledRow = styled.div`
width: 100%;
display: grid;
grid-template-columns: 16px 22px 1fr;
grid-template-rows: 1fr;
2020-11-09 13:38:13 +00:00
grid-column-gap: ${(props) => props.gap || "8px"};
2020-11-03 22:54:44 +00:00
margin-bottom: 32px;
justify-items: center;
align-items: center;
`;
2020-11-10 14:29:11 +00:00
const StyledBox1 = styled.div`
.rectangle-content {
width: 32px;
height: 32px;
}
@media ${desktop} {
.rectangle-content {
width: 22px;
height: 22px;
}
}
`;
const StyledBox2 = styled.div`
2020-11-03 22:54:44 +00:00
width: 100%;
display: grid;
grid-template-columns: 1fr;
2020-11-10 14:29:11 +00:00
grid-template-rows: 16px;
2020-11-03 22:54:44 +00:00
grid-row-gap: 4px;
justify-items: left;
align-items: left;
2020-11-10 14:29:11 +00:00
.first-row-content__mobile {
width: 80%;
}
@media ${desktop} {
grid-template-rows: 16px;
grid-row-gap: 0;
2020-11-03 22:54:44 +00:00
2020-11-10 14:29:11 +00:00
.first-row-content__mobile {
width: 100%;
}
.second-row-content__mobile {
width: 100%;
display: none;
}
}
`;
const Row = ({ id, className, style, isRectangle, ...rest }) => {
const {
title,
x,
y,
borderRadius,
backgroundColor,
foregroundColor,
backgroundOpacity,
foregroundOpacity,
speed,
animate,
} = rest;
2020-11-03 22:54:44 +00:00
return (
2020-11-10 14:29:11 +00:00
<StyledRow
id={id}
className={className}
style={style}
gap={isRectangle ? "8px" : "16px"}
>
<RectangleLoader
title={title}
x={x}
y={y}
width="16"
height="16"
borderRadius={borderRadius}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
backgroundOpacity={backgroundOpacity}
foregroundOpacity={foregroundOpacity}
speed={speed}
animate={animate}
/>
<StyledBox1>
{isRectangle ? (
<RectangleLoader
className="rectangle-content"
title={title}
x={x}
y={y}
width="100%"
height="100%"
borderRadius={borderRadius}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
backgroundOpacity={backgroundOpacity}
foregroundOpacity={foregroundOpacity}
speed={speed}
animate={animate}
/>
) : (
<CircleLoader
title={title}
x="16"
y="16"
width="32"
height="32"
radius="16"
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
backgroundOpacity={backgroundOpacity}
foregroundOpacity={foregroundOpacity}
speed={speed}
animate={animate}
/>
)}
</StyledBox1>
<StyledBox2>
<RectangleLoader
className="first-row-content__mobile"
title={title}
x={x}
y={y}
height="16px"
borderRadius={borderRadius}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
backgroundOpacity={backgroundOpacity}
foregroundOpacity={foregroundOpacity}
speed={speed}
animate={animate}
/>
<RectangleLoader
2020-11-10 14:29:11 +00:00
className="second-row-content__mobile"
title={title}
x={x}
y={y}
height="12px"
borderRadius={borderRadius}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
backgroundOpacity={backgroundOpacity}
foregroundOpacity={foregroundOpacity}
speed={speed}
animate={animate}
/>
2020-11-10 14:29:11 +00:00
</StyledBox2>
2020-11-03 22:54:44 +00:00
</StyledRow>
);
};
2020-11-06 12:38:20 +00:00
const RowsLoader = (props) => {
2020-11-03 22:54:44 +00:00
return (
<div>
2020-11-06 12:38:20 +00:00
<Row {...props} />
<Row {...props} />
<Row {...props} />
<Row {...props} />
<Row {...props} />
<Row {...props} />
2020-11-03 22:54:44 +00:00
</div>
);
};
Row.propTypes = {
2020-11-10 14:29:11 +00:00
id: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
isRectangle: PropTypes.bool,
};
Row.defaultProps = {
2020-11-10 14:29:11 +00:00
id: undefined,
className: undefined,
style: undefined,
isRectangle: true,
};
export default RowsLoader;