diff --git a/src/app/organisms/room/RoomViewHeader.scss b/src/app/organisms/room/RoomViewHeader.scss index 84d8b8ca..b553abbd 100644 --- a/src/app/organisms/room/RoomViewHeader.scss +++ b/src/app/organisms/room/RoomViewHeader.scss @@ -3,9 +3,8 @@ @use "../../partials/screen"; .room-header__btn { - min-width: 0; @extend .cp-fx__row--s-c; - @include dir.side(margin, 0, auto); + @include dir.side(margin, 0, var(--sp-extra-tight)); border-radius: var(--bo-radius); cursor: pointer; @@ -27,21 +26,54 @@ } } +.room-header__topic { + min-width: 0; + display: flex; + align-items: center; + @include dir.side(margin, 0, auto); + + p { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} + .room-header__drawer-btn { + flex: 0; + @include screen.smallerThan(tabletBreakpoint) { display: none; } } + .room-header__members-btn { + flex: 0; + @include screen.biggerThan(tabletBreakpoint) { display: none; } } .room-header__back-btn { + flex: 0; + @include dir.side(margin, 0, var(--sp-tight)); @include screen.biggerThan(mobileBreakpoint) { display: none; } } + +.room-header__left { + display: flex; + flex-shrink: 1; + min-width: 0; +} + +.room-header__right { + display: flex; + flex-grow: 1; + justify-content: flex-end; + min-width: 0; +} diff --git a/src/app/organisms/room/RoomViewHeader.jsx b/src/app/organisms/room/RoomViewHeader.tsx similarity index 58% rename from src/app/organisms/room/RoomViewHeader.jsx rename to src/app/organisms/room/RoomViewHeader.tsx index fea7eed5..b5204447 100644 --- a/src/app/organisms/room/RoomViewHeader.jsx +++ b/src/app/organisms/room/RoomViewHeader.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useRef } from "react"; -import PropTypes from "prop-types"; import "./RoomViewHeader.scss"; import { twemojify } from "../../../util/twemojify"; @@ -33,16 +32,26 @@ import BackArrowIC from "../../../../public/res/ic/outlined/chevron-left.svg"; import { useForceUpdate } from "../../hooks/useForceUpdate"; -function RoomViewHeader({ roomId }) { +interface RoomViewHeaderProps { + roomId: string; +} + +function RoomViewHeader({ roomId }: RoomViewHeaderProps) { const [, forceUpdate] = useForceUpdate(); const mx = initMatrix.matrixClient; const isDM = initMatrix.roomList.directs.has(roomId); const room = mx.getRoom(roomId); let avatarSrc = room.getAvatarUrl(mx.baseUrl, 36, 36, "crop"); avatarSrc = isDM - ? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 36, 36, "crop") + ? room + .getAvatarFallbackMember() + ?.getAvatarUrl(mx.baseUrl, 36, 36, "crop", true, false) : avatarSrc; - const roomName = room.name; + const { name: roomName, currentState } = room; + + const roomTopic = currentState + .getStateEvents("m.room.topic")[0] + ?.getContent().topic; const roomHeaderBtnRef = useRef(null); useEffect(() => { @@ -89,61 +98,69 @@ function RoomViewHeader({ roomId }) { return (
- openNavigation()} - /> - - {mx.isRoomEncrypted(roomId) === false && ( +
toggleRoomSettings(tabText.SEARCH)} - tooltip="Search" - src={SearchIC} + src={BackArrowIC} + className="room-header__back-btn" + tooltip="Return to navigation" + onClick={() => openNavigation()} /> - )} - - toggleRoomSettings(tabText.MEMBERS)} - tooltip="Members" - src={UserIC} - /> - + + +
+ {roomTopic && ( + {twemojify(roomTopic, undefined, true)} + )} +
+
+ +
+ {mx.isRoomEncrypted(roomId) === false && ( + toggleRoomSettings(tabText.SEARCH)} + tooltip="Search" + src={SearchIC} + /> + )} + + toggleRoomSettings(tabText.MEMBERS)} + tooltip="Members" + src={UserIC} + /> + +
); } -RoomViewHeader.propTypes = { - roomId: PropTypes.string.isRequired, -}; export default RoomViewHeader; diff --git a/tsconfig.json b/tsconfig.json index e109a97c..8618f508 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,12 @@ "esModuleInterop": true, "moduleResolution": "Node", "outDir": "dist", - "skipLibCheck": true + "skipLibCheck": true, + + "baseUrl": ".", + "paths": { + "@": ["src/*"] + } }, "exclude": ["node_modules", "dist"], "include": ["src"] diff --git a/vite.config.js b/vite.config.js index 88e851c5..d504acc0 100644 --- a/vite.config.js +++ b/vite.config.js @@ -5,6 +5,7 @@ import { viteStaticCopy } from "vite-plugin-static-copy"; import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill"; import inject from "@rollup/plugin-inject"; import { svgLoader } from "./viteSvgLoader"; +import path from "path"; const copyFiles = { targets: [ @@ -35,6 +36,11 @@ export default defineConfig({ port: 8080, host: true, }, + resolve: { + alias: { + "@": path.resolve(__dirname, "./src"), + }, + }, plugins: [viteStaticCopy(copyFiles), svgLoader(), wasm(), react()], optimizeDeps: { esbuildOptions: {