Skip to content

Commit

Permalink
title fix (#235)
Browse files Browse the repository at this point in the history
* title fix

* spinner center

* test fix
  • Loading branch information
aaronshiel authored Oct 15, 2024
1 parent 3b19c0e commit 7b88e89
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
18 changes: 12 additions & 6 deletions client/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The full terms of this copyright and license should always be found in the root
*/
import React from "react";
import { useSelector } from "react-redux";
import { Typography } from "@mui/material";
import { Tooltip, Typography } from "@mui/material";
import { State } from "types";
import IconButton from "@mui/material/IconButton";
import HomeIcon from "@mui/icons-material/Home";
Expand All @@ -20,6 +20,7 @@ import {
REGISTRATION_ID_KEY,
SESSION_URL_PARAM_KEY,
} from "local-constants";
import { useWithWindowSize } from "use-with-window-size";

interface HeaderMentorData {
_id: string;
Expand All @@ -42,7 +43,7 @@ function Header(): JSX.Element {
title: m.mentor.title,
};
});

const { isMobile } = useWithWindowSize();
const styleHeaderLogo = useSelector<State, string>(
(state) => state.config.styleHeaderLogo?.trim() || ""
);
Expand Down Expand Up @@ -79,7 +80,10 @@ function Header(): JSX.Element {
};

const MentorNameTitle = `${mentor.name}: ${mentor.title}`;

const mentorTitleTooLong = isMobile && MentorNameTitle.length > 80;
const displayMentorNameTitle = mentorTitleTooLong
? MentorNameTitle.slice(0, 80).concat("...")
: MentorNameTitle;
return (
<div
data-cy="header"
Expand Down Expand Up @@ -138,9 +142,11 @@ function Header(): JSX.Element {
)}
</div>
</div>
<div className="header-mentor-info">
<Typography>{MentorNameTitle}</Typography>
</div>
<Tooltip title={mentorTitleTooLong ? MentorNameTitle : ""}>
<div className="header-mentor-info">
<Typography>{displayMentorNameTitle}</Typography>
</div>
</Tooltip>
<div>
<Disclaimer />
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/video-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function VideoPanel(): JSX.Element {
key={`${id}-${i}`}
style={{ display: "inline-block", position: "relative" }}
>
<LoadingSpinner mentor={id} />
<div
style={{ position: "absolute", right: 0, top: 5, zIndex: 2 }}
>
Expand All @@ -102,7 +103,6 @@ function VideoPanel(): JSX.Element {
onClick={() => onClick(id)}
>
<VideoThumbnail mentor={id} />
<LoadingSpinner mentor={id} />
<MessageStatus mentor={id} />
</button>
</div>
Expand Down
15 changes: 12 additions & 3 deletions client/src/styles/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ body {

.spinner {
position: absolute;
left: 50%;
bottom: 15px;
transform: translateX(-50%);
top: 25%;
left: 25%;
transform: translate(-50%, -50%);
}

.message-notice {
Expand Down Expand Up @@ -287,6 +287,7 @@ body {
.header-mentor-info > p {
font-size: 1.2rem !important;
}

/* width */
::-webkit-scrollbar {
width: 15px;
Expand Down Expand Up @@ -343,3 +344,11 @@ textarea:-moz-placeholder {
background-color: #fff !important;
border-radius: 0px;
}

@media only screen and (max-width: 800px) {
.header-mentor-info > p {
font-weight: bold;
font-size: 0.8rem !important;
line-height: 1rem !important;
}
}
4 changes: 3 additions & 1 deletion client/src/use-with-window-size.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { useEffect, useState } from "react";
interface WindowSize {
width: number;
height: number;
isMobile: boolean;
}

export function useWithWindowSize(): WindowSize {
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });

const isMobile = windowSize.width < 768;
useEffect(() => {
if (typeof window === "undefined") {
return;
Expand All @@ -30,5 +31,6 @@ export function useWithWindowSize(): WindowSize {
return {
width: windowSize.width,
height: windowSize.height,
isMobile,
};
}
4 changes: 2 additions & 2 deletions cypress/cypress/e2e/panel.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ describe("Mentor panel", () => {
cy.get("[data-cy=input-send]").trigger("mouseover").click();
cy.wait("@carlos-query");
// Despite recieving a response to carlos, we are still waiting for all responses before continuing
cy.get("[data-cy=video-thumbnail-carlos]").within(($within) => {
cy.get("[data-cy=video-thumbnail-container-carlos]").within(($within) => {
cy.get("[data-cy=loading-answer-spinner]").should("exist");
});
cy.get("[data-cy=video-thumbnail-clint]").within(($within) => {
cy.get("[data-cy=video-thumbnail-container-clint]").within(($within) => {
cy.get("[data-cy=loading-answer-spinner]").should("exist");
});
});
Expand Down

0 comments on commit 7b88e89

Please sign in to comment.