-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathVideoBodyView.stories.tsx
More file actions
100 lines (87 loc) · 2.64 KB
/
VideoBodyView.stories.tsx
File metadata and controls
100 lines (87 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
import React, { type ReactNode } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import posterImage from "../../../../../../static/element.png";
import {
VideoBodyView,
VideoBodyViewState,
type VideoBodyViewActions,
type VideoBodyViewSnapshot,
} from "./VideoBodyView";
import { useMockedViewModel } from "../../../../../core/viewmodel/useMockedViewModel";
import { withViewDocs } from "../../../../../../.storybook/withViewDocs";
const demoVideo = new URL("../../../../../../static/videoBodyDemo.webm", import.meta.url).href;
type VideoBodyViewProps = VideoBodyViewSnapshot &
VideoBodyViewActions & {
className?: string;
children?: ReactNode;
};
const VideoBodyViewWrapperImpl = ({
onPreviewClick,
onPlay,
className,
children,
...snapshotProps
}: VideoBodyViewProps): ReactNode => {
const vm = useMockedViewModel(snapshotProps, { onPreviewClick, onPlay });
return (
<VideoBodyView vm={vm} className={className}>
{children}
</VideoBodyView>
);
};
const VideoBodyViewWrapper = withViewDocs(VideoBodyViewWrapperImpl, VideoBodyView);
const meta = {
title: "Timeline/Timeline Body/VideoBodyView",
component: VideoBodyViewWrapper,
tags: ["autodocs"],
argTypes: {
state: {
options: Object.entries(VideoBodyViewState)
.filter(([key, value]) => key === value)
.map(([key]) => key),
control: { type: "select" },
},
className: { control: "text" },
},
args: {
state: VideoBodyViewState.READY,
videoLabel: "Product demo video",
hiddenButtonLabel: "Show video",
errorLabel: "Error decrypting video",
maxWidth: 320,
maxHeight: 180,
aspectRatio: "16/9",
src: demoVideo,
poster: posterImage,
preload: "none",
controls: true,
muted: false,
autoPlay: false,
className: undefined,
children: <div>File body slot</div>,
},
} satisfies Meta<typeof VideoBodyViewWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Ready: Story = {};
export const Hidden: Story = {
args: {
state: VideoBodyViewState.HIDDEN,
},
};
export const Loading: Story = {
args: {
state: VideoBodyViewState.LOADING,
},
};
export const ErrorState: Story = {
args: {
state: VideoBodyViewState.ERROR,
},
};