Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 1bfb2d2

Browse files
feat: allow summary header to be collapse (#57)
1 parent 44229e2 commit 1bfb2d2

File tree

3 files changed

+102
-30
lines changed

3 files changed

+102
-30
lines changed

web/src/components/UI/atoms/icon.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
FaAngleUp,
66
FaCheckCircle,
77
FaFilter,
8+
FaChevronDown,
9+
FaChevronUp,
810
} from "react-icons/fa";
911
import { FcAndroidOs } from "react-icons/fc";
1012
import {
@@ -182,6 +184,12 @@ export default function Icon(props: IconProps) {
182184
case "minimize":
183185
icon = <FiMinimize />;
184186
break;
187+
case "chevron-up":
188+
icon = <FaChevronUp />;
189+
break;
190+
case "chevron-down":
191+
icon = <FaChevronDown />;
192+
break;
185193
default:
186194
icon = null;
187195
}

web/src/components/UI/organisms/session-details.tsx

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useMemo, useState } from "react";
1+
import React, { useCallback, useState, useMemo, useEffect } from "react";
22
import { useSelector } from "react-redux";
33
import styled from "styled-components";
44
import {
@@ -19,8 +19,47 @@ import Session from "../../../interfaces/session";
1919
import SessionMenuItems from "./session-details-menu-items";
2020
import { Tooltip } from "@mui/material";
2121
import SessionScriptExecutor from "./session-script-executor";
22+
import Icon, { Sizes } from "../atoms/icon";
2223

23-
const Container = styled.div``;
24+
const Container = styled.div`
25+
@-webkit-keyframes progress {
26+
0% {
27+
background-position: 0 0;
28+
}
29+
30+
to {
31+
background-position: 200px 0;
32+
}
33+
}
34+
35+
@keyframes progress {
36+
0% {
37+
background-position: 0 0;
38+
}
39+
40+
to {
41+
background-position: 200px 0;
42+
}
43+
}
44+
45+
@keyframes session-summary-expand {
46+
0% {
47+
bottom: -5px;
48+
}
49+
50% {
50+
bottom: 0px;
51+
}
52+
100% {
53+
bottom: -5px;
54+
}
55+
}
56+
57+
& > * {
58+
.collapsible-row {
59+
transition: height 0.75s ease-out;
60+
}
61+
}
62+
`;
2463

2564
const HEADER = styled.div`
2665
${(props) => getHeaderStyle(props.theme)};
@@ -66,8 +105,29 @@ const PausedProgressIndicator = styled(ProgressIndicator)`
66105
#fff2cc 20px
67106
);
68107
`;
108+
const SummaryContainer = styled.div`
109+
position: relative;
110+
display: flex;
111+
justify-contents: center;
112+
align-items: center;
113+
flex-direction: column;
114+
transition: all 1s;
115+
height: auto;
116+
`;
117+
118+
const SummaryCollapseIcon = styled.div`
119+
position: absolute;
120+
animation: session-summary-expand 1s linear infinite;
121+
cursor: pointer;
69122
70-
export const SUMMARY_HEIGHT = 120;
123+
& > {
124+
.icon {
125+
color: #12bbef;
126+
}
127+
}
128+
`;
129+
130+
export const SUMMARY_HEIGHT = 110;
71131
export const FAIL_MESSAGE_CONTAINER_HEIGHT = 80;
72132
export const PADDING = 10;
73133
export const VIDEO_PLAYER_HEIGHT = 400;
@@ -82,9 +142,12 @@ function hasSessionFailureMessage(session: Session | null) {
82142
);
83143
}
84144

85-
function getSessiobDetailsMainContainerHeight(session: Session | null) {
145+
function getSessiobDetailsMainContainerHeight(
146+
session: Session | null,
147+
hideSummary: boolean,
148+
) {
86149
return (
87-
SUMMARY_HEIGHT +
150+
(hideSummary ? 0 : SUMMARY_HEIGHT) +
88151
APP_HEADER_HEIGHT +
89152
SUB_APP_HEADER_HEIGHT +
90153
PADDING +
@@ -115,9 +178,16 @@ export default function SessionDetails() {
115178
const [paused, setPaused] = useState(session?.is_paused);
116179
const [isDebugging, setIsDebugging] = useState(false);
117180
const [isVideoFullscreen, setIsVideFullScreen] = useState(false);
181+
const [hideSummary, setHideSummary] = useState(false);
182+
183+
const onToggleSummary = useCallback((state) => {
184+
setHideSummary(state);
185+
}, []);
118186

119-
const MAIN_CONTENT_CONTAINER_HEIGHT =
120-
getSessiobDetailsMainContainerHeight(session);
187+
const MAIN_CONTENT_CONTAINER_HEIGHT = getSessiobDetailsMainContainerHeight(
188+
session,
189+
hideSummary,
190+
);
121191

122192
const videoHeight = useMemo(() => {
123193
return isVideoFullscreen && !session?.is_completed
@@ -168,8 +238,22 @@ export default function SessionDetails() {
168238
</ParallelLayout>
169239
</HEADER>
170240
</Row>
171-
<Row height={`${SUMMARY_HEIGHT}px`}>
172-
<SessionSummary session={session} />
241+
<Row
242+
height={`${hideSummary ? 0 : SUMMARY_HEIGHT}px`}
243+
className="collapsible-row"
244+
>
245+
<SummaryContainer>
246+
{!hideSummary && <SessionSummary session={session} />}
247+
<SummaryCollapseIcon className={hideSummary ? "down" : "up"}>
248+
<Icon
249+
name={hideSummary ? "chevron-down" : "chevron-up"}
250+
size={Sizes.XL}
251+
color="#ff4433"
252+
tooltip={hideSummary ? "View Summary" : "Hide Summary"}
253+
onClick={() => onToggleSummary(!hideSummary)}
254+
/>
255+
</SummaryCollapseIcon>
256+
</SummaryContainer>
173257
</Row>
174258
{/* Animated indicator of the session status */}
175259
{(!session.is_completed || session.is_paused) && (

web/src/index.css

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,4 @@ body {
5656

5757
.custom-tooltip-arrow {
5858
color: #000!important;
59-
}
60-
61-
@-webkit-keyframes progress {
62-
0% {
63-
background-position: 0 0
64-
}
65-
66-
to {
67-
background-position: 200px 0
68-
}
69-
}
70-
71-
@keyframes progress {
72-
0% {
73-
background-position: 0 0
74-
}
75-
76-
to {
77-
background-position: 200px 0
78-
}
79-
}
59+
}

0 commit comments

Comments
 (0)