Skip to content

Commit 837797a

Browse files
committed
feat: make court branch look good in mobile, redirect to its corresponding court when clicking on it
1 parent 15497de commit 837797a

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

web/src/components/DisputeView/DisputeInfo/DisputeInfoCard.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React, { useMemo } from "react";
22
import styled, { css } from "styled-components";
33

4+
import { Link } from "react-router-dom";
5+
46
import LawBalanceIcon from "svgs/icons/law-balance.svg";
57

8+
import { useScrollTop } from "hooks/useScrollTop";
69
import { useCourtTree } from "hooks/queries/useCourtTree";
710

811
import { landscapeStyle } from "styles/landscapeStyle";
@@ -12,7 +15,7 @@ import { getCourtsPath } from "pages/Courts/CourtDetails";
1215

1316
import CardLabel from "../CardLabels";
1417

15-
import { FieldItem, IDisputeInfo } from ".";
18+
import { FieldItem, IDisputeInfo } from "./index";
1619

1720
const Container = styled.div`
1821
display: flex;
@@ -59,6 +62,19 @@ const StyledField = styled(Field)`
5962
margin-left: 8px;
6063
overflow: hidden;
6164
text-overflow: ellipsis;
65+
text-wrap: auto;
66+
}
67+
}
68+
`;
69+
70+
const StyledLink = styled(Link)`
71+
:hover {
72+
label {
73+
&.value {
74+
cursor: pointer;
75+
color: ${({ theme }) => theme.primaryBlue};
76+
text-decoration: underline;
77+
}
6278
}
6379
}
6480
`;
@@ -74,6 +90,7 @@ const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({
7490
disputeID,
7591
round,
7692
}) => {
93+
const scrollTop = useScrollTop();
7794
const { data } = useCourtTree();
7895
const courtPath = getCourtsPath(data?.court, courtId);
7996
const items = useMemo(
@@ -86,7 +103,9 @@ const DisputeInfoCard: React.FC<IDisputeInfoCard> = ({
86103
<Container>
87104
{court && courtId && isOverview && (
88105
<CourtBranchFieldContainer>
89-
<StyledField icon={LawBalanceIcon} name="Court Branch" value={courtBranchValue} {...{ isOverview }} />
106+
<StyledLink to={`/courts/${courtId}`} onClick={() => scrollTop()}>
107+
<StyledField icon={LawBalanceIcon} name="Court Branch" value={courtBranchValue} {...{ isOverview }} />
108+
</StyledLink>
90109
</CourtBranchFieldContainer>
91110
)}
92111
<RestOfFieldsContainer {...{ isOverview }}>

web/src/hooks/useScrollTop.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useContext } from "react";
2+
import { OverlayScrollContext } from "context/OverlayScrollContext";
3+
4+
export const useScrollTop = () => {
5+
const osInstanceRef = useContext(OverlayScrollContext);
6+
7+
const scrollTop = () => {
8+
osInstanceRef?.current?.osInstance().elements().viewport.scroll({ top: 0 });
9+
};
10+
11+
return scrollTop;
12+
};

0 commit comments

Comments
 (0)