Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions web/src/hooks/useNavigateAndScrollTop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useContext } from "react";
import { useNavigate } from "react-router-dom";
import { OverlayScrollContext } from "context/OverlayScrollContext";

export const useNavigateAndScrollTop = () => {
const navigate = useNavigate();
const osInstanceRef = useContext(OverlayScrollContext);

const navigateAndScrollTop = (path) => {
navigate(path);
osInstanceRef?.current?.osInstance().elements().viewport.scroll({ top: 0 });
};

return navigateAndScrollTop;
};
36 changes: 28 additions & 8 deletions web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React from "react";
import styled, { css } from "styled-components";

import { Breadcrumb } from "@kleros/ui-components-library";

import { landscapeStyle } from "styles/landscapeStyle";
import LightButton from "components/LightButton";

import ArrowIcon from "svgs/icons/arrow.svg";
import { useNavigateAndScrollTop } from "hooks/useNavigateAndScrollTop";

const Container = styled.div`
display: flex;
width: 100%;
justify-content: flex-start;
flex-direction: row;
gap: 16px;
align-items: center;

small {
height: 100%;
Expand All @@ -17,25 +22,40 @@ const Container = styled.div`
${landscapeStyle(
() =>
css`
justify-content: flex-start;
width: auto;
`
)}
`;

const StyledBreadcrumb = styled(Breadcrumb)`
const StyledButton = styled(LightButton)`
display: flex;
align-items: center;
height: 100%;
flex-direction: row-reverse;
gap: 8px;
padding: 0px;
> .button-text {
color: ${({ theme }) => theme.primaryBlue};
font-size: 14px;
}
`;

interface ICourtName {
name: string;
id: string;
}

const CourtName: React.FC<ICourtName> = ({ name }) => {
const CourtName: React.FC<ICourtName> = ({ name, id }) => {
const navigate = useNavigateAndScrollTop();

return (
<Container>
<StyledBreadcrumb items={[{ text: name, value: 0 }]} />
<small>{name}</small>
<StyledButton
onClick={() => navigate(`/courts/${id?.toString()}`)}
text="Open Court"
Icon={ArrowIcon}
className="reverse-button"
/>
</Container>
);
};
Expand Down
15 changes: 12 additions & 3 deletions web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import { landscapeStyle } from "styles/landscapeStyle";

import NumberDisplay from "components/NumberDisplay";

import PnkIcon from "svgs/icons/pnk.svg";

const Container = styled.div`
display: flex;
flex-direction: row;
gap: 16px;
justify-content: space-between;
width: 100%;
justify-content: flex-end;

${landscapeStyle(
() => css`
justify-content: flex-end;
align-items: center;
width: auto;
`
)}
Expand All @@ -31,6 +33,13 @@ const StyledLabel = styled.label`
gap: 4px;
`;

const StyledPnkIcon = styled(PnkIcon)`
display: inline-block;
width: 16px;
height: 16px;
fill: ${({ theme }) => theme.secondaryPurple};
`;

interface IStake {
stake: string;
}
Expand All @@ -40,7 +49,7 @@ const Stake: React.FC<IStake> = ({ stake }) => {

return (
<Container>
<label>Stake</label>
<StyledPnkIcon />
<StyledLabel>
<NumberDisplay value={formattedStake} unit="PNK" />
</StyledLabel>
Expand Down
9 changes: 5 additions & 4 deletions web/src/pages/Dashboard/Courts/CourtCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Container = styled(_Card)`
padding: 21px 24px 25px 19px;
border-left: 5px solid ${({ theme }) => theme.secondaryPurple};
flex-wrap: wrap;
gap: 12px;
gap: 24px;

${({ theme }) => (theme.name === "light" ? `box-shadow: 0px 2px 3px 0px ${theme.stroke};` : "")}

Expand All @@ -33,13 +33,14 @@ const Container = styled(_Card)`
interface ICourtCard {
name: string;
stake: string;
id: string;
}

const CourtCard: React.FC<ICourtCard> = ({ name, stake }) => {
const CourtCard: React.FC<ICourtCard> = ({ name, stake, id }) => {
return (
<Container>
<CourtName name={name} />
<Stake stake={stake} />
<CourtName {...{ name, id }} />
<Stake {...{ stake }} />
</Container>
);
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Dashboard/Courts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Courts: React.FC = () => {
{stakeData?.jurorTokensPerCourts
?.filter(({ staked }) => staked > 0)
.map(({ court: { id, name }, staked }) => (
<CourtCard key={id} name={name ?? ""} stake={staked} />
<CourtCard key={id} name={name ?? ""} stake={staked} {...{ id }} />
))}
</CourtCardsContainer>
) : null}
Expand Down
Loading