Skip to content

Commit 007a570

Browse files
committed
refactor(web): extract-calc-to-ResponsiveSize-func
1 parent 2912f25 commit 007a570

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+177
-99
lines changed

web/src/components/CasesDisplay/CasesListHeader.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from "react";
22
import styled, { css } from "styled-components";
33
import { landscapeStyle } from "styles/landscapeStyle";
44
import WithHelpTooltip from "components/WithHelpTooltip";
5+
import { responsiveSize } from "styles/responsiveSize";
56

67
const Container = styled.div`
78
display: flex;
89
justify-content: space-between;
9-
gap: calc(15vw + (40 - 15) * ((100vw - 300px) / (1250 - 300)));
10+
${responsiveSize("gap", 15, 40, 300, 1250, "vw")}
1011
width: 100%;
1112
height: 100%;
1213
`;
@@ -16,10 +17,10 @@ const CasesData = styled.div`
1617
align-items: center;
1718
justify-content: space-around;
1819
width: 100%;
19-
margin-left: calc(0px + (33) * (100vw - 370px) / (1250 - 370));
20+
${responsiveSize("marginLeft", 0, 33, 370)}
2021
flex-wrap: wrap;
2122
padding: 0 3%;
22-
gap: calc(24px + (48 - 24) * ((100vw - 300px) / (1250 - 300)));
23+
${responsiveSize("gap", 24, 48, 300)}
2324
`;
2425

2526
const CaseTitle = styled.div`
@@ -42,7 +43,7 @@ const CaseTitle = styled.div`
4243
`;
4344

4445
const StyledLabel = styled.label`
45-
padding-left: calc(4px + (8 - 4) * ((100vw - 300px) / (900 - 300)));
46+
${responsiveSize("marginLeft", 4, 8, 300, 900)}
4647
`;
4748

4849
const tooltipMsg =

web/src/components/CasesDisplay/Search.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Searchbar, DropdownCascader } from "@kleros/ui-components-library";
88
import { rootCourtToItems, useCourtTree } from "queries/useCourtTree";
99
import { isUndefined } from "utils/index";
1010
import { decodeURIFilter, encodeURIFilter, useRootPath } from "utils/uri";
11+
import { responsiveSize } from "styles/responsiveSize";
1112

1213
const Container = styled.div`
1314
display: flex;
@@ -18,7 +19,7 @@ const Container = styled.div`
1819
() =>
1920
css`
2021
flex-direction: row;
21-
gap: calc(4px + (22 - 4) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
22+
${responsiveSize("gap", 4, 22)}
2223
`
2324
)}
2425
`;

web/src/components/CasesDisplay/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import styled from "styled-components";
33
import Search from "./Search";
44
import StatsAndFilters from "./StatsAndFilters";
55
import CasesGrid, { ICasesGrid } from "./CasesGrid";
6+
import { responsiveSize } from "styles/responsiveSize";
67

78
const Divider = styled.hr`
89
display: flex;
910
border: none;
1011
height: 1px;
1112
background-color: ${({ theme }) => theme.stroke};
12-
margin: calc(20px + (24 - 20) * (min(max(100vw, 375px), 1250px) - 375px) / 875) 0;
13+
${responsiveSize("margin", 20, 24)}
1314
`;
1415

1516
const StyledTitle = styled.h1`
16-
margin-bottom: calc(32px + (48 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875) !important;
17+
${responsiveSize("marginBottom", 32, 48)}
1718
`;
1819

1920
interface ICasesDisplay extends ICasesGrid {

web/src/components/DisputeCard/DisputeInfo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import RoundIcon from "svgs/icons/round.svg";
1111
import Field from "../Field";
1212
import { getCourtsPath } from "pages/Courts/CourtDetails";
1313
import { useCourtTree } from "hooks/queries/useCourtTree";
14+
import { responsiveSize } from "styles/responsiveSize";
1415

1516
const Container = styled.div<{ isList: boolean; isOverview?: boolean }>`
1617
display: flex;
@@ -56,7 +57,7 @@ const RestOfFieldsContainer = styled.div<{ isList?: boolean; isOverview?: boolea
5657
${landscapeStyle(
5758
() => css`
5859
flex-direction: row;
59-
gap: calc(4px + (24px - 4px) * ((100vw - 300px) / (900 - 300)));
60+
${responsiveSize("gap", 4, 24, 300, 900)}
6061
justify-content: space-around;
6162
`
6263
)}

web/src/components/DisputeCard/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import DisputeInfo from "./DisputeInfo";
1515
import PeriodBanner from "./PeriodBanner";
1616
import { isUndefined } from "utils/index";
1717
import { getLocalRounds } from "utils/getLocalRounds";
18+
import { responsiveSize } from "styles/responsiveSize";
1819

1920
const StyledCard = styled(Card)`
2021
width: 100%;
21-
height: calc(280px + (296 - 280) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
22+
${responsiveSize("height", 280, 296)}
2223
2324
${landscapeStyle(
2425
() =>
@@ -42,7 +43,7 @@ const StyledListItem = styled(Card)`
4243

4344
const CardContainer = styled.div`
4445
height: calc(100% - 45px);
45-
padding: calc(20px + (24 - 20) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
46+
${responsiveSize("padding", 20, 24)}
4647
display: flex;
4748
flex-direction: column;
4849
justify-content: space-between;
@@ -67,7 +68,7 @@ const ListTitle = styled.div`
6768
height: 100%;
6869
justify-content: start;
6970
align-items: center;
70-
width: calc(30vw + (40 - 30) * ((100vw - 300px) / (1250 - 300)));
71+
${responsiveSize("width", 30, 40, 300, 1250, "vw")}
7172
`;
7273

7374
export const getPeriodEndTimestamp = (

web/src/components/EvidenceCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import AttachmentIcon from "svgs/icons/attachment.svg";
77
import { useIPFSQuery } from "hooks/useIPFSQuery";
88
import { shortenAddress } from "utils/shortenAddress";
99
import { IPFS_GATEWAY } from "consts/index";
10+
import { responsiveSize } from "styles/responsiveSize";
1011

1112
const StyledCard = styled(Card)`
1213
width: 100%;
1314
height: auto;
1415
`;
1516

1617
const TextContainer = styled.div`
17-
padding: calc(8px + (24 - 8) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
18+
${responsiveSize("padding", 8, 24)}
1819
> * {
1920
overflow-wrap: break-word;
2021
margin: 0;
@@ -45,7 +46,7 @@ const BottomShade = styled.div`
4546
const StyledA = styled.a`
4647
display: flex;
4748
margin-left: auto;
48-
gap: calc(5px + (6 - 5) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
49+
${responsiveSize("gap", 5, 6)}
4950
5051
${landscapeStyle(
5152
() => css`

web/src/components/LatestCases.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import { DisputeDetailsFragment, useCasesQuery } from "queries/useCasesQuery";
55
import DisputeCard from "components/DisputeCard";
66
import { SkeletonDisputeCard } from "components/StyledSkeleton";
77
import { isUndefined } from "utils/index";
8+
import { responsiveSize } from "styles/responsiveSize";
89

910
const Container = styled.div`
10-
margin-top: calc(48px + (80 - 48) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
11+
${responsiveSize("marginTop", 48, 80)}
1112
`;
1213

1314
const Title = styled.h1`
14-
margin-bottom: calc(16px + (48 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
15+
${responsiveSize("marginBottom", 16, 48)}
1516
`;
1617

1718
const DisputeContainer = styled.div`

web/src/components/Popup/Description/Appeal.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import styled from "styled-components";
3+
import { responsiveSize } from "styles/responsiveSize";
34

45
const Container = styled.div`
56
display: flex;
@@ -8,17 +9,17 @@ const Container = styled.div`
89

910
const StyledAmountFunded = styled.div`
1011
display: flex;
11-
margin-left: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
12-
margin-right: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
12+
${responsiveSize("marginLeft", 8, 44, 300)}
13+
${responsiveSize("marginRight", 8, 44, 300)}
1314
color: ${({ theme }) => theme.secondaryText};
1415
text-align: center;
1516
`;
1617

1718
const StyledOptionFunded = styled.div`
1819
display: flex;
19-
margin-bottom: calc(16px + (32 - 16) * ((100vw - 300px) / (1250 - 300)));
20-
margin-left: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
21-
margin-right: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
20+
${responsiveSize("marginBottom", 16, 32, 300)}
21+
${responsiveSize("marginLeft", 8, 44, 300)}
22+
${responsiveSize("marginRight", 8, 44, 300)}
2223
color: ${({ theme }) => theme.secondaryText};
2324
text-align: center;
2425
`;

web/src/components/Popup/Description/StakeWithdraw.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useAccount } from "wagmi";
55
import { isUndefined } from "utils/index";
66
import { useKlerosCoreGetJurorBalance } from "hooks/contracts/generated";
77
import KlerosLogo from "tsx:svgs/icons/kleros.svg";
8+
import { responsiveSize } from "styles/responsiveSize";
89

910
const Container = styled.div`
1011
display: flex;
@@ -19,9 +20,9 @@ const StyledKlerosLogo = styled(KlerosLogo)`
1920

2021
const StyledTitle = styled.div`
2122
display: flex;
22-
margin-bottom: calc(16px + (32 - 16) * ((100vw - 300px) / (1250 - 300)));
23-
margin-left: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
24-
margin-right: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
23+
${responsiveSize("marginBottom", 16, 32, 300)}
24+
${responsiveSize("marginLeft", 8, 44, 300)}
25+
${responsiveSize("marginRight", 8, 44, 300)}
2526
color: ${({ theme }) => theme.secondaryText};
2627
text-align: center;
2728
`;
@@ -30,15 +31,15 @@ const AmountStakedOrWithdrawnContainer = styled.div`
3031
font-size: 24px;
3132
font-weight: 600;
3233
color: ${({ theme }) => theme.secondaryPurple};
33-
margin-bottom: calc(0px + (4 - 0) * ((100vw - 300px) / (1250 - 300)));
34+
${responsiveSize("marginBottom", 0, 4, 300)}
3435
`;
3536

3637
const TotalStakeContainer = styled.div`
3738
display: flex;
3839
font-size: 14px;
3940
align-items: center;
4041
justify-content: center;
41-
margin-bottom: calc(8px + (32 - 8) * ((100vw - 300px) / (1250 - 300)));
42+
${responsiveSize("marginBottom", 8, 32, 300)}
4243
`;
4344

4445
const MyStakeContainer = styled.div`

web/src/components/Popup/ExtraInfo/StakeWithdrawExtraInfo.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from "react";
22
import styled from "styled-components";
3+
import { responsiveSize } from "styles/responsiveSize";
34

45
const Container = styled.div`
56
display: flex;
67
color: ${({ theme }) => theme.secondaryText};
78
text-align: center;
8-
margin-left: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
9-
margin-right: calc(8px + (44 - 8) * ((100vw - 300px) / (1250 - 300)));
10-
margin-top: calc(8px + (24 - 8) * ((100vw - 300px) / (1250 - 300)));
9+
${responsiveSize("marginLeft", 8, 44, 300)}
10+
${responsiveSize("marginRight", 8, 44, 300)}
11+
${responsiveSize("marginTop", 8, 24, 300)}
1112
`;
1213

1314
const StakeWithdrawExtraInfo: React.FC = () => {

0 commit comments

Comments
 (0)