forked from element-hq/element-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoomListSectionHeaderView.stories.tsx
More file actions
116 lines (104 loc) · 2.96 KB
/
RoomListSectionHeaderView.stories.tsx
File metadata and controls
116 lines (104 loc) · 2.96 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
/*
* 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 {
RoomListSectionHeaderView,
type RoomListSectionHeaderViewSnapshot,
type RoomListSectionHeaderActions,
type RoomListSectionHeaderViewProps,
} from "./RoomListSectionHeaderView";
import { useMockedViewModel } from "../../../core/viewmodel";
import { withViewDocs } from "../../../../.storybook/withViewDocs";
type RoomListSectionHeaderProps = RoomListSectionHeaderViewSnapshot &
RoomListSectionHeaderActions &
Omit<RoomListSectionHeaderViewProps, "vm">;
const RoomListSectionHeaderViewWrapperImpl = ({
onClick,
onFocus,
isFocused,
sectionIndex,
sectionCount,
indexInList,
roomCountInSection,
...rest
}: RoomListSectionHeaderProps): JSX.Element => {
const vm = useMockedViewModel(rest, { onClick });
return (
<RoomListSectionHeaderView
vm={vm}
onFocus={onFocus}
isFocused={isFocused}
sectionIndex={sectionIndex}
sectionCount={sectionCount}
indexInList={indexInList}
roomCountInSection={roomCountInSection}
/>
);
};
const RoomListSectionHeaderViewWrapper = withViewDocs(RoomListSectionHeaderViewWrapperImpl, RoomListSectionHeaderView);
const meta = {
title: "Room List/RoomListSectionHeaderView",
component: RoomListSectionHeaderViewWrapper,
tags: ["autodocs"],
args: {
id: "favourites",
title: "Favourites",
isExpanded: true,
isFocused: false,
isUnread: false,
onClick: fn(),
onFocus: fn(),
sectionIndex: 1,
sectionCount: 3,
roomCountInSection: 5,
indexInList: 3,
},
decorators: [
(Story) => (
<div role="treegrid" style={{ width: "320px" }}>
<Story />
</div>
),
],
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/design/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?node-id=10657-20703&p=f",
},
},
} satisfies Meta<typeof RoomListSectionHeaderViewWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};
export const Collapsed: Story = {
args: {
isExpanded: false,
},
};
export const LongTitle: Story = {
args: {
title: "This is a very long title that should be truncated with an ellipsis",
},
};
export const FirstHeader: Story = {
args: {
sectionIndex: 0,
},
};
export const LastHeaderCollapsed: Story = {
args: {
isExpanded: false,
sectionIndex: 2,
},
};
export const Unread: Story = {
args: {
isUnread: true,
},
};