Skip to content

Commit 94b3a69

Browse files
committedJan 8, 2025··
feat: better styling for dropdown, better wrapping for verdict answer, remove verdict description
1 parent 0aedfbc commit 94b3a69

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed
 

‎web/src/components/Verdict/Answer.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import React from "react";
2-
import styled from "styled-components";
32

43
import { Answer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
54

6-
import { AnswerDescription, AnswerTitle, AnswerTitleAndDescription } from "../DisputePreview/DisputeContext";
7-
8-
const Container = styled.div`
9-
display: flex;
10-
flex-direction: row;
11-
flex-wrap: wrap;
12-
align-items: center;
13-
gap: 6px;
14-
`;
5+
import { AnswerTitle, AnswerTitleAndDescription } from "../DisputePreview/DisputeContext";
156

167
interface IAnswer {
178
answer?: Answer;
@@ -24,12 +15,11 @@ const AnswerDisplay: React.FC<IAnswer> = ({ answer, currentRuling }) => {
2415
{answer ? (
2516
<AnswerTitleAndDescription dir="auto">
2617
<AnswerTitle>{answer.title}</AnswerTitle>
27-
<AnswerDescription>{answer.description.trim() ? ` - ${answer.description}` : null}</AnswerDescription>
2818
</AnswerTitleAndDescription>
2919
) : (
30-
<Container>
20+
<AnswerTitleAndDescription>
3121
{currentRuling !== 0 ? <small>Answer 0x{currentRuling}</small> : <small>Refuse to Arbitrate</small>}
32-
</Container>
22+
</AnswerTitleAndDescription>
3323
)}
3424
</>
3525
);

‎web/src/components/Verdict/FinalDecision.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ const Container = styled.div`
3333

3434
const JuryContainer = styled.div`
3535
display: flex;
36-
flex-direction: row;
37-
flex-wrap: wrap;
3836
align-items: center;
3937
gap: 5px 7px;
40-
flex: 1;
38+
flex-wrap: wrap;
39+
4140
h3 {
4241
line-height: 21px;
4342
margin-bottom: 0px;
4443
}
44+
4545
> div {
4646
flex: 1;
4747
}

‎web/src/pages/Courts/TopSearch.tsx ‎web/src/pages/Courts/CourtDetails/TopSearch.tsx

+42-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useMemo } from "react";
22
import styled, { css } from "styled-components";
33

4-
import { useNavigate } from "react-router-dom";
4+
import { useNavigate, useParams } from "react-router-dom";
55

66
import { Card, DropdownCascader, Searchbar } from "@kleros/ui-components-library";
77

@@ -12,9 +12,10 @@ import { useCourtTree, rootCourtToItems } from "queries/useCourtTree";
1212

1313
import { responsiveSize } from "styles/responsiveSize";
1414
import { landscapeStyle } from "styles/landscapeStyle";
15+
import { hoverShortTransitionTiming } from "styles/commonStyles";
1516

1617
import { StyledSkeleton } from "components/StyledSkeleton";
17-
import StakeMaintenanceButtons from "./StakeMaintenanceButton";
18+
import StakeMaintenanceButtons from "../StakeMaintenanceButton";
1819

1920
const Container = styled.div`
2021
width: 100%;
@@ -57,6 +58,7 @@ const SearchResultsContainer = styled.div`
5758
position: absolute;
5859
margin-top: 45px;
5960
max-height: 400px;
61+
border: 1px solid ${({ theme }) => theme.stroke};
6062
width: 100%;
6163
flex-direction: column;
6264
border-radius: 4px;
@@ -65,29 +67,54 @@ const SearchResultsContainer = styled.div`
6567
background-color: ${({ theme }) => theme.whiteBackground};
6668
`;
6769

68-
const StyledCard = styled(Card)`
70+
const StyledCard = styled(Card)<{ selected: boolean }>`
71+
${hoverShortTransitionTiming}
6972
height: auto;
7073
width: 100%;
71-
padding: 16px;
72-
color: ${({ theme }) => theme.primaryText};
74+
padding: ${({ selected }) => (selected ? "16px 13px" : "16px")};
7375
cursor: pointer;
76+
border: none;
77+
border-left: ${({ selected, theme }) => (selected ? `3px solid ${theme.primaryBlue}` : "none")};
78+
background-color: ${({ selected, theme }) => (selected ? theme.mediumBlue : "transparent")};
79+
80+
:hover {
81+
background-color: ${({ theme }) => theme.mediumBlue};
82+
}
7483
`;
7584

76-
function flattenCourts(court) {
77-
return court ? [court, ...(court.children || []).flatMap(flattenCourts)] : [];
85+
const CourtParentSpan = styled.span`
86+
color: ${({ theme }) => theme.secondaryText}EE;
87+
`;
88+
89+
const CourtNameSpan = styled.span`
90+
color: ${({ theme }) => theme.primaryText};
91+
`;
92+
93+
function flattenCourts(court, parent = null) {
94+
const current = {
95+
...court,
96+
parentName: parent?.name ?? null,
97+
};
98+
const children = (court.children || []).flatMap((child) => flattenCourts(child, current));
99+
return [current, ...children];
78100
}
79101

80102
const TopSearch: React.FC = () => {
81103
const { data } = useCourtTree();
82104
const navigate = useNavigate();
105+
const { id: currentCourtId } = useParams();
83106
const items = useMemo(() => !isUndefined(data) && [rootCourtToItems(data.court)], [data]);
84107
const isUniversity = isKlerosUniversity();
85108
const [search, setSearch] = useState("");
86-
const filteredCourts = useMemo(
87-
() =>
88-
data?.court ? flattenCourts(data.court).filter((c) => c.name.toLowerCase().includes(search.toLowerCase())) : [],
89-
[data, search]
90-
);
109+
110+
const filteredCourts = useMemo(() => {
111+
if (!data?.court) return [];
112+
const courts = flattenCourts(data.court).filter((c) => c.name.toLowerCase().includes(search.toLowerCase()));
113+
const selectedCourt = courts.find((c) => c.id === currentCourtId);
114+
if (!selectedCourt) return courts;
115+
116+
return [selectedCourt, ...courts.filter((c) => c.id !== currentCourtId)];
117+
}, [data, search, currentCourtId]);
91118

92119
return (
93120
<Container>
@@ -110,14 +137,15 @@ const TopSearch: React.FC = () => {
110137
<SearchResultsContainer>
111138
{filteredCourts.map((court) => (
112139
<StyledCard
113-
hover
114140
key={court.id}
141+
selected={court.id === currentCourtId}
115142
onClick={() => {
116143
navigate(`/courts/${court.id}`);
117144
setSearch("");
118145
}}
119146
>
120-
{court.name}
147+
{court.parentName && <CourtParentSpan>{court.parentName} / </CourtParentSpan>}
148+
<CourtNameSpan>{court.name}</CourtNameSpan>
121149
</StyledCard>
122150
))}
123151
</SearchResultsContainer>

‎web/src/pages/Courts/CourtDetails/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Divider } from "components/Divider";
2525
import Description from "./Description";
2626
import StakePanel from "./StakePanel";
2727
import Stats from "./Stats";
28+
import TopSearch from "./TopSearch";
2829

2930
const Container = styled.div``;
3031

@@ -113,6 +114,7 @@ const CourtDetails: React.FC = () => {
113114

114115
return (
115116
<Container>
117+
<TopSearch />
116118
<StyledCard>
117119
<CourtHeader>
118120
<CourtInfo>

‎web/src/pages/Courts/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { responsiveSize } from "styles/responsiveSize";
77
import { Routes, Route, Navigate } from "react-router-dom";
88

99
import CourtDetails from "./CourtDetails";
10-
import TopSearch from "./TopSearch";
1110

1211
const Container = styled.div`
1312
width: 100%;
@@ -26,7 +25,6 @@ const Container = styled.div`
2625
const Courts: React.FC = () => {
2726
return (
2827
<Container>
29-
<TopSearch />
3028
<Routes>
3129
<Route path="/:id/*" element={<CourtDetails />} />
3230
<Route path="*" element={<Navigate to="1" replace />} />

0 commit comments

Comments
 (0)
Please sign in to comment.