DocSpace-client/packages/asc-web-common/components/MediaViewer/MediaViewer.stories.js

99 lines
2.2 KiB
JavaScript
Raw Normal View History

import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import Section from "../../../.storybook/decorators/section";
import MediaViewer from ".";
2021-02-25 21:19:45 +00:00
import Button from "@appserver/components/button";
import withReadme from "storybook-readme/with-readme";
import { withKnobs, boolean, text } from "@storybook/addon-knobs/react";
import Readme from "./README.md";
2020-04-19 20:06:17 +00:00
var playlist = [
{
id: 0,
fileId: 0,
src: "",
title: "",
},
];
2020-04-30 07:35:02 +00:00
class MediaViewerStory extends React.Component {
constructor(props) {
super(props);
this.state = {
visible: false,
};
2020-04-30 07:35:02 +00:00
}
buttonClick = () => {
this.setState({
visible: true,
2020-04-30 07:35:02 +00:00
});
};
2020-04-30 07:35:02 +00:00
onClose = () => {
this.setState({
visible: false,
2020-04-30 07:35:02 +00:00
});
};
2020-04-30 07:35:02 +00:00
render() {
return (
<Section>
<div style={{ marginBottom: "20px" }}>
<Button label="Open" onClick={this.buttonClick} />
2020-04-30 07:35:02 +00:00
</div>
<MediaViewer
currentFileId={0}
2020-04-30 07:35:02 +00:00
allowConvert={true}
canDelete={(fileId) => {
if (fileId == 1) return false;
return true;
}}
2020-04-30 07:35:02 +00:00
visible={this.state.visible}
playlist={playlist}
onDelete={(fileId) => action("On delete")(fileId)}
onDownload={(fileId) => action("On download")(fileId)}
2020-04-30 07:35:02 +00:00
onClose={this.onClose}
extsMediaPreviewed={[
".aac",
".flac",
".m4a",
".mp3",
".oga",
".ogg",
".wav",
".f4v",
".m4v",
".mov",
".mp4",
".ogv",
".webm",
".avi",
".mpg",
".mpeg",
".wmv",
]}
extsImagePreviewed={[
".bmp",
".gif",
".jpeg",
".jpg",
".png",
".ico",
".tif",
".tiff",
".webp",
]}
2020-04-30 07:35:02 +00:00
/>
</Section>
);
}
2020-04-30 07:35:02 +00:00
}
storiesOf("Components|MediaViewer", module)
2020-04-30 07:35:02 +00:00
.addDecorator(withKnobs)
.addDecorator(withReadme(Readme))
.add("base", () => (
2020-04-30 07:35:02 +00:00
<Section>
<MediaViewerStory />
</Section>
));