-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathActionBarView.stories.tsx
More file actions
194 lines (179 loc) · 5.61 KB
/
ActionBarView.stories.tsx
File metadata and controls
194 lines (179 loc) · 5.61 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* 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 JSX } from "react";
import { fn } from "storybook/test";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { ActionBarAction, ActionBarView, type ActionBarViewActions, type ActionBarViewSnapshot } from "./ActionBarView";
import { useMockedViewModel } from "../../../../../core/viewmodel";
import { withViewDocs } from "../../../../../../.storybook/withViewDocs";
type ActionBarProps = ActionBarViewSnapshot & ActionBarViewActions;
const ActionBarViewWrapperImpl = ({ ...snapshotAndActions }: ActionBarProps): JSX.Element => {
const {
onCancelClick = fn(),
onCopyLinkClick = fn(),
onDownloadClick = fn(),
onEditClick = fn(),
onHideClick = fn(),
onOptionsClick = fn(),
onPinClick = fn(),
onReactionsClick = fn(),
onRemoveClick = fn(),
onReplyClick = fn(),
onReplyInThreadClick = fn(),
onResendClick = fn(),
onToggleThreadExpanded = fn(),
onViewInRoomClick = fn(),
onViewSourceClick = fn(),
...snapshot
} = snapshotAndActions;
const vm = useMockedViewModel(snapshot, {
onCancelClick,
onCopyLinkClick,
onDownloadClick,
onEditClick,
onHideClick,
onOptionsClick,
onPinClick,
onReactionsClick,
onRemoveClick,
onReplyClick,
onReplyInThreadClick,
onResendClick,
onToggleThreadExpanded,
onViewInRoomClick,
onViewSourceClick,
});
return <ActionBarView vm={vm} className="mx_MessageActionBar" />;
};
const ActionBarViewWrapper = withViewDocs(ActionBarViewWrapperImpl, ActionBarView);
const meta = {
title: "Timeline/Timeline Action/ActionBarView",
component: ActionBarViewWrapper,
tags: ["autodocs"],
argTypes: {
presentation: {
control: { type: "select" },
options: ["icon", "label"],
},
},
args: {
actions: [
ActionBarAction.Hide,
ActionBarAction.Download,
ActionBarAction.React,
ActionBarAction.Reply,
ActionBarAction.ReplyInThread,
ActionBarAction.Edit,
ActionBarAction.Pin,
ActionBarAction.Resend,
ActionBarAction.Cancel,
ActionBarAction.Expand,
ActionBarAction.Options,
ActionBarAction.ViewInRoom,
ActionBarAction.CopyLink,
ActionBarAction.Remove,
ActionBarAction.ViewSource,
],
presentation: "icon",
isDownloadEncrypted: false,
isDownloadLoading: false,
isPinned: false,
isQuoteExpanded: false,
isThreadReplyAllowed: true,
},
} satisfies Meta<typeof ActionBarViewWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const AllIconActions: Story = {};
export const AllLabelActions: Story = {
args: {
actions: [
ActionBarAction.Hide,
ActionBarAction.Download,
ActionBarAction.React,
ActionBarAction.Reply,
ActionBarAction.ReplyInThread,
ActionBarAction.Edit,
ActionBarAction.Pin,
ActionBarAction.Resend,
ActionBarAction.Cancel,
ActionBarAction.Expand,
ActionBarAction.Options,
ActionBarAction.ViewInRoom,
ActionBarAction.CopyLink,
ActionBarAction.Remove,
ActionBarAction.ViewSource,
],
presentation: "label",
},
};
export const DownloadingAttachment: Story = {
args: {
actions: [ActionBarAction.Download, ActionBarAction.Options],
isDownloadLoading: true,
isDownloadEncrypted: false,
},
parameters: {
docs: {
description: {
story: "Attachment download in progress. The download action is disabled and shows a spinner with the downloading label.",
},
},
},
};
export const DecryptingAttachment: Story = {
args: {
...DownloadingAttachment.args,
isDownloadEncrypted: true,
},
parameters: {
docs: {
description: {
story: "Encrypted attachment state. Uses the same loading UI as download, but with the decrypting label.",
},
},
},
};
export const PinnedMessage: Story = {
args: {
actions: [ActionBarAction.React, ActionBarAction.Reply, ActionBarAction.Pin, ActionBarAction.Options],
isPinned: true,
},
parameters: {
docs: {
description: {
story: "Pinned-state variant showing the unpin affordance instead of pin.",
},
},
},
};
export const ExpandedReplyChain: Story = {
args: {
actions: [ActionBarAction.Reply, ActionBarAction.Expand, ActionBarAction.Options],
isQuoteExpanded: true,
},
parameters: {
docs: {
description: {
story: "Reply-chain control in its expanded state, showing the collapse action and tooltip copy.",
},
},
},
};
export const DisabledThreadReply: Story = {
args: {
actions: [ActionBarAction.React, ActionBarAction.Reply, ActionBarAction.ReplyInThread, ActionBarAction.Options],
isThreadReplyAllowed: false,
},
parameters: {
docs: {
description: {
story: "Thread reply action present but disabled.",
},
},
},
};