Skip to content

Commit 2f187f1

Browse files
authored
Merge pull request #74 from element-hq/florianduros/room-list-header
2 parents 16e08f7 + a5dd101 commit 2f187f1

16 files changed

+272
-517
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"biome:format": "yarn biome format --write ."
2121
},
2222
"dependencies": {
23-
"@element-hq/web-shared-components": "0.0.0-test.12",
23+
"@element-hq/web-shared-components": "0.0.1",
2424
"@tauri-apps/api": "^1.5.2",
2525
"@vector-im/compound-design-tokens": "^6.0.0",
2626
"@vector-im/compound-web": "^8.2.1",

src/App.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ body {
2424
color: var(--cpd-color-text-primary);
2525
}
2626

27-
.mx_LoadingSession {
28-
display: flex;
29-
flex-direction: column;
30-
width: 100%;
31-
height: 100%;
32-
align-items: center;
33-
justify-content: center;
34-
}
35-
3627
/* room for the tauri window header */
3728
.mx_Header {
3829
flex: 0 0 auto;

src/App.tsx

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
import type React from "react";
2-
import type { ReactNode } from "react";
2+
import { type ReactNode, useEffect, useState } from "react";
33
import "./App.css";
4+
import {
5+
type I18nApi,
6+
I18nContext,
7+
useViewModel,
8+
} from "@element-hq/web-shared-components";
49
import { InlineSpinner } from "@vector-im/compound-web";
5-
import { useViewModel } from "@element-hq/web-shared-components";
610
import { Client } from "./Client.tsx";
711
import { Encryption } from "./Encryption.tsx";
12+
import { LoadingScreen } from "./LoadingScreen/LoadingScreen.tsx";
813
import { Login } from "./Login.tsx";
914
import { OidcCallback } from "./OidcCallback.tsx";
15+
import { I18nTest } from "./components/I18nTest.tsx";
1016
import { useClientStoreContext } from "./context/ClientStoreContext";
1117
import { useClientStoresContext } from "./context/ClientStoresContext";
1218
import { useSessionStoreContext } from "./context/SessionStoreContext";
13-
import { ClientState } from "./viewmodel/client-view.types";
19+
import { createI18nApi } from "./utils/i18nApi.ts";
1420
import { ClientViewModel } from "./viewmodel/ClientViewModel";
21+
import { ClientState } from "./viewmodel/client-view.types";
1522

1623
console.log("running App.tsx");
1724

1825
const App: React.FC = () => {
1926
const [clientViewModel, setClientViewModel] = useClientStoreContext();
2027
const [, addClientStore] = useClientStoresContext();
2128
const sessionStore = useSessionStoreContext();
29+
const i18nApi = useI18nApi();
2230

2331
// Check if we're on the OIDC callback route
2432
const isOidcCallback = window.location.pathname === "/oidc/callback";
@@ -38,10 +46,9 @@ const App: React.FC = () => {
3846
clientState === ClientState.LoadingSession
3947
) {
4048
component = (
41-
<div className="mx_LoadingSession">
42-
<InlineSpinner size={32} />
49+
<LoadingScreen>
4350
<h2>Loading Session...</h2>
44-
</div>
51+
</LoadingScreen>
4552
);
4653
} else if (clientState === ClientState.SettingUpEncryption) {
4754
component = encryptionViewModel ? (
@@ -76,7 +83,34 @@ const App: React.FC = () => {
7683
) : null;
7784
}
7885

79-
return <div className="mx_App">{component}</div>;
86+
if (!i18nApi) {
87+
return (
88+
<div className="mx_App">
89+
<LoadingScreen>Loading translations</LoadingScreen>
90+
</div>
91+
);
92+
}
93+
return (
94+
<div className="mx_App">
95+
<I18nContext.Provider value={i18nApi}>
96+
{component}
97+
</I18nContext.Provider>
98+
</div>
99+
);
80100
};
81101

82102
export default App;
103+
104+
/**
105+
* A hook that initializes and provides an I18n API instance.
106+
* @returns
107+
*/
108+
function useI18nApi(): I18nApi | undefined {
109+
const [i18nApi, setI18nApi] = useState<I18nApi>();
110+
111+
useEffect(() => {
112+
createI18nApi().then((api) => setI18nApi(api));
113+
}, []);
114+
115+
return i18nApi;
116+
}

src/Client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { useViewModel } from "@element-hq/web-shared-components";
55
import { Composer } from "./Composer.tsx";
66
import MemberListView from "./MemberList/MemberListView.tsx";
77
import { RoomHeaderView } from "./RoomHeaderView";
8+
import { RoomListSearch } from "./RoomList";
89
import { RoomListFiltersView } from "./RoomListFiltersView";
910
import { RoomListHeaderView } from "./RoomListHeaderView";
1011
import { RoomListView } from "./RoomListView";
11-
import { RoomSearchView } from "./RoomSearchView";
1212
import { RoomView } from "./RoomView";
1313
import { SidePanelView } from "./SidePanelView.tsx";
1414
import { SplashView } from "./SplashView.tsx";
@@ -47,7 +47,7 @@ export const Client: React.FC<ClientProps> = ({ onAddAccount }) => {
4747
/>
4848
</nav>
4949
<nav className="mx_RoomList">
50-
<RoomSearchView />
50+
<RoomListSearch />
5151
{
5252
<>
5353
<RoomListHeaderView />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.container {
2+
width: 100%;
3+
height: 100%;
4+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2026 Element Creations Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import { Flex } from "@element-hq/web-shared-components";
9+
import { InlineSpinner } from "@vector-im/compound-web";
10+
import type { PropsWithChildren } from "react";
11+
import styles from "./LoadingScreen.module.css";
12+
13+
export function LoadingScreen({ children }: PropsWithChildren) {
14+
return (
15+
<Flex
16+
className={styles.container}
17+
direction="column"
18+
align="center"
19+
justify="center"
20+
>
21+
<InlineSpinner size={32} />
22+
{children}
23+
</Flex>
24+
);
25+
}

src/RoomList/RoomListSearch.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2026 Element Creations Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import {
9+
RoomListSearchView,
10+
useCreateAutoDisposedViewModel,
11+
} from "@element-hq/web-shared-components";
12+
import { RoomListSearchViewModel } from "./RoomListSearchViewModel";
13+
14+
export function RoomListSearch() {
15+
const vm = useCreateAutoDisposedViewModel(
16+
() => new RoomListSearchViewModel(),
17+
);
18+
19+
return <RoomListSearchView vm={vm} />;
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2026 Element Creations Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import {
9+
BaseViewModel,
10+
type RoomListSearchViewSnapshot,
11+
type RoomListSearchViewModel as RoomListSearchViewModelInterface,
12+
} from "@element-hq/web-shared-components";
13+
14+
export class RoomListSearchViewModel
15+
extends BaseViewModel<RoomListSearchViewSnapshot, null>
16+
implements RoomListSearchViewModelInterface
17+
{
18+
constructor() {
19+
super(null, {
20+
displayDialButton: true,
21+
displayExploreButton: true,
22+
searchShortcut: "⌘ K",
23+
});
24+
}
25+
26+
onSearchClick(): void {
27+
// Implement search click handling logic here
28+
}
29+
30+
onExploreClick(): void {
31+
// Implement explore click handling logic here
32+
}
33+
34+
onDialPadClick(): void {
35+
// Implement dial pad click handling logic here
36+
}
37+
}

src/RoomList/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright 2026 Element Creations Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
export { RoomListSearch } from "./RoomListSearch";

src/RoomSearchView.css

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)