11import React from "react" ;
22import styled , { useTheme , css } from "styled-components" ;
33
4- import { landscapeStyle } from "styles/landscapeStyle" ;
5- import { responsiveSize } from "styles/responsiveSize" ;
6-
7- const Container = styled . div `
4+ const Container = styled . div < { isSmallDisplay : boolean } > `
85 display: flex;
9- max-width: 196px;
106 align-items: center;
117 gap: 8px;
12-
13- ${ landscapeStyle (
14- ( ) => css `
15- margin-bottom: ${ responsiveSize ( 16 , 30 ) } ;
16- `
17- ) }
8+ ${ ( { isSmallDisplay } ) =>
9+ isSmallDisplay
10+ ? css `
11+ width: 151px;
12+ `
13+ : css `
14+ max-width: 196px;
15+ ` }
1816` ;
1917
20- const SVGContainer = styled . div < { iconColor : string ; backgroundColor : string } > `
21- height: 48px;
22- width: 48px;
18+ const SVGContainer = styled . div < { iconColor : string ; backgroundColor : string ; isSmallDisplay : boolean } > `
2319 border-radius: 50%;
24- background-color: ${ ( { backgroundColor } ) => backgroundColor } ;
2520 display: flex;
2621 align-items: center;
2722 justify-content: center;
23+ background-color: ${ ( { backgroundColor } ) => backgroundColor } ;
2824 svg {
2925 fill: ${ ( { iconColor } ) => iconColor } ;
3026 }
27+
28+ ${ ( { isSmallDisplay } ) =>
29+ isSmallDisplay
30+ ? css `
31+ height: 32px;
32+ width: 32px;
33+ svg {
34+ height: 20px;
35+ }
36+ `
37+ : css `
38+ height: 48px;
39+ width: 48px;
40+ ` }
3141` ;
3242
33- const TextContainer = styled . div `
34- h1 {
35- margin: 0;
36- }
43+ const TextContainer = styled . div < { isSmallDisplay : boolean } > `
44+ display: flex;
45+ flex-direction: column;
46+ gap: ${ ( { isSmallDisplay } ) => ( isSmallDisplay ? "3px" : "8px" ) } ;
47+ ` ;
48+
49+ const StyledTitle = styled . label `
50+ font-size: 14px;
51+ ` ;
52+
53+ const StyledValue = styled . label < { isSmallDisplay : boolean } > `
54+ font-size: ${ ( { isSmallDisplay } ) => ( isSmallDisplay ? "16px" : "24px" ) } ;
55+ font-weight: 600;
56+ color: ${ ( { theme } ) => theme . primaryText } ;
57+ ` ;
58+
59+ const StyledUSDValue = styled . label < { isSmallDisplay : boolean } > `
60+ font-size: ${ ( { isSmallDisplay } ) => ( isSmallDisplay ? "12px" : "14px" ) } ;
3761` ;
3862
3963const createPair = ( iconColor : string , backgroundColor : string ) => ( {
@@ -47,9 +71,18 @@ export interface IStatDisplay {
4771 subtext ?: string | React . ReactNode ;
4872 icon : React . FunctionComponent < React . SVGAttributes < SVGElement > > ;
4973 color : "red" | "orange" | "green" | "blue" | "purple" ;
74+ isSmallDisplay ?: boolean ;
5075}
5176
52- const StatDisplay : React . FC < IStatDisplay > = ( { title, text, subtext, icon : Icon , color, ...props } ) => {
77+ const StatDisplay : React . FC < IStatDisplay > = ( {
78+ title,
79+ text,
80+ subtext,
81+ icon : Icon ,
82+ color,
83+ isSmallDisplay = false ,
84+ ...props
85+ } ) => {
5386 const theme = useTheme ( ) ;
5487 const COLORS = {
5588 red : createPair ( theme . error , theme . errorLight ) ,
@@ -60,12 +93,12 @@ const StatDisplay: React.FC<IStatDisplay> = ({ title, text, subtext, icon: Icon,
6093 } ;
6194
6295 return (
63- < Container { ...props } >
64- < SVGContainer { ...{ ...COLORS [ color ] } } > { < Icon /> } </ SVGContainer >
65- < TextContainer >
66- < label > { title } </ label >
67- < h1 > { text } </ h1 >
68- < label > { subtext } </ label >
96+ < Container { ...{ isSmallDisplay } } { ... props } >
97+ < SVGContainer { ...{ ...COLORS [ color ] , isSmallDisplay } } > { < Icon /> } </ SVGContainer >
98+ < TextContainer { ... { isSmallDisplay } } >
99+ < StyledTitle > { title } </ StyledTitle >
100+ < StyledValue { ... { isSmallDisplay } } > { text } </ StyledValue >
101+ < StyledUSDValue { ... { isSmallDisplay } } > { subtext } </ StyledUSDValue >
69102 </ TextContainer >
70103 </ Container >
71104 ) ;
0 commit comments