1
1
import React from "react" ;
2
2
import styled , { useTheme , css } from "styled-components" ;
3
3
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 } > `
8
5
display: flex;
9
- max-width: 196px;
10
6
align-items: center;
11
7
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
+ ` }
18
16
` ;
19
17
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 } > `
23
19
border-radius: 50%;
24
- background-color: ${ ( { backgroundColor } ) => backgroundColor } ;
25
20
display: flex;
26
21
align-items: center;
27
22
justify-content: center;
23
+ background-color: ${ ( { backgroundColor } ) => backgroundColor } ;
28
24
svg {
29
25
fill: ${ ( { iconColor } ) => iconColor } ;
30
26
}
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
+ ` }
31
41
` ;
32
42
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" ) } ;
37
61
` ;
38
62
39
63
const createPair = ( iconColor : string , backgroundColor : string ) => ( {
@@ -47,9 +71,18 @@ export interface IStatDisplay {
47
71
subtext ?: string | React . ReactNode ;
48
72
icon : React . FunctionComponent < React . SVGAttributes < SVGElement > > ;
49
73
color : "red" | "orange" | "green" | "blue" | "purple" ;
74
+ isSmallDisplay ?: boolean ;
50
75
}
51
76
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
+ } ) => {
53
86
const theme = useTheme ( ) ;
54
87
const COLORS = {
55
88
red : createPair ( theme . error , theme . errorLight ) ,
@@ -60,12 +93,12 @@ const StatDisplay: React.FC<IStatDisplay> = ({ title, text, subtext, icon: Icon,
60
93
} ;
61
94
62
95
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 >
69
102
</ TextContainer >
70
103
</ Container >
71
104
) ;
0 commit comments