-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathRoomStatusBarView.stories.tsx
More file actions
121 lines (110 loc) · 3.34 KB
/
RoomStatusBarView.stories.tsx
File metadata and controls
121 lines (110 loc) · 3.34 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (c) 2025 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 { type Meta, type StoryObj } from "@storybook/react-vite";
import React, { type JSX } from "react";
import { fn } from "storybook/test";
import { useMockedViewModel } from "../../core/viewmodel";
import { withViewDocs } from "../../../.storybook/withViewDocs";
import {
RoomStatusBarState,
RoomStatusBarView,
type RoomStatusBarViewActions,
type RoomStatusBarViewSnapshot,
} from "./RoomStatusBarView";
type RoomStatusBarProps = RoomStatusBarViewSnapshot & RoomStatusBarViewActions;
const RoomStatusBarViewWrapperImpl = ({
onResendAllClick,
onDeleteAllClick,
onRetryRoomCreationClick,
onTermsAndConditionsClicked,
...rest
}: RoomStatusBarProps): JSX.Element => {
const vm = useMockedViewModel(rest, {
onResendAllClick,
onDeleteAllClick,
onRetryRoomCreationClick,
onTermsAndConditionsClicked,
});
return <RoomStatusBarView vm={vm} />;
};
const RoomStatusBarViewWrapper = withViewDocs(RoomStatusBarViewWrapperImpl, RoomStatusBarView);
const meta = {
title: "Room/RoomStatusBarView",
component: RoomStatusBarViewWrapper,
tags: ["autodocs"],
argTypes: {},
args: {
onResendAllClick: fn(),
onDeleteAllClick: fn(),
onRetryRoomCreationClick: fn(),
onTermsAndConditionsClicked: fn(),
},
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/design/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?node-id=11019-2353&t=p8SkJGh9tJx09MTJ-4",
},
},
} satisfies Meta<typeof RoomStatusBarViewWrapper>;
export default meta;
type Story = StoryObj<typeof RoomStatusBarViewWrapper>;
/**
* Rendered when the client has lost connection with the server.
*/
export const WithConnectionLost: Story = {
args: {
state: RoomStatusBarState.ConnectionLost,
},
};
/**
* Rendered when the client needs the user to consent to some terms and conditions before
* they can perform any room actions.
*/
export const WithConsentLink: Story = {
args: {
state: RoomStatusBarState.NeedsConsent,
consentUri: "#example",
},
};
/**
* Rendered when the server has hit a usage limit and is forbidding the user from performing
* any actions in the room. There is an optional parameter to link to an admin to contact.
*/
export const WithResourceLimit: Story = {
args: {
state: RoomStatusBarState.ResourceLimited,
resourceLimit: "hs_disabled",
adminContactHref: "#example",
},
};
/**
* Rendered when the client has some unsent messages in the room, stored locally.
*/
export const WithUnsentMessages: Story = {
args: {
state: RoomStatusBarState.UnsentMessages,
isResending: false,
},
};
/**
* Rendered when the client has some unsent messages in the room, stored locally and is
* trying to send them.
*/
export const WithUnsentMessagesSending: Story = {
args: {
state: RoomStatusBarState.UnsentMessages,
isResending: true,
},
};
/**
* Rendered when a local room has failed to be created.
*/
export const WithLocalRoomRetry: Story = {
args: {
state: RoomStatusBarState.LocalRoomFailed,
},
};