2020-04-09 00:29:13 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
|
|
|
|
|
|
|
const STYLES_SECTION = css`
|
2020-08-09 06:52:22 +03:00
|
|
|
flex-shrink: 0;
|
2020-04-09 00:29:13 +03:00
|
|
|
width: 100%;
|
2020-08-09 01:38:09 +03:00
|
|
|
min-width: 960px;
|
2020-04-09 00:29:13 +03:00
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.gray}, 0 1px 4px rgba(0, 0, 0, 0.04);
|
|
|
|
border-radius: 4px;
|
|
|
|
font-weight: 400;
|
|
|
|
margin-top: 24px;
|
2020-09-09 20:56:35 +03:00
|
|
|
white-space: pre-wrap;
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
:first-child {
|
|
|
|
margin-top: 0px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_HEADER = css`
|
|
|
|
background: ${Constants.system.foreground};
|
|
|
|
border-bottom: 1px solid ${Constants.system.border};
|
2020-07-02 11:24:14 +03:00
|
|
|
font-family: ${Constants.font.medium};
|
2020-04-09 00:29:13 +03:00
|
|
|
font-size: ${Constants.typescale.lvl1};
|
|
|
|
border-radius: 4px 4px 0 0;
|
2020-07-27 12:50:25 +03:00
|
|
|
padding: 24px 24px 24px 20px;
|
2020-04-09 00:29:13 +03:00
|
|
|
overflow: hidden;
|
|
|
|
display: flex;
|
2020-08-09 06:52:22 +03:00
|
|
|
width: 100%;
|
2020-04-09 00:29:13 +03:00
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_LEFT = css`
|
|
|
|
min-width: 5%;
|
|
|
|
width: 100%;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_RIGHT = css`
|
|
|
|
flex-shrink: 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_CHILDREN = css`
|
|
|
|
background: ${Constants.system.white};
|
|
|
|
border-radius: 0 0 4px 4px;
|
2020-08-09 06:52:22 +03:00
|
|
|
width: 100%;
|
2020-04-09 00:29:13 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_BUTTON = css`
|
|
|
|
border-radius: 4px;
|
|
|
|
outline: 0;
|
|
|
|
border: 0;
|
|
|
|
min-height: 32px;
|
|
|
|
padding: 6px 16px 6px 16px;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
font-size: 12px;
|
|
|
|
letter-spacing: 0.2px;
|
2020-07-02 11:24:14 +03:00
|
|
|
font-family: ${Constants.font.semiBold};
|
2020-04-09 00:29:13 +03:00
|
|
|
transition: 200ms ease all;
|
2020-08-20 08:45:43 +03:00
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.border},
|
|
|
|
0 1px 4px rgba(0, 0, 0, 0.07);
|
2020-04-09 00:29:13 +03:00
|
|
|
cursor: pointer;
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
color: ${Constants.system.black};
|
|
|
|
margin-left: 16px;
|
|
|
|
|
|
|
|
:hover {
|
|
|
|
background-color: #f2f4f8;
|
|
|
|
}
|
|
|
|
|
|
|
|
:focus {
|
2020-09-13 01:08:36 +03:00
|
|
|
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.3) inset;
|
2020-04-09 00:29:13 +03:00
|
|
|
outline: 0;
|
|
|
|
border: 0;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-30 23:31:09 +03:00
|
|
|
export const Section = (props) => {
|
2020-04-09 00:29:13 +03:00
|
|
|
return (
|
|
|
|
<div css={STYLES_SECTION} style={props.style}>
|
|
|
|
<header css={STYLES_HEADER}>
|
|
|
|
<div css={STYLES_LEFT}>{props.title}</div>
|
|
|
|
{props.buttons ? (
|
|
|
|
<div css={STYLES_RIGHT}>
|
|
|
|
{props.buttons.map((b) => {
|
|
|
|
return (
|
2020-09-23 14:17:56 +03:00
|
|
|
<label
|
2020-08-20 08:45:43 +03:00
|
|
|
key={b.name}
|
2020-09-23 14:17:56 +03:00
|
|
|
htmlFor={b.type}
|
2020-08-20 08:45:43 +03:00
|
|
|
css={STYLES_BUTTON}
|
2020-09-23 14:17:56 +03:00
|
|
|
onClick={b.type !== "file" ? () => props.onAction(b) : null}
|
2020-09-13 01:08:36 +03:00
|
|
|
>
|
2020-04-09 00:29:13 +03:00
|
|
|
{b.name}
|
2020-09-23 14:17:56 +03:00
|
|
|
</label>
|
2020-04-09 00:29:13 +03:00
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</header>
|
|
|
|
<div css={STYLES_CHILDREN}>{props.children}</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-08-30 23:31:09 +03:00
|
|
|
|
|
|
|
export default Section;
|