11import React from "react" ;
2- import styled , { css } from "styled-components" ;
32import { Button , Card } from "@kleros/ui-components-library" ;
4- import { landscapeStyle } from "styles/landscapeStyle" ;
53import { useNavigateAndScrollTop } from "hooks/useNavigateAndScrollTop" ;
64import { responsiveSize } from "styles/responsiveSize" ;
75import StatusBanner , { mapFromSubgraphStatus } from "../RegistryCard/StatusBanner" ;
86import ArrowIcon from "svgs/icons/arrow.svg" ;
97import { ItemDetailsFragment } from "src/graphql/graphql" ;
108import ItemField from "./ItemField" ;
9+ import { cn } from "~src/utils" ;
10+ import clsx from "clsx" ;
1111
12- const StyledListItem = styled ( Card ) `
13- display: flex;
14- flex-grow: 1;
15- width: 100%;
16- height: max-content;
17- ${ landscapeStyle (
18- ( ) => css `
19- height: 64px;
20- `
21- ) }
22- ` ;
12+ const landscapeGridColsCalc =
13+ "lg:grid-cols-[1fr_calc(150px+(180-150)*(min(max(100vw,900px),1250px)-900px)/(1250-900))_max-content]" ;
14+ const landscapeGapCalc = "lg:gap-[calc(16px+(36-16)*(min(max(100vw,900px),1250px)-900px)/(1250-900))]" ;
2315
24- const Container = styled . div `
25- width: 100%;
26- height: max-content;
27- align-items: center;
28- display: grid;
29- grid-template-rows: repeat(3, min-content);
30- grid-template-columns: 1fr min-content;
31- column-gap: ${ responsiveSize ( 12 , 32 , 900 ) } ;
32- row-gap: 8px;
33- padding: 16px;
34- ${ landscapeStyle (
35- ( ) => css `
36- height: 64px;
37- justify-content: space-between;
38- grid-template-rows: 1fr;
39- grid-template-columns: 1fr ${ responsiveSize ( 150 , 180 , 900 ) } max-content;
40- padding: 0 32px;
41- `
42- ) }
43- ` ;
44-
45- const StyledButton = styled ( Button ) `
46- background-color: transparent;
47- padding: 0;
48- flex-direction: row-reverse;
49- gap: 8px;
50- .button-text {
51- color: ${ ( { theme } ) => theme . primaryBlue } ;
52- font-weight: 400;
53- }
54-
55- :focus,
56- :hover {
57- background-color: transparent;
58- }
59- ` ;
60-
61- const FieldsContainer = styled . div `
62- display: flex;
63- flex-direction: column;
64- justify-content: space-between;
65- align-items: start;
66- width: fit-content;
67- gap: 16px;
68- grid-column: span 2;
69- ${ landscapeStyle (
70- ( ) => css `
71- flex-direction: row;
72- align-items: center;
73- grid-column: span 1;
74- gap: ${ responsiveSize ( 16 , 36 , 900 ) } ;
75- `
76- ) }
77- ` ;
7816interface IItemCard extends ItemDetailsFragment { }
7917
8018const ItemCard : React . FC < IItemCard > = ( { id, status, disputed, props } ) => {
@@ -84,13 +22,41 @@ const ItemCard: React.FC<IItemCard> = ({ id, status, disputed, props }) => {
8422 const sortedProps = sortItemProps ( props ) ;
8523
8624 return (
87- < StyledListItem hover onClick = { ( ) => navigateAndScrollTop ( `/lists/item/${ id ?. toString ( ) } ` ) } >
88- < Container >
89- < FieldsContainer > { sortedProps . map ( ( prop ) => prop . isIdentifier && < ItemField { ...prop } /> ) } </ FieldsContainer >
25+ < Card
26+ className = "flex grow w-full h-max lg:h-16"
27+ hover
28+ onClick = { ( ) => navigateAndScrollTop ( `/lists/item/${ id ?. toString ( ) } ` ) }
29+ >
30+ < div
31+ className = { cn (
32+ "grid grid-rows-[repeat(3,)min-content] grid-cols-[1fr_min-content]" ,
33+ "w-full h-max p-4 gap-y-2 items-center" ,
34+ "lg:h-16 lg:justify-between lg:grid-rows-[1fr] lg:py-0 lg:px-8" ,
35+ landscapeGridColsCalc
36+ ) }
37+ style = { { columnGap : responsiveSize ( 12 , 32 , 900 ) } }
38+ >
39+ < div
40+ className = { cn (
41+ "flex flex-col justify-between items-start gap-4 w-fit col-span-2" ,
42+ "lg:flex-row lg:items-center lg:col-span-1" ,
43+ landscapeGapCalc
44+ ) }
45+ >
46+ { sortedProps . map ( ( prop ) => prop . isIdentifier && < ItemField { ...prop } /> ) }
47+ </ div >
9048 < StatusBanner { ...{ status : mapFromSubgraphStatus ( status , disputed ) } } isListView />
91- < StyledButton text = "Open" Icon = { ArrowIcon } />
92- </ Container >
93- </ StyledListItem >
49+ < Button
50+ className = { clsx (
51+ "bg-transparent p-0 flex-row-reverse gap-2" ,
52+ "[&_.button-text]:text-klerosUIComponentsPrimaryBlue [&_.button-text]:font-normal" ,
53+ "focus:bg-transparent hover:bg-transparent"
54+ ) }
55+ text = "Open"
56+ Icon = { ArrowIcon }
57+ />
58+ </ div >
59+ </ Card >
9460 ) ;
9561} ;
9662
0 commit comments