fix: chat height with css

This commit is contained in:
Alejandro Gomez
2023-06-26 15:28:24 +02:00
parent 8bc4c1e2ce
commit ddbe0e2a92
4 changed files with 26 additions and 39 deletions

View File

@ -11,16 +11,20 @@
gap: 0; gap: 0;
} }
.page.home {
display: grid;
grid-template-areas:
"header"
"video-content";
grid-template-rows: 64px 1fr;
grid-template-columns: 1fr;
}
.live-chat { .live-chat {
max-height: calc(100vh - 385px); max-height: calc(100vh - 385px);
} }
@media (min-width: 768px) { @media (min-width: 768px) {
.info {
display: none;
}
.video-content video { .video-content video {
height: calc(100vh - 64px); height: calc(100vh - 64px);
} }
@ -34,18 +38,15 @@
display: grid; display: grid;
grid-template-areas: grid-template-areas:
"header header" "header header"
"video-content profile"
"video-content chat"; "video-content chat";
grid-template-rows: 64px min-content; grid-template-rows: 64px min-content;
grid-template-columns: calc(min(600px, 1fr)) 1fr; grid-template-columns: minmax(600px, 1fr) min-content;
gap: 0; gap: 0;
} }
} }
@media (min-width: 1020px) { @media (min-width: 1020px) {
.video-content video {
height: unset;
}
.page { .page {
width: unset; width: unset;
display: grid; display: grid;
@ -57,7 +58,7 @@
"header header" "header header"
"video-content chat" "video-content chat"
"profile chat"; "profile chat";
gap: 32px; gap: 0;
} }
} }

View File

@ -6,7 +6,7 @@ import {
encodeTLV, encodeTLV,
NostrPrefix, NostrPrefix,
} from "@snort/system"; } from "@snort/system";
import { Outlet, useNavigate } from "react-router-dom"; import { Outlet, useNavigate, useLocation } from "react-router-dom";
import AsyncButton from "element/async-button"; import AsyncButton from "element/async-button";
import { Login } from "index"; import { Login } from "index";
import { useLogin } from "hooks/login"; import { useLogin } from "hooks/login";
@ -19,6 +19,7 @@ export function LayoutPage() {
const navigate = useNavigate(); const navigate = useNavigate();
const login = useLogin(); const login = useLogin();
const [newStream, setNewStream] = useState(false); const [newStream, setNewStream] = useState(false);
const location = useLocation();
async function doLogin() { async function doLogin() {
const pub = await EventPublisher.nip7(); const pub = await EventPublisher.nip7();
@ -78,7 +79,9 @@ export function LayoutPage() {
} }
return ( return (
<div className="page"> <div
className={location.pathname.startsWith("/live/") ? "page" : "page home"}
>
<header> <header>
<div className="logo" onClick={() => navigate("/")}> <div className="logo" onClick={() => navigate("/")}>
S S

View File

@ -62,6 +62,14 @@
.stream-info { .stream-info {
display: block; display: block;
} }
.video-content video {
height: 100%;
}
.live-chat {
margin-left: 32px;
}
} }
.info { .info {
@ -69,12 +77,6 @@
margin-top: 8px margin-top: 8px
} }
@media (min-width: 1020px) {
.info {
margin-top: 32px;
}
}
.info h1 { .info h1 {
margin: 0 0 8px 0; margin: 0 0 8px 0;
font-weight: 600; font-weight: 600;

View File

@ -1,8 +1,7 @@
import "./stream-page.css"; import "./stream-page.css";
import { useRef, useState, useLayoutEffect } from "react"; import { useRef, useState } from "react";
import { parseNostrLink, EventPublisher } from "@snort/system"; import { parseNostrLink, EventPublisher } from "@snort/system";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import useResizeObserver from "@react-hook/resize-observer";
import moment from "moment"; import moment from "moment";
import useEventFeed from "hooks/event-feed"; import useEventFeed from "hooks/event-feed";
@ -150,31 +149,13 @@ export function StreamPage() {
const ref = useRef(null); const ref = useRef(null);
const params = useParams(); const params = useParams();
const link = parseNostrLink(params.id!); const link = parseNostrLink(params.id!);
const [height, setHeight] = useState<number | undefined>();
function setChatHeight() {
const contentHeight =
document.querySelector(".live-page")?.clientHeight || 0;
const videoContentHeight =
document.querySelector(".video-content")?.clientHeight || 0;
if (window.innerWidth <= 480) {
setHeight(contentHeight - videoContentHeight);
} else if (window.innerWidth <= 768) {
setHeight(videoContentHeight);
} else {
setHeight(undefined);
}
}
useLayoutEffect(setChatHeight, []);
useResizeObserver(ref, () => setChatHeight());
return ( return (
<> <>
<div ref={ref}></div> <div ref={ref}></div>
<VideoPlayer link={link} /> <VideoPlayer link={link} />
<ProfileInfo link={link} /> <ProfileInfo link={link} />
<LiveChat link={link} height={height} /> <LiveChat link={link} />
</> </>
); );
} }