Skip to content

Commit 56abf81

Browse files
committed
refactor: replace responsiveSize with clamp-based spacing utilities
1 parent 916c565 commit 56abf81

File tree

37 files changed

+75
-152
lines changed

37 files changed

+75
-152
lines changed

web/src/components/InfoCard.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import clsx from "clsx";
12
import React from "react";
2-
import { responsiveSize } from "styles/responsiveSize";
33
import InfoCircle from "svgs/icons/info-circle.svg";
4-
import { cn } from "src/utils";
54

65
interface IInfoCard {
76
msg: string;
@@ -11,12 +10,11 @@ interface IInfoCard {
1110
const InfoCard: React.FC<IInfoCard> = ({ msg, className }) => {
1211
return (
1312
<div
14-
className={cn(
15-
"grid grid-cols-[16px_auto] items-center justify-start",
13+
className={clsx(
14+
"grid grid-cols-[16px_auto] gap-fluid-6-8-300 items-center justify-start",
1615
"text-start text-klerosUIComponentsSecondaryText",
1716
className
1817
)}
19-
style={{ gap: responsiveSize(6, 8, 300) }}
2018
>
2119
<InfoCircle />
2220
{msg}

web/src/components/InformationCards/ItemInformationCard/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Skeleton from "react-loading-skeleton";
44
import AliasDisplay from "components/RegistryInfo/AliasDisplay";
55
import ActionButton from "components/ActionButton";
66
import { mapFromSubgraphStatus } from "components/RegistryCard/StatusBanner";
7-
import { responsiveSize } from "styles/responsiveSize";
87
import { Policies } from "../RegistryInformationCard/Policies";
98
import FieldsDisplay from "./FieldsDisplay";
109
import StatusDisplay from "../StatusDisplay";
@@ -61,10 +60,7 @@ const ItemInformationCard: React.FC<IItemInformationCard> = ({
6160
<StatusDisplay {...{ status, disputed, registryAddress, latestRequestSubmissionTime }} />
6261
</div>
6362
</div>
64-
<hr
65-
className="border-none h-px bg-klerosUIComponentsStroke mx-8"
66-
style={{ marginBlock: responsiveSize(20, 28) }}
67-
/>
63+
<hr className="border-none h-px bg-klerosUIComponentsStroke mx-8 my-fluid-20-28" />
6864
<div className="flex px-8 pb-3 flex-wrap gap-3 justify-between">
6965
{registerer?.id ? (
7066
<div className={aliasContainerStyle}>

web/src/components/InformationCards/RegistryInformationCard/Policies.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from "react";
22

3-
import { responsiveSize } from "styles/responsiveSize";
4-
53
import Skeleton from "react-loading-skeleton";
64

75
import PolicyIcon from "svgs/icons/policy.svg";
@@ -26,14 +24,13 @@ export const Policies: React.FC<IPolicies> = ({ policyURI, isItem }) => {
2624
<div
2725
className={clsx(
2826
"flex flex-col justify-center lg:flex-row lg:justify-between",
29-
"w-full py-6 mt-4 bg-klerosUIComponentsMediumBlue leading-6"
27+
"w-full py-6 px-fluid-24-32 mt-4 bg-klerosUIComponentsMediumBlue leading-6"
3028
)}
31-
style={{ paddingInline: responsiveSize(24, 32) }}
3229
>
3330
<p className="text-sm leading-6 text-klerosUIComponentsPrimaryBlue mb-4 lg:mb-0">
3431
Make sure you read and understand the Policies
3532
</p>
36-
<div className="flex flex-wrap" style={{ gap: responsiveSize(16, 24) }}>
33+
<div className="flex flex-wrap gap-fluid-16-24">
3734
{!isItem ? (
3835
<>
3936
{parentRegistryDetails ? (

web/src/components/InformationCards/RegistryInformationCard/TopInfo.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Skeleton from "react-loading-skeleton";
44
import { RegistryDetails } from "context/RegistryDetailsContext";
55
import StatusDisplay from "../StatusDisplay";
66
import { DEFAULT_CHAIN, SUPPORTED_CHAINS } from "src/consts/chains";
7-
import { responsiveSize } from "src/styles/responsiveSize";
87
import { isUndefined } from "src/utils";
98
import { DEFAULT_LIST_LOGO } from "src/consts";
109
import { getIpfsUrl } from "utils/getIpfsUrl";
@@ -33,11 +32,8 @@ const TopInfo: React.FC<ITopInfo> = ({
3332
const [imageSrc, setImageSrc] = useState(getIpfsUrl(logoURI ?? ""));
3433
useEffect(() => setImageSrc(getIpfsUrl(logoURI ?? "")), [logoURI]);
3534
return (
36-
<div
37-
className="flex flex-wrap justify-between gap-3 lg:flex-nowrap pb-3"
38-
style={{ paddingTop: responsiveSize(20, 24), paddingInline: responsiveSize(24, 32) }}
39-
>
40-
<div className="flex flex-col" style={{ rowGap: responsiveSize(8, 16) }}>
35+
<div className="flex flex-wrap justify-between gap-3 lg:flex-nowrap pb-3 pt-fluid-20-24 px-fluid-24-32">
36+
<div className="flex flex-col gap-y-fluid-8-16">
4137
<div className="flex flex-wrap items-center gap-4">
4238
{isUndefined(logoURI) ? (
4339
<Skeleton width={125} height={125} borderRadius="62.5px" className="mb-2" />

web/src/components/InformationCards/RegistryInformationCard/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import { responsiveSize } from "styles/responsiveSize";
32
import { Card, Copiable } from "@kleros/ui-components-library";
43
import AliasDisplay from "components/RegistryInfo/AliasDisplay";
54
import { mapFromSubgraphStatus } from "components/RegistryCard/StatusBanner";
@@ -71,11 +70,8 @@ const RegistryInformationCard: React.FC<IInformationCard> = ({
7170
registryAddress: parentRegistryAddress,
7271
}}
7372
/>
74-
<hr
75-
className="border-none h-px bg-klerosUIComponentsStroke"
76-
style={{ marginBlock: responsiveSize(20, 28), marginInline: responsiveSize(24, 32) }}
77-
/>
78-
<div className="flex flex-wrap justify-between gap-5 pb-3" style={{ paddingInline: responsiveSize(24, 32) }}>
73+
<hr className="border-none h-px bg-klerosUIComponentsStroke my-fluid-20-28 mx-fluid-24-32" />
74+
<div className="flex flex-wrap justify-between gap-5 pb-3 px-fluid-24-32">
7975
<div className="flex flex-wrap gap-2 items-center leading-18px">
8076
<small className="text-sm font-semibold leading-18px text-klerosUIComponentsPrimaryText">Submitted by:</small>
8177
<Copiable copiableContent={registerer?.id ?? ""} tooltipProps={{ small: true }}>

web/src/components/ItemCard/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import { Button, Card } from "@kleros/ui-components-library";
33
import { useNavigateAndScrollTop } from "hooks/useNavigateAndScrollTop";
4-
import { responsiveSize } from "styles/responsiveSize";
54
import StatusBanner, { mapFromSubgraphStatus } from "../RegistryCard/StatusBanner";
65
import ArrowIcon from "svgs/icons/arrow.svg";
76
import { ItemDetailsFragment } from "src/graphql/graphql";
@@ -27,11 +26,10 @@ const ItemCard: React.FC<IItemCard> = ({ id, status, disputed, props }) => {
2726
<div
2827
className={clsx(
2928
"grid grid-rows-[repeat(3,min-content)] grid-cols-[1fr_min-content]",
30-
"w-full h-max p-4 gap-y-2 items-center",
29+
"w-full h-max p-4 gap-y-2 gap-x-fluid-12-32-900 items-center",
3130
"lg:h-16 lg:justify-between lg:grid-rows-[1fr] lg:py-0 lg:px-8",
3231
landscapeGridColsCalc
3332
)}
34-
style={{ columnGap: responsiveSize(12, 32, 900) }}
3533
>
3634
<div
3735
className={clsx(

web/src/components/RegistryCard/RegistryInfo.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useEffect, useState } from "react";
2-
import { responsiveSize } from "styles/responsiveSize";
32
import Skeleton from "react-loading-skeleton";
43
import { Button } from "@kleros/ui-components-library";
54
import ArrowIcon from "svgs/icons/arrow.svg";
@@ -35,15 +34,14 @@ const ListInfo: React.FC<IListInfo> = ({ title, totalItems, logoURI, status, isL
3534
className={cn(
3635
"flex flex-col justify-center items-center gap-2 h-[calc(100%-45px)]",
3736
isListView && [
38-
"grid grid-cols-[21px_max-content_1fr_max-content] grid-rows-[repeat(3,min-content)] gap-y-4",
37+
"grid grid-cols-[21px_max-content_1fr_max-content] grid-rows-[repeat(3,min-content)] gap-y-4 gap-x-fluid-8-24-900",
3938
"w-full h-max lg:h-16 p-4",
4039
"[&_img]:col-span-4",
4140
"lg:justify-between lg:grid-rows-[1fr] lg:px-8 lg:py-0",
4241
"lg:[&_img]:col-span-1",
4342
landscapeGridColsCalc,
4443
]
4544
)}
46-
style={{ columnGap: isListView ? responsiveSize(8, 24, 900) : undefined }}
4745
>
4846
{!imageLoaded ? (
4947
<Skeleton

web/src/components/StyledSkeleton.tsx

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

54
export const HistorySkeletonCard = () => (
65
<div className="flex flex-col gap-2">
@@ -11,17 +10,13 @@ export const HistorySkeletonCard = () => (
1110
</div>
1211
);
1312

14-
export const SkeletonRegistryCard = () => (
15-
<div className="w-full">
16-
<Skeleton height={responsiveSize(270, 296)} />
17-
</div>
18-
);
13+
export const SkeletonRegistryCard = () => <Skeleton className="w-full h-fluid-270-296" />;
1914

2015
export const SkeletonJustificationCard = () => (
2116
<div className="flex flex-col gap-4 w-full">
22-
<Skeleton className="ml-auto" height={24} width={responsiveSize(100, 160)} />
17+
<Skeleton className="ml-auto w-fluid-100-160" height={24} />
2318
<Skeleton height={60} />
24-
<Skeleton height={24} width={responsiveSize(60, 80)} />
19+
<Skeleton className="w-fluid-60-80" height={24} />
2520
</div>
2621
);
2722

web/src/global.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,43 @@
3838
* Default max screen width is 1250px
3939
* Default min screen width is 375px
4040
*/
41+
--spacing-fluid-0-16: clamp(0px, calc(0px + (16 - 0) * (100vw - 375px) / (1250 - 375)), 16px);
42+
--spacing-fluid-0-108: clamp(0px, calc(0px + (108 - 0) * (100vw - 375px) / (1250 - 375)), 108px);
4143
--spacing-fluid-0-132: clamp(0px, calc(0px + (132 - 0) * (100vw - 375px) / (1250 - 375)), 132px);
44+
--spacing-fluid-4-8: clamp(4px, calc(4px + (8 - 4) * (100vw - 375px) / (1250 - 375)), 8px);
45+
--spacing-fluid-6-8-300: clamp(6px, calc(6px + (8 - 6) * (100vw - 300px) / (1250 - 300)), 8px);
46+
--spacing-fluid-8-16: clamp(8px, calc(8px + (16 - 8) * (100vw - 375px) / (1250 - 375)), 16px);
47+
--spacing-fluid-8-24: clamp(8px, calc(8px + (24 - 8) * (100vw - 375px) / (1250 - 375)), 24px);
48+
--spacing-fluid-8-24-900: clamp(8px, calc(8px + (24 - 8) * (100vw - 900px) / (1250 - 900)), 24px);
4249
--spacing-fluid-8-32-300: clamp(8px, calc(8px + (32 - 8) * (100vw - 300px) / (1250 - 300)), 32px);
50+
--spacing-fluid-10-130: clamp(10px, calc(10px + (130 - 10) * (100vw - 375px) / (1250 - 375)), 130px);
51+
--spacing-fluid-12-32-300: clamp(12px, calc(12px + (32 - 12) * (100vw - 300px) / (1250 - 300)), 32px);
52+
--spacing-fluid-12-32-900: clamp(12px, calc(12px + (32 - 12) * (100vw - 900px) / (1250 - 900)), 32px);
53+
--spacing-fluid-16-24: clamp(16px, calc(16px + (24 - 16) * (100vw - 375px) / (1250 - 375)), 24px);
4354
--spacing-fluid-16-30: clamp(16px, calc(16px + (30 - 16) * (100vw - 375px) / (1250 - 375)), 30px);
4455
--spacing-fluid-16-36-900: clamp(16px, calc(16px + (36 - 16) * (100vw - 900px) / (1250 - 900)), 36px);
4556
--spacing-fluid-16-54: clamp(16px, calc(16px + (54 - 16) * (100vw - 375px) / (1250 - 375)), 54px);
57+
--spacing-fluid-20-24: clamp(20px, calc(20px + (24 - 20) * (100vw - 375px) / (1250 - 375)), 24px);
58+
--spacing-fluid-20-28: clamp(20px, calc(20px + (28 - 20) * (100vw - 375px) / (1250 - 375)), 28px);
59+
--spacing-fluid-24-28: clamp(24px, calc(24px + (28 - 24) * (100vw - 375px) / (1250 - 375)), 28px);
4660
--spacing-fluid-24-32: clamp(24px, calc(24px + (32 - 24) * (100vw - 375px) / (1250 - 375)), 32px);
61+
--spacing-fluid-24-48: clamp(24px, calc(24px + (48 - 24) * (100vw - 375px) / (1250 - 375)), 48px);
4762
--spacing-fluid-24-32-900: clamp(24px, calc(24px + (32 - 24) * (100vw - 900px) / (1250 - 900)), 32px);
4863
--spacing-fluid-24-136: clamp(24px, calc(24px + (136 - 24) * (100vw - 375px) / (1250 - 375)), 136px);
4964
--spacing-fluid-25-65: clamp(25px, calc(25px + (65 - 25) * (100vw - 375px) / (1250 - 375)), 65px);
65+
--spacing-fluid-32-24: clamp(24px, calc(32px + (24 - 32) * (100vw - 375px) / (1250 - 375)), 32px);
5066
--spacing-fluid-32-80: clamp(32px, calc(32px + (80 - 32) * (100vw - 375px) / (1250 - 375)), 80px);
67+
--spacing-fluid-60-80: clamp(60px, calc(60px + (80 - 60) * (100vw - 375px) / (1250 - 375)), 80px);
68+
--spacing-fluid-68-40: clamp(40px, calc(68px + (40 - 68) * (100vw - 375px) / (1250 - 375)), 68px);
5169
--spacing-fluid-76-96: clamp(76px, calc(76px + (96 - 76) * (100vw - 375px) / (1250 - 375)), 96px);
5270
--spacing-fluid-80-100-900: clamp(80px, calc(80px + (100 - 80) * (100vw - 900px) / (1250 - 900)), 100px);
71+
--spacing-fluid-100-130: clamp(100px, calc(100px + (130 - 100) * (100vw - 375px) / (1250 - 375)), 130px);
5372
--spacing-fluid-100-150-900: clamp(100px, calc(100px + (150 - 100) * (100vw - 900px) / (1250 - 900)), 150px);
73+
--spacing-fluid-100-160: clamp(100px, calc(100px + (160 - 100) * (100vw - 375px) / (1250 - 375)), 160px);
5474
--spacing-fluid-150-72: clamp(72px, calc(150px + (72 - 150) * (100vw - 375px) / (1250 - 375)), 150px);
5575
--spacing-fluid-150-180-900: clamp(150px, calc(150px + (180 - 150) * (100vw - 900px) / (1250 - 900)), 180px);
5676
--spacing-fluid-200-720: clamp(200px, calc(200px + (720 - 200) * (100vw - 375px) / (1250 - 375)), 720px);
77+
--spacing-fluid-270-296: clamp(270px, calc(270px + (296 - 270) * (100vw - 375px) / (1250 - 375)), 296px);
5778
--spacing-fluid-300-480: clamp(300px, calc(300px + (480 - 300) * (100vw - 375px) / (1250 - 375)), 480px);
5879
--spacing-fluid-300-424-300: clamp(300px, calc(300px + (424 - 300) * (100vw - 300px) / (1250 - 300)), 424px);
5980
--spacing-fluid-342-618: clamp(342px, calc(342px + (618 - 342) * (100vw - 375px) / (1250 - 375)), 618px);

web/src/layout/Header/DesktopHeader.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import KlerosSolutionsIcon from "svgs/menu-icons/kleros-solutions.svg";
88
import { DEFAULT_CHAIN } from "consts/chains";
99
import { useLockOverlayScroll } from "hooks/useLockOverlayScroll";
1010

11-
import { responsiveSize } from "styles/responsiveSize";
12-
1311
import ConnectWallet from "components/ConnectWallet";
1412
import LightButton from "components/LightButton";
1513
import OverlayPortal from "components/OverlayPortal";
@@ -44,7 +42,7 @@ const DesktopHeader: React.FC = () => {
4442
<Explore />
4543
</div>
4644

47-
<div className="flex ml-2 [&_canvas]:w-5" style={{ gap: responsiveSize(4, 8) }}>
45+
<div className="flex gap-fluid-4-8 ml-2 [&_canvas]:w-5">
4846
<div
4947
className="[&_label]:cursor-pointer [&_label]:text-white/80"
5048
onClick={isConnected && isDefaultChain ? toggleIsSettingsOpen : undefined}

0 commit comments

Comments
 (0)