Compare commits
1 commit
dev
...
add-topic-
Author | SHA1 | Date | |
---|---|---|---|
e75fef6ba3 |
4 changed files with 118 additions and 58 deletions
|
@ -3,9 +3,8 @@
|
||||||
@use "../../partials/screen";
|
@use "../../partials/screen";
|
||||||
|
|
||||||
.room-header__btn {
|
.room-header__btn {
|
||||||
min-width: 0;
|
|
||||||
@extend .cp-fx__row--s-c;
|
@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);
|
border-radius: var(--bo-radius);
|
||||||
cursor: pointer;
|
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 {
|
.room-header__drawer-btn {
|
||||||
|
flex: 0;
|
||||||
|
|
||||||
@include screen.smallerThan(tabletBreakpoint) {
|
@include screen.smallerThan(tabletBreakpoint) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.room-header__members-btn {
|
.room-header__members-btn {
|
||||||
|
flex: 0;
|
||||||
|
|
||||||
@include screen.biggerThan(tabletBreakpoint) {
|
@include screen.biggerThan(tabletBreakpoint) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.room-header__back-btn {
|
.room-header__back-btn {
|
||||||
|
flex: 0;
|
||||||
|
|
||||||
@include dir.side(margin, 0, var(--sp-tight));
|
@include dir.side(margin, 0, var(--sp-tight));
|
||||||
|
|
||||||
@include screen.biggerThan(mobileBreakpoint) {
|
@include screen.biggerThan(mobileBreakpoint) {
|
||||||
display: none;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect, useRef } from "react";
|
||||||
import PropTypes from "prop-types";
|
|
||||||
import "./RoomViewHeader.scss";
|
import "./RoomViewHeader.scss";
|
||||||
|
|
||||||
import { twemojify } from "../../../util/twemojify";
|
import { twemojify } from "../../../util/twemojify";
|
||||||
|
@ -33,16 +32,26 @@ import BackArrowIC from "../../../../public/res/ic/outlined/chevron-left.svg";
|
||||||
|
|
||||||
import { useForceUpdate } from "../../hooks/useForceUpdate";
|
import { useForceUpdate } from "../../hooks/useForceUpdate";
|
||||||
|
|
||||||
function RoomViewHeader({ roomId }) {
|
interface RoomViewHeaderProps {
|
||||||
|
roomId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RoomViewHeader({ roomId }: RoomViewHeaderProps) {
|
||||||
const [, forceUpdate] = useForceUpdate();
|
const [, forceUpdate] = useForceUpdate();
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const isDM = initMatrix.roomList.directs.has(roomId);
|
const isDM = initMatrix.roomList.directs.has(roomId);
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
let avatarSrc = room.getAvatarUrl(mx.baseUrl, 36, 36, "crop");
|
let avatarSrc = room.getAvatarUrl(mx.baseUrl, 36, 36, "crop");
|
||||||
avatarSrc = isDM
|
avatarSrc = isDM
|
||||||
? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 36, 36, "crop")
|
? room
|
||||||
|
.getAvatarFallbackMember()
|
||||||
|
?.getAvatarUrl(mx.baseUrl, 36, 36, "crop", true, false)
|
||||||
: avatarSrc;
|
: avatarSrc;
|
||||||
const roomName = room.name;
|
const { name: roomName, currentState } = room;
|
||||||
|
|
||||||
|
const roomTopic = currentState
|
||||||
|
.getStateEvents("m.room.topic")[0]
|
||||||
|
?.getContent().topic;
|
||||||
|
|
||||||
const roomHeaderBtnRef = useRef(null);
|
const roomHeaderBtnRef = useRef(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -89,61 +98,69 @@ function RoomViewHeader({ roomId }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header>
|
<Header>
|
||||||
<IconButton
|
<div class="room-header__left">
|
||||||
src={BackArrowIC}
|
|
||||||
className="room-header__back-btn"
|
|
||||||
tooltip="Return to navigation"
|
|
||||||
onClick={() => openNavigation()}
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
ref={roomHeaderBtnRef}
|
|
||||||
className="room-header__btn"
|
|
||||||
onClick={() => toggleRoomSettings()}
|
|
||||||
type="button"
|
|
||||||
onMouseUp={(e) => blurOnBubbling(e, ".room-header__btn")}
|
|
||||||
>
|
|
||||||
<Avatar
|
|
||||||
imageSrc={avatarSrc}
|
|
||||||
text={roomName}
|
|
||||||
bgColor={colorMXID(roomId)}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
<TitleWrapper>
|
|
||||||
<Text variant="h2" weight="medium" primary>
|
|
||||||
{twemojify(roomName)}
|
|
||||||
</Text>
|
|
||||||
</TitleWrapper>
|
|
||||||
<RawIcon src={ChevronBottomIC} />
|
|
||||||
</button>
|
|
||||||
{mx.isRoomEncrypted(roomId) === false && (
|
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => toggleRoomSettings(tabText.SEARCH)}
|
src={BackArrowIC}
|
||||||
tooltip="Search"
|
className="room-header__back-btn"
|
||||||
src={SearchIC}
|
tooltip="Return to navigation"
|
||||||
|
onClick={() => openNavigation()}
|
||||||
/>
|
/>
|
||||||
)}
|
<button
|
||||||
<IconButton
|
ref={roomHeaderBtnRef}
|
||||||
className="room-header__drawer-btn"
|
className="room-header__btn"
|
||||||
onClick={togglePeopleDrawer}
|
onClick={() => toggleRoomSettings()}
|
||||||
tooltip="People"
|
type="button"
|
||||||
src={UserIC}
|
onMouseUp={(e) => blurOnBubbling(e, ".room-header__btn")}
|
||||||
/>
|
>
|
||||||
<IconButton
|
<Avatar
|
||||||
className="room-header__members-btn"
|
imageSrc={avatarSrc}
|
||||||
onClick={() => toggleRoomSettings(tabText.MEMBERS)}
|
text={roomName}
|
||||||
tooltip="Members"
|
bgColor={colorMXID(roomId)}
|
||||||
src={UserIC}
|
size="small"
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<TitleWrapper>
|
||||||
onClick={openRoomOptions}
|
<Text variant="h2" weight="medium" primary>
|
||||||
tooltip="Options"
|
{twemojify(roomName)}
|
||||||
src={VerticalMenuIC}
|
</Text>
|
||||||
/>
|
</TitleWrapper>
|
||||||
|
<RawIcon src={ChevronBottomIC} />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div className="room-header__topic">
|
||||||
|
{roomTopic && (
|
||||||
|
<Text variant="b2">{twemojify(roomTopic, undefined, true)}</Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="room-header__right">
|
||||||
|
{mx.isRoomEncrypted(roomId) === false && (
|
||||||
|
<IconButton
|
||||||
|
onClick={() => toggleRoomSettings(tabText.SEARCH)}
|
||||||
|
tooltip="Search"
|
||||||
|
src={SearchIC}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<IconButton
|
||||||
|
className="room-header__drawer-btn"
|
||||||
|
onClick={togglePeopleDrawer}
|
||||||
|
tooltip="People"
|
||||||
|
src={UserIC}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
className="room-header__members-btn"
|
||||||
|
onClick={() => toggleRoomSettings(tabText.MEMBERS)}
|
||||||
|
tooltip="Members"
|
||||||
|
src={UserIC}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
onClick={openRoomOptions}
|
||||||
|
tooltip="Options"
|
||||||
|
src={VerticalMenuIC}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</Header>
|
</Header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
RoomViewHeader.propTypes = {
|
|
||||||
roomId: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RoomViewHeader;
|
export default RoomViewHeader;
|
|
@ -7,7 +7,12 @@
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@": ["src/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist"],
|
"exclude": ["node_modules", "dist"],
|
||||||
"include": ["src"]
|
"include": ["src"]
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||||
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
|
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
|
||||||
import inject from "@rollup/plugin-inject";
|
import inject from "@rollup/plugin-inject";
|
||||||
import { svgLoader } from "./viteSvgLoader";
|
import { svgLoader } from "./viteSvgLoader";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
const copyFiles = {
|
const copyFiles = {
|
||||||
targets: [
|
targets: [
|
||||||
|
@ -35,6 +36,11 @@ export default defineConfig({
|
||||||
port: 8080,
|
port: 8080,
|
||||||
host: true,
|
host: true,
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": path.resolve(__dirname, "./src"),
|
||||||
|
},
|
||||||
|
},
|
||||||
plugins: [viteStaticCopy(copyFiles), svgLoader(), wasm(), react()],
|
plugins: [viteStaticCopy(copyFiles), svgLoader(), wasm(), react()],
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
esbuildOptions: {
|
esbuildOptions: {
|
||||||
|
|
Loading…
Reference in a new issue