diff --git a/web/src/hooks/useNavigateAndScrollTop.ts b/web/src/hooks/useNavigateAndScrollTop.ts new file mode 100644 index 000000000..0929bfa5b --- /dev/null +++ b/web/src/hooks/useNavigateAndScrollTop.ts @@ -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; +}; diff --git a/web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx b/web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx index b2742f567..6bc7e531c 100644 --- a/web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx +++ b/web/src/pages/Dashboard/Courts/CourtCard/CourtName.tsx @@ -1,13 +1,19 @@ 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; + justify-content: space-between; small { height: 100%; @@ -17,25 +23,46 @@ 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; + } + > .button-svg { + margin-right: 0; + path { + fill: ${({ theme }) => theme.primaryBlue}; + } + } `; interface ICourtName { name: string; + id: string; } -const CourtName: React.FC = ({ name }) => { +const CourtName: React.FC = ({ name, id }) => { + const navigate = useNavigateAndScrollTop(); + return ( - + {name} + navigate(`/courts/${id?.toString()}`)} + text="Open Court" + Icon={ArrowIcon} + className="reverse-button" + /> ); }; diff --git a/web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx b/web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx index de2084617..21b291642 100644 --- a/web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx +++ b/web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx @@ -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-start; + align-items: center; ${landscapeStyle( () => css` - justify-content: flex-end; width: auto; ` )} @@ -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; } @@ -40,7 +49,7 @@ const Stake: React.FC = ({ stake }) => { return ( - + diff --git a/web/src/pages/Dashboard/Courts/CourtCard/index.tsx b/web/src/pages/Dashboard/Courts/CourtCard/index.tsx index 369c2a599..79bc7b82c 100644 --- a/web/src/pages/Dashboard/Courts/CourtCard/index.tsx +++ b/web/src/pages/Dashboard/Courts/CourtCard/index.tsx @@ -15,17 +15,17 @@ const Container = styled(_Card)` justify-content: space-between; height: auto; width: 100%; - padding: 21px 24px 25px 19px; + padding: 21px 20px 25px 20px; border-left: 5px solid ${({ theme }) => theme.secondaryPurple}; flex-wrap: wrap; - gap: 12px; + gap: 20px; ${({ theme }) => (theme.name === "light" ? `box-shadow: 0px 2px 3px 0px ${theme.stroke};` : "")} ${landscapeStyle( () => css` - padding: 21.5px 32px 21.5px 27px; + padding: 21.5px 32px; ` )} `; @@ -33,13 +33,14 @@ const Container = styled(_Card)` interface ICourtCard { name: string; stake: string; + id: string; } -const CourtCard: React.FC = ({ name, stake }) => { +const CourtCard: React.FC = ({ name, stake, id }) => { return ( - - + + ); }; diff --git a/web/src/pages/Dashboard/Courts/index.tsx b/web/src/pages/Dashboard/Courts/index.tsx index 31d3981c8..965185b80 100644 --- a/web/src/pages/Dashboard/Courts/index.tsx +++ b/web/src/pages/Dashboard/Courts/index.tsx @@ -54,7 +54,7 @@ const Courts: React.FC = () => { {stakeData?.jurorTokensPerCourts ?.filter(({ staked }) => staked > 0) .map(({ court: { id, name }, staked }) => ( - + ))} ) : null}