Skip to content

Commit 3171cb2

Browse files
committed
feat: add accordion, style divider
1 parent b82ea0d commit 3171cb2

File tree

2 files changed

+84
-50
lines changed

2 files changed

+84
-50
lines changed

web/src/pages/Courts/CourtDetails/Stats.tsx

+74-48
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,28 @@ import { responsiveSize } from "styles/responsiveSize";
2727

2828
import StatDisplay, { IStatDisplay } from "components/StatDisplay";
2929
import { StyledSkeleton } from "components/StyledSkeleton";
30-
// import { useHomePageBlockQuery } from "queries/useHomePageBlockQuery";
3130
import { commify } from "utils/commify";
32-
import { DropdownSelect } from "@kleros/ui-components-library";
31+
import { CustomAccordion, DropdownSelect } from "@kleros/ui-components-library";
3332
import { useHomePageExtraStats } from "queries/useHomePageExtraStats";
3433

34+
const StyledAccordion = styled(CustomAccordion)`
35+
width: 100%;
36+
margin-bottom: 12px;
37+
> * > button {
38+
justify-content: unset;
39+
background-color: ${({ theme }) => theme.whiteBackground} !important;
40+
border: 1px solid ${({ theme }) => theme.stroke} !important;
41+
color: ${({ theme }) => theme.primaryText} !important;
42+
> svg {
43+
fill: ${({ theme }) => theme.primaryText} !important;
44+
}
45+
}
46+
//adds padding to body container
47+
> * > div > div {
48+
padding: 0;
49+
}
50+
`;
51+
3552
function beautifyStatNumber(value: number): string {
3653
const absValue = Math.abs(value);
3754

@@ -242,52 +259,61 @@ const Stats = () => {
242259
};
243260

244261
return (
245-
<>
246-
<AllTimeContainer>
247-
<StyledChartIcon />
248-
<StyledAllTimeText>All time</StyledAllTimeText>
249-
</AllTimeContainer>
250-
<StyledCard>
251-
{stats.map(({ title, coinId, getText, getSubtext, color, icon }, i) => {
252-
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIds[coinId!]]?.price : undefined;
253-
return (
254-
<StatDisplay
255-
key={i}
256-
{...{ title, color, icon }}
257-
text={data ? getText(data.court) : <StyledSkeleton />}
258-
subtext={calculateSubtextRender(data?.court, getSubtext, coinPrice)}
259-
/>
260-
);
261-
})}
262-
</StyledCard>
263-
<TimeSelectorContainer>
264-
<StyledChartIcon />
265-
<StyledAllTimeText>
266-
<DropdownSelect
267-
smallButton
268-
simpleButton
269-
items={timeRanges.map((range) => ({
270-
value: range.value,
271-
text: range.text,
272-
}))}
273-
defaultValue={selectedRange}
274-
callback={handleTimeRangeChange}
275-
/>
276-
</StyledAllTimeText>
277-
</TimeSelectorContainer>
278-
<StyledCard>
279-
{timeframedStats.map(({ title, getText, getSubtext, color, icon }, i) => {
280-
return (
281-
<StatDisplay
282-
key={i}
283-
{...{ title, color, icon }}
284-
text={foundCourt ? getText(foundCourt) : <StyledSkeleton />}
285-
subtext={calculateSubtextRender(foundCourt, getSubtext)}
286-
/>
287-
);
288-
})}
289-
</StyledCard>
290-
</>
262+
<StyledAccordion
263+
items={[
264+
{
265+
title: "Statistics",
266+
body: (
267+
<>
268+
<AllTimeContainer>
269+
<StyledChartIcon />
270+
<StyledAllTimeText>All time</StyledAllTimeText>
271+
</AllTimeContainer>
272+
<StyledCard>
273+
{stats.map(({ title, coinId, getText, getSubtext, color, icon }, i) => {
274+
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIds[coinId!]]?.price : undefined;
275+
return (
276+
<StatDisplay
277+
key={i}
278+
{...{ title, color, icon }}
279+
text={data ? getText(data.court) : <StyledSkeleton />}
280+
subtext={calculateSubtextRender(data?.court, getSubtext, coinPrice)}
281+
/>
282+
);
283+
})}
284+
</StyledCard>
285+
<TimeSelectorContainer>
286+
<StyledChartIcon />
287+
<StyledAllTimeText>
288+
<DropdownSelect
289+
smallButton
290+
simpleButton
291+
items={timeRanges.map((range) => ({
292+
value: range.value,
293+
text: range.text,
294+
}))}
295+
defaultValue={selectedRange}
296+
callback={handleTimeRangeChange}
297+
/>
298+
</StyledAllTimeText>
299+
</TimeSelectorContainer>
300+
<StyledCard>
301+
{timeframedStats.map(({ title, getText, getSubtext, color, icon }, i) => {
302+
return (
303+
<StatDisplay
304+
key={i}
305+
{...{ title, color, icon }}
306+
text={foundCourt ? getText(foundCourt) : <StyledSkeleton />}
307+
subtext={calculateSubtextRender(foundCourt, getSubtext)}
308+
/>
309+
);
310+
})}
311+
</StyledCard>
312+
</>
313+
),
314+
},
315+
]}
316+
></StyledAccordion>
291317
);
292318
};
293319

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ const StyledBreadcrumb = styled(Breadcrumb)`
7777
}
7878
`;
7979

80+
const Divider = styled.hr`
81+
width: 100%;
82+
display: flex;
83+
border: none;
84+
height: 1px;
85+
background-color: ${({ theme }) => theme.stroke};
86+
margin: 0;
87+
`;
88+
8089
const CourtDetails: React.FC = () => {
8190
const { id } = useParams();
8291
const { data: policy } = useCourtPolicy(id);
@@ -110,9 +119,8 @@ const CourtDetails: React.FC = () => {
110119
{!isProductionDeployment() && <ClaimPnkButton />}
111120
</ButtonContainer>
112121
</CourtHeader>
113-
<hr />
114122
<Stats />
115-
<hr />
123+
<Divider />
116124
<StakePanel id={!isUndefined(id) ? id : ""} courtName={policy?.name} />
117125
</StyledCard>
118126
<StyledCard>

0 commit comments

Comments
 (0)