2020-07-07 08:35:49 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-07-21 03:05:45 +03:00
|
|
|
import {
|
|
|
|
ButtonPrimaryFull,
|
|
|
|
ButtonSecondaryFull,
|
|
|
|
} from "~/components/system/components/Buttons";
|
2020-07-07 08:35:49 +03:00
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
|
|
|
|
2020-07-07 11:03:45 +03:00
|
|
|
const STYLES_CONTAINER = css`
|
2020-07-10 08:03:37 +03:00
|
|
|
font-family: ${Constants.font.text};
|
|
|
|
box-sizing: border-box;
|
2020-07-07 11:03:45 +03:00
|
|
|
padding: 24px;
|
|
|
|
border-radius: 4px;
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
|
|
|
border: 1px solid ${Constants.system.border};
|
|
|
|
max-width: 320px;
|
|
|
|
width: 100%;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_FILE_HIDDEN = css`
|
|
|
|
height: 1px;
|
|
|
|
width: 1px;
|
|
|
|
opacity: 0;
|
|
|
|
visibility: hidden;
|
|
|
|
position: fixed;
|
|
|
|
top: -1px;
|
|
|
|
left: -1px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_FOCUS = css`
|
2020-07-10 08:03:37 +03:00
|
|
|
box-sizing: border-box;
|
2020-07-07 11:03:45 +03:00
|
|
|
font-size: ${Constants.typescale.lvl1};
|
|
|
|
font-family: ${Constants.font.medium};
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
strong {
|
|
|
|
font-family: ${Constants.font.semiBold};
|
|
|
|
font-weight: 400;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_SUBTEXT = css`
|
|
|
|
margin-top: 8px;
|
|
|
|
font-size: 12px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ITEM = css`
|
|
|
|
margin-top: 16px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
export class CreateFilecoinStorageDeal extends React.Component {
|
|
|
|
static defaultProps = {
|
|
|
|
onSubmit: () => alert("onSubmit"),
|
|
|
|
};
|
|
|
|
|
|
|
|
state = { file: null };
|
|
|
|
|
|
|
|
_handleUpload = (e) => {
|
|
|
|
e.persist();
|
|
|
|
let file = e.target.files[0];
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
alert("Something went wrong");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({ file });
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleSubmit = (e) => {
|
|
|
|
this.props.onSubmit({ file });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div css={STYLES_CONTAINER}>
|
|
|
|
<input
|
|
|
|
css={STYLES_FILE_HIDDEN}
|
|
|
|
type="file"
|
|
|
|
id="file"
|
|
|
|
onChange={this._handleUpload}
|
|
|
|
/>
|
|
|
|
{this.state.file ? (
|
|
|
|
<div style={{ marginBottom: 24 }}>
|
|
|
|
<div css={STYLES_ITEM}>
|
|
|
|
<div css={STYLES_FOCUS}>{this.state.file.name}</div>
|
|
|
|
<div css={STYLES_SUBTEXT}>Name</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div css={STYLES_ITEM}>
|
|
|
|
<div css={STYLES_FOCUS}>{this.state.file.size}</div>
|
|
|
|
<div css={STYLES_SUBTEXT}>File size</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : null}
|
2020-07-21 03:05:45 +03:00
|
|
|
<ButtonSecondaryFull type="label" htmlFor="file">
|
2020-07-07 11:03:45 +03:00
|
|
|
Add file
|
2020-07-21 03:05:45 +03:00
|
|
|
</ButtonSecondaryFull>
|
2020-07-07 11:03:45 +03:00
|
|
|
{this.state.file ? (
|
2020-07-21 03:05:45 +03:00
|
|
|
<ButtonPrimaryFull
|
2020-07-07 11:03:45 +03:00
|
|
|
style={{ marginTop: 24 }}
|
|
|
|
onClick={this._handleSubmit}
|
|
|
|
>
|
|
|
|
Make storage deal
|
2020-07-21 03:05:45 +03:00
|
|
|
</ButtonPrimaryFull>
|
2020-07-07 11:03:45 +03:00
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|