@@ -8,40 +8,48 @@ export function BigNumber(
8
8
target = "_blank" ,
9
9
title,
10
10
format = ",.2~f" ,
11
- trend,
12
- trendFormat = "+.1~%" ,
13
- trendColor = trend == null ? "" : trend > 0 ? "green" : trend < 0 ? "red" : "orange" ,
14
- trendArrow = trend == null ? "" : trend > 0 ? "↗︎" : trend < 0 ? "↘︎" : "→" ,
15
- trendTitle,
16
- plot
11
+ secondary,
12
+ secondaryFormat = format ,
13
+ secondaryColor = secondary == null
14
+ ? ""
15
+ : secondary > 0
16
+ ? "var(--theme-color-positive)"
17
+ : secondary < 0
18
+ ? "var(--theme-color-negative)"
19
+ : "var(--theme-color-neutral)" ,
20
+ secondaryArrow = secondary == null ? "" : secondary > 0 ? "↗︎" : secondary < 0 ? "↘︎" : "→" ,
21
+ secondaryTitle,
22
+ styles = { display : "flex" , flexDirection : "column" , fontFamily : "var(--sans-serif)" } ,
23
+ children
17
24
} : {
18
25
href ?: string ;
19
26
target ?: string ;
20
27
title ?: string ;
21
28
format ?: string | ( ( x : any ) => string ) ;
22
- trend ?: number ;
23
- trendFormat ?: string | ( ( x : any ) => string ) ;
24
- trendColor ?: string ;
25
- trendArrow ?: string ;
26
- trendTitle ?: string ;
27
- plot ?: Node ;
29
+ secondary ?: number ;
30
+ secondaryFormat ?: string | ( ( x : any ) => string ) ;
31
+ secondaryColor ?: string ;
32
+ secondaryArrow ?: string ;
33
+ secondaryTitle ?: string ;
34
+ styles ?: { [ key : string ] : string } ;
35
+ children ?: Node | Iterable < Node > ;
28
36
} = { }
29
37
) {
30
38
if ( typeof format !== "function" ) format = typeof number === "string" ? String : d3 . format ( format ) ;
31
- if ( typeof trendFormat !== "function" ) trendFormat = d3 . format ( trendFormat ) ;
32
- const div = html `< div style ="display: flex; flex-direction: column; font-family: var(--sans-serif); ">
39
+ if ( typeof secondaryFormat !== "function" ) secondaryFormat = d3 . format ( secondaryFormat ) ;
40
+ const div = html `< div style ="${ styles } ">
33
41
< div style ="text-transform: uppercase; font-size: 12px; "> ${ title } </ div >
34
42
< div style ="display: flex; flex-wrap: wrap; column-gap: 10px; align-items: baseline; ">
35
43
< div style ="font-size: 32px; font-weight: bold; line-height: 1; "> ${ ( format as ( x : any ) => string ) ( number ) } </ div >
36
44
${
37
- trend == null
45
+ secondary == null
38
46
? null
39
- : html `< div style ="font-size: 14px; color: ${ trendColor } ; " ${ { title : trendTitle } } > ${ (
40
- trendFormat as ( x : any ) => string
41
- ) ( trend ) } ${ trendArrow } </ div > `
47
+ : html `< div style ="font-size: 14px; color: ${ secondaryColor } ; " ${ { title : secondaryTitle } } > ${ (
48
+ secondaryFormat as ( x : any ) => string
49
+ ) ( secondary ) } ${ secondaryArrow } </ div > `
42
50
}
43
51
</ div >
44
- ${ plot }
52
+ ${ children }
45
53
</ div > ` ;
46
54
return href == null ? div : html `< a href =${ href } target =${ target } style="color: inherit;"> ${ div } </ a > ` ;
47
55
}
0 commit comments