Skip to content

Commit

Permalink
feat: add accordion, style divider
Browse files Browse the repository at this point in the history
  • Loading branch information
kemuru committed Sep 30, 2024
1 parent b82ea0d commit 3171cb2
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 50 deletions.
122 changes: 74 additions & 48 deletions web/src/pages/Courts/CourtDetails/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,28 @@ import { responsiveSize } from "styles/responsiveSize";

import StatDisplay, { IStatDisplay } from "components/StatDisplay";
import { StyledSkeleton } from "components/StyledSkeleton";
// import { useHomePageBlockQuery } from "queries/useHomePageBlockQuery";
import { commify } from "utils/commify";
import { DropdownSelect } from "@kleros/ui-components-library";
import { CustomAccordion, DropdownSelect } from "@kleros/ui-components-library";
import { useHomePageExtraStats } from "queries/useHomePageExtraStats";

const StyledAccordion = styled(CustomAccordion)`
width: 100%;
margin-bottom: 12px;
> * > button {
justify-content: unset;
background-color: ${({ theme }) => theme.whiteBackground} !important;
border: 1px solid ${({ theme }) => theme.stroke} !important;
color: ${({ theme }) => theme.primaryText} !important;
> svg {
fill: ${({ theme }) => theme.primaryText} !important;
}
}
//adds padding to body container
> * > div > div {
padding: 0;
}
`;

function beautifyStatNumber(value: number): string {
const absValue = Math.abs(value);

Expand Down Expand Up @@ -242,52 +259,61 @@ const Stats = () => {
};

return (
<>
<AllTimeContainer>
<StyledChartIcon />
<StyledAllTimeText>All time</StyledAllTimeText>
</AllTimeContainer>
<StyledCard>
{stats.map(({ title, coinId, getText, getSubtext, color, icon }, i) => {
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIds[coinId!]]?.price : undefined;
return (
<StatDisplay
key={i}
{...{ title, color, icon }}
text={data ? getText(data.court) : <StyledSkeleton />}
subtext={calculateSubtextRender(data?.court, getSubtext, coinPrice)}
/>
);
})}
</StyledCard>
<TimeSelectorContainer>
<StyledChartIcon />
<StyledAllTimeText>
<DropdownSelect
smallButton
simpleButton
items={timeRanges.map((range) => ({
value: range.value,
text: range.text,
}))}
defaultValue={selectedRange}
callback={handleTimeRangeChange}
/>
</StyledAllTimeText>
</TimeSelectorContainer>
<StyledCard>
{timeframedStats.map(({ title, getText, getSubtext, color, icon }, i) => {
return (
<StatDisplay
key={i}
{...{ title, color, icon }}
text={foundCourt ? getText(foundCourt) : <StyledSkeleton />}
subtext={calculateSubtextRender(foundCourt, getSubtext)}
/>
);
})}
</StyledCard>
</>
<StyledAccordion
items={[
{
title: "Statistics",
body: (
<>
<AllTimeContainer>
<StyledChartIcon />
<StyledAllTimeText>All time</StyledAllTimeText>
</AllTimeContainer>
<StyledCard>
{stats.map(({ title, coinId, getText, getSubtext, color, icon }, i) => {
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIds[coinId!]]?.price : undefined;
return (
<StatDisplay
key={i}
{...{ title, color, icon }}
text={data ? getText(data.court) : <StyledSkeleton />}
subtext={calculateSubtextRender(data?.court, getSubtext, coinPrice)}
/>
);
})}
</StyledCard>
<TimeSelectorContainer>
<StyledChartIcon />
<StyledAllTimeText>
<DropdownSelect
smallButton
simpleButton
items={timeRanges.map((range) => ({
value: range.value,
text: range.text,
}))}
defaultValue={selectedRange}
callback={handleTimeRangeChange}
/>
</StyledAllTimeText>
</TimeSelectorContainer>
<StyledCard>
{timeframedStats.map(({ title, getText, getSubtext, color, icon }, i) => {
return (
<StatDisplay
key={i}
{...{ title, color, icon }}
text={foundCourt ? getText(foundCourt) : <StyledSkeleton />}
subtext={calculateSubtextRender(foundCourt, getSubtext)}
/>
);
})}
</StyledCard>
</>
),
},
]}
></StyledAccordion>
);
};

Expand Down
12 changes: 10 additions & 2 deletions web/src/pages/Courts/CourtDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ const StyledBreadcrumb = styled(Breadcrumb)`
}
`;

const Divider = styled.hr`
width: 100%;
display: flex;
border: none;
height: 1px;
background-color: ${({ theme }) => theme.stroke};
margin: 0;
`;

const CourtDetails: React.FC = () => {
const { id } = useParams();
const { data: policy } = useCourtPolicy(id);
Expand Down Expand Up @@ -110,9 +119,8 @@ const CourtDetails: React.FC = () => {
{!isProductionDeployment() && <ClaimPnkButton />}
</ButtonContainer>
</CourtHeader>
<hr />
<Stats />
<hr />
<Divider />
<StakePanel id={!isUndefined(id) ? id : ""} courtName={policy?.name} />
</StyledCard>
<StyledCard>
Expand Down

0 comments on commit 3171cb2

Please sign in to comment.