Skip to content

Commit fd03903

Browse files
authored
Merge pull request #45 from CS3219-AY2425S1/solomon/minor-styling-changes-matching-buttons-and-avatar-username
Minor styling edits to matching buttons and avatar username
2 parents 0b5e5de + 8ee7843 commit fd03903

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

apps/frontend/src/app/matching/MatchingModal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ const MatchingModal: React.FC<MatchingModalProps> = ({ isOpen, close: _close })
4747
canceledIn={timeoutAfter}
4848
/>;
4949
case "joined":
50-
return <JoinedMatchContent cancel={() => {
50+
return <JoinedMatchContent
51+
cancel={() => {
5152
setClosedType("cancelled");
52-
}}/>;
53+
}}
54+
name1={matchingState.info?.myName || ""}
55+
name2={matchingState.info?.partnerName || ""}
56+
/>;
5357
}
5458
case 'matching':
5559
return <MatchingInProgressContent

apps/frontend/src/app/matching/modalContent/JoinedMatchContent.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ import { formatTime } from '@/utils/DateTime';
1313

1414
interface Props {
1515
cancel(): void
16+
name1: string, // user's username
17+
name2: string, // matched user's username
1618
}
1719

18-
const JoinedMatchContent: React.FC<Props> = ({cancel}) => {
20+
const JoinedMatchContent: React.FC<Props> = ({cancel, name1: me, name2: you}) => {
1921
const matchAlreadyJoined = () => {
2022
throw new Error('Match already joined.');
2123
}
2224

2325
return (
2426
<div className="joined-match-content">
2527
<div className="matched-profiles">
26-
<Avatar size={64} icon={<UserOutlined />} />
28+
<div className="avatar-caption-container">
29+
<Avatar size={64} icon={<UserOutlined />} />
30+
<div className="user-caption">{me}</div>
31+
</div>
2732
<svg xmlns="http://www.w3.org/2000/svg"
2833
height="24px"
2934
viewBox="0 -960 960 960"
@@ -33,7 +38,10 @@ const JoinedMatchContent: React.FC<Props> = ({cancel}) => {
3338
>
3439
<path d="m422-232 207-248H469l29-227-185 267h139l-30 208ZM320-80l40-280H160l360-520h80l-40 320h240L400-80h-80Zm151-390Z"/>
3540
</svg>
36-
<Avatar size={64} icon={<UserOutlined />} />
41+
<div className="avatar-caption-container">
42+
<Avatar size={64} icon={<UserOutlined />} />
43+
<div className="user-caption">{you}</div>
44+
</div>
3745
</div>
3846
<div className="match-status-label">Match Found!</div>
3947
<div className="match-status-message">

apps/frontend/src/app/matching/modalContent/styles.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119

120120
.join-match-button {
121121
background-color: #28A745;
122-
cursor: not-allowed // TODO: remove when collaboration service is implemented
123122
}
124123

125124
.join-match-button:hover {
@@ -228,12 +227,3 @@ button:disabled, .joined-match-deactivated-button {
228227
height: 60px;
229228
fill: #463F3A;
230229
}
231-
232-
.user-caption {
233-
display: flex;
234-
justify-content: center;
235-
}
236-
237-
.avatar-caption-container {
238-
width: 64px;
239-
}

apps/frontend/src/app/matching/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ button:hover {
2828
button:active {
2929
transform: scale(0.95);
3030
}
31+
32+
button:disabled:active {
33+
transform: scale(1);
34+
}

apps/frontend/src/app/services/use-matching.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default function useMatching(): MatchState {
4646
const [isSocket, setIsSocket] = useState<boolean>(false);
4747
const [ste, setSte] = useState<MatchState>({
4848
state: "closed",
49+
info: null,
4950
start,
5051
});
5152

@@ -67,7 +68,14 @@ export default function useMatching(): MatchState {
6768
setSte({
6869
state: "found",
6970
info: info,
70-
ok: cancel
71+
ok: () => {
72+
setIsSocket(false);
73+
setSte({
74+
state: "closed",
75+
info: info,
76+
start,
77+
});
78+
}
7179
})
7280
return;
7381
}
@@ -97,6 +105,7 @@ export default function useMatching(): MatchState {
97105
setIsSocket(false)
98106
setSte({
99107
state: "closed",
108+
info: null,
100109
start,
101110
})
102111
}
@@ -110,7 +119,7 @@ export default function useMatching(): MatchState {
110119
switch (socketState) {
111120
case ReadyState.CLOSED:
112121
case ReadyState.UNINSTANTIATED:
113-
matchState = {state: "closed", start}
122+
matchState = {state: "closed", info: null, start}
114123
break;
115124
case ReadyState.OPEN:
116125
matchState = {state: "matching", cancel, timeout}

apps/frontend/src/contexts/websocketcontext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type SocketState = {
66
state: "cancelling" | "starting"
77
} | {
88
state: "closed";
9+
info: MatchInfo | null;
910
start(req: MatchRequestParams): void;
1011
} | {
1112
state: "matching";

0 commit comments

Comments
 (0)