diff --git a/web/src/components/CasesDisplay/CasesGrid.tsx b/web/src/components/CasesDisplay/CasesGrid.tsx index 7f465ff1e..ad5d96857 100644 --- a/web/src/components/CasesDisplay/CasesGrid.tsx +++ b/web/src/components/CasesDisplay/CasesGrid.tsx @@ -1,7 +1,7 @@ import React from "react"; import styled, { css } from "styled-components"; import { StandardPagination } from "@kleros/ui-components-library"; -import { smallScreenStyle } from "styles/smallScreenStyle"; +import { tabletScreenStyle } from "styles/tabletScreenStyle"; import { useFiltersContext } from "context/FilterProvider"; import { CasesPageQuery } from "queries/useCasesQuery"; import DisputeCard from "components/DisputeCard"; @@ -9,14 +9,18 @@ import CasesListHeader from "./CasesListHeader"; const GridContainer = styled.div` display: grid; - gap: 16px; - grid-template-columns: repeat(3, minmax(50px, 1fr)); - justify-content: center; + row-gap: 16px; + column-gap: 8px; + grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); + justify-content: space-between; align-items: center; - gap: 8px; - ${smallScreenStyle(css` + justify-items: center; + ${tabletScreenStyle(css` display: flex; flex-wrap: wrap; + justify-content: center; + align-items: center; + gap: 8px; `)} `; const ListContainer = styled.div` diff --git a/web/src/components/CasesDisplay/CasesListHeader.tsx b/web/src/components/CasesDisplay/CasesListHeader.tsx index ac94d34b9..de51a6717 100644 --- a/web/src/components/CasesDisplay/CasesListHeader.tsx +++ b/web/src/components/CasesDisplay/CasesListHeader.tsx @@ -5,14 +5,15 @@ import WithHelpTooltip from "pages/Dashboard/WithHelpTooltip"; const Container = styled.div` display: flex; - flex-direction: row; justify-content: space-between; gap: 40vw; width: 100%; + height: 100%; `; const CasesData = styled.div` display: flex; + flex-wrap: wrap; align-items: center; width: 100%; gap: 48px; diff --git a/web/src/components/DisputeCard/DisputeInfo.tsx b/web/src/components/DisputeCard/DisputeInfo.tsx index 6ea8f9940..bf8b3c88e 100644 --- a/web/src/components/DisputeCard/DisputeInfo.tsx +++ b/web/src/components/DisputeCard/DisputeInfo.tsx @@ -1,5 +1,6 @@ import React from "react"; import styled from "styled-components"; +import { useFiltersContext } from "context/FilterProvider"; import { Periods } from "consts/periods"; import BookmarkIcon from "svgs/icons/bookmark.svg"; import CalendarIcon from "svgs/icons/calendar.svg"; @@ -7,11 +8,11 @@ import LawBalanceIcon from "svgs/icons/law-balance.svg"; import PileCoinsIcon from "svgs/icons/pile-coins.svg"; import Field from "../Field"; -const Container = styled.div<{ isCard: boolean }>` +const Container = styled.div<{ isList: boolean }>` display: flex; - flex-direction: ${({ isCard }) => (isCard ? "column" : "row")}; - gap: ${({ isCard }) => (isCard ? "8px" : "48px")}; - justify-content: ${({ isCard }) => (isCard ? "center" : "space-between")}; + flex-direction: ${({ isList }) => (isList ? "row" : "column")}; + gap: ${({ isList }) => (isList ? "48px" : "8px")}; + justify-content: ${({ isList }) => (isList ? "space-between" : "center")}; align-items: center; width: 100%; height: 100%; @@ -37,7 +38,6 @@ export interface IDisputeInfo { rewards?: string; period?: Periods; date?: number; - isCard?: boolean; } const formatDate = (date: number) => { @@ -47,20 +47,18 @@ const formatDate = (date: number) => { return formattedDate; }; -const DisputeInfo: React.FC = ({ courtId, court, category, rewards, period, date, isCard = true }) => { +const DisputeInfo: React.FC = ({ courtId, court, category, rewards, period, date }) => { + const { isList } = useFiltersContext(); return ( - - {court && courtId && ( - - )} - {category && } - {rewards && } + + {court && courtId && } + {category && } + {rewards && } {typeof period !== "undefined" && date && ( )} diff --git a/web/src/components/DisputeCard/index.tsx b/web/src/components/DisputeCard/index.tsx index 8ecc73562..b1df25e32 100644 --- a/web/src/components/DisputeCard/index.tsx +++ b/web/src/components/DisputeCard/index.tsx @@ -16,7 +16,7 @@ import { isUndefined } from "utils/index"; const StyledCard = styled(Card)` max-width: 380px; min-width: 312px; - width: auto; + width: 380px; height: 260px; `; const StyledListItem = styled(Card)` @@ -111,7 +111,6 @@ const DisputeCard: React.FC = ({

{title}

` width: ${({ width = "100%" }) => width}; @@ -10,7 +11,7 @@ const FieldContainer = styled.div` white-space: nowrap; .value { flex-grow: 1; - text-align: ${({ isCard }) => (isCard ? "end" : "center")}; + text-align: ${({ isList }) => (isList ? "center" : "end")}; color: ${({ theme }) => theme.primaryText}; } svg { @@ -28,7 +29,7 @@ const FieldContainer = styled.div` type FieldContainerProps = { width?: string; - isCard?: boolean; + isList?: boolean; }; interface IField { @@ -37,25 +38,27 @@ interface IField { value: string; link?: string; width?: string; - isCard?: boolean; } -const Field: React.FC = ({ icon: Icon, name, value, link, width, isCard = true }) => ( - - {isCard && ( - <> - - - - )} - {link ? ( - - {value} - - ) : ( - - )} - -); +const Field: React.FC = ({ icon: Icon, name, value, link, width }) => { + const { isList } = useFiltersContext(); + return ( + + {!isList && ( + <> + + + + )} + {link ? ( + + {value} + + ) : ( + + )} + + ); +}; export default Field; diff --git a/web/src/hooks/useWindowWidth.ts b/web/src/hooks/useWindowWidth.ts deleted file mode 100644 index ff74a14ba..000000000 --- a/web/src/hooks/useWindowWidth.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { useState, useEffect } from "react"; - -export const useWindowWidth = () => { - const [windowWidth, setWindowWidth] = useState(window.innerWidth); - - useEffect(() => { - const handleResize = () => { - setWindowWidth(window.innerWidth); - }; - - window.addEventListener("resize", handleResize); - - return () => { - window.removeEventListener("resize", handleResize); - }; - }, []); - - return windowWidth; -}; diff --git a/web/src/pages/Cases/index.tsx b/web/src/pages/Cases/index.tsx index a34ce9a04..ec746e268 100644 --- a/web/src/pages/Cases/index.tsx +++ b/web/src/pages/Cases/index.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react"; import styled from "styled-components"; import { Routes, Route } from "react-router-dom"; import { useCasesQuery } from "queries/useCasesQuery"; -import { useWindowWidth } from "hooks/useWindowWidth"; +import { useWindowSize } from "react-use"; import { BREAKPOINT_TABLET_SCREEN } from "styles/tabletScreenStyle"; import CasesDisplay from "components/CasesDisplay"; import CaseDetails from "./CaseDetails"; @@ -11,14 +11,16 @@ const Container = styled.div` width: 100%; min-height: calc(100vh - 144px); background-color: ${({ theme }) => theme.lightBackground}; - padding: 32px; + padding: calc(32px + (132 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875); + padding-top: calc(32px + (64 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875); + padding-bottom: calc(64px + (96 - 64) * (min(max(100vw, 375px), 1250px) - 375px) / 875); `; const Cases: React.FC = () => { const [currentPage, setCurrentPage] = useState(1); - const windowWidth = useWindowWidth(); + const { width } = useWindowSize(); const { isList, setIsList } = useFiltersContext(); - const screenIsBig = windowWidth > BREAKPOINT_TABLET_SCREEN; + const screenIsBig = width > BREAKPOINT_TABLET_SCREEN; const casesPerPage = screenIsBig ? 9 : 3; const { data } = useCasesQuery(casesPerPage * (currentPage - 1), casesPerPage); diff --git a/web/src/pages/Dashboard/index.tsx b/web/src/pages/Dashboard/index.tsx index aaf615cec..f5d303e4c 100644 --- a/web/src/pages/Dashboard/index.tsx +++ b/web/src/pages/Dashboard/index.tsx @@ -11,7 +11,9 @@ const Container = styled.div` width: 100%; min-height: calc(100vh - 144px); background-color: ${({ theme }) => theme.lightBackground}; - padding: 32px; + padding: calc(32px + (132 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875); + padding-top: calc(32px + (64 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875); + padding-bottom: calc(64px + (96 - 64) * (min(max(100vw, 375px), 1250px) - 375px) / 875); `; const StyledCasesDisplay = styled(CasesDisplay)` diff --git a/web/src/pages/Home/LatestCases.tsx b/web/src/pages/Home/LatestCases.tsx index d3f9028a6..353e8bece 100644 --- a/web/src/pages/Home/LatestCases.tsx +++ b/web/src/pages/Home/LatestCases.tsx @@ -1,6 +1,7 @@ -import React from "react"; +import React, { useEffect } from "react"; import styled from "styled-components"; import { useCasesQuery } from "queries/useCasesQuery"; +import { useFiltersContext } from "context/FilterProvider"; import DisputeCard from "components/DisputeCard"; import { StyledSkeleton } from "components/StyledSkeleton"; @@ -16,6 +17,12 @@ const Container = styled.div` const LatestCases: React.FC = () => { const { data } = useCasesQuery(0); + const { setIsList } = useFiltersContext(); + + useEffect(() => { + setIsList(false); + }, []); + return (

Latest Cases

diff --git a/web/src/styles/tabletScreenStyle.ts b/web/src/styles/tabletScreenStyle.ts index 7b1fe25e7..b047e6603 100644 --- a/web/src/styles/tabletScreenStyle.ts +++ b/web/src/styles/tabletScreenStyle.ts @@ -1,9 +1,9 @@ -import { css, DefaultTheme, FlattenInterpolation, ThemeProps } from "styled-components"; +import { css, FlattenSimpleInterpolation } from "styled-components"; export const BREAKPOINT_TABLET_SCREEN = 1024; -export const tabletScreenStyle = (styleFn: () => FlattenInterpolation>) => css` +export const tabletScreenStyle = (style: FlattenSimpleInterpolation) => css` @media (max-width: ${BREAKPOINT_TABLET_SCREEN}px) { - ${() => styleFn()} + ${style} } `;