import { storiesOf } from "@storybook/react"; import React from "react"; import { AttachmentVideo } from ".."; import { Attachment } from "../../../util/attrs"; import { MockAttachmentService } from "../../Shared/__stories__/MockAttachmentService"; import { AttachmentDownloadUrl } from "../../../AttachmentService"; import { AttachmentPreview, AttachmentUpload } from "../../../.."; const ATTACHMENT_MP4: Attachment = { hidePreview: false, id: "1", name: "Elephant’s Dream – The Wires", type: "video/mp4" }; storiesOf(`Attachments/${AttachmentVideo.name}`, module) .add("Default", () => ( {}} onRemove={() => {}} /> )) .add("Active", () => ( {}} onRemove={() => {}} style="active" /> )) .add("Selected", () => ( {}} onRemove={() => {}} style="selected" /> )) .add("Not Editable", () => ( {}} onRemove={() => {}} /> )) .add("Download pending", () => ( {}} onRemove={() => {}} /> )) .add("Download unavailable", () => ( {}} onRemove={() => {}} /> )) .add("Uploading", () => ( {}} onRemove={() => {}} /> )) .add("Uploading pending", () => ( {}} onRemove={() => {}} /> )) .add("Uploading unknown", () => ( {}} onRemove={() => {}} /> )) .add("Uploading failed", () => ( {}} onRemove={() => {}} /> )) .add("Stateful", () => { interface State { downloadUrl: AttachmentDownloadUrl; preview: AttachmentPreview; upload: AttachmentUpload; } class Example extends React.PureComponent<{}, State> { public state: State = { downloadUrl: { type: "pending" }, preview: { type: "unavailable" }, upload: { bytesUploaded: 50000, bytesTotal: 200000, type: "uploading" } }; public componentDidMount() { if (window !== undefined) { window.setTimeout(() => { this.setState({ downloadUrl: { type: "pending" }, upload: { type: "complete" } }); }, 2000); window.setTimeout(() => { this.setState({ downloadUrl: { type: "available", url: "https://storage.googleapis.com/media-session/elephants-dream/teaser.mp4" } }); }, 5000); } } public render() { const { downloadUrl, preview, upload } = this.state; return ( {}} onRemove={() => {}} /> ); } } return ; });