import React from "react";
import { AttachmentUpload } from "../../AttachmentService";
import { styled } from "typestyle-react";
import { humanAttachmentTitle } from "../../util/text";
import { Flex, Item, ProgressBar } from "@heydovetail/ui-components";
interface Props {
name?: string;
uploadState: AttachmentUpload;
}
export function AttachmentDetails(props: Props) {
const { name, uploadState } = props;
let content: React.ReactNode = null;
switch (uploadState.type) {
case "uploading":
content = (
);
break;
case "queued":
content = ;
break;
case "failed":
content = "Upload Failed";
break;
case "unknown":
case "complete":
content = humanAttachmentTitle(name);
}
return {content} ;
}
const Details = styled("div", {
flexGrow: 1,
fontSize: "14px",
fontWeight: 600,
lineHeight: "24px",
marginLeft: 8,
overflow: "hidden",
// When used in an attachment card, and the user drags when a mouse, this
// prevents the dragged preview from being just the name or icon, and instead
// causes the drag to happen on the card container, which means the entire
// card is rendered in a dragged preview.
pointerEvents: "none",
textOverflow: "ellipsis",
whiteSpace: "nowrap"
});
const LabelledProgressBar: React.SFC<{ label: string; numerator: number; denominator: number }> = ({
label,
numerator,
denominator
}) => (
- {label}
-
);