File tree Expand file tree Collapse file tree 1 file changed +47
-4
lines changed
packages/component-library/src/InfoBox Expand file tree Collapse file tree 1 file changed +47
-4
lines changed Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
+ import {
4
+ Confetti ,
5
+ DotOutline ,
6
+ HardDrives ,
7
+ Info ,
8
+ WarningCircle ,
9
+ XCircle ,
10
+ } from "@phosphor-icons/react" ;
3
11
import clsx from "clsx" ;
4
12
import type { ComponentProps , ReactNode } from "react" ;
5
13
@@ -14,9 +22,44 @@ export const VARIANTS = [
14
22
"success" ,
15
23
] as const ;
16
24
25
+ const DEFAULTS : Default = {
26
+ neutral : {
27
+ header : "-" ,
28
+ icon : < DotOutline /> ,
29
+ } ,
30
+ info : {
31
+ header : "Info" ,
32
+ icon : < Info /> ,
33
+ } ,
34
+ warning : {
35
+ header : "Warning" ,
36
+ icon : < WarningCircle /> ,
37
+ } ,
38
+ error : {
39
+ header : "Error" ,
40
+ icon : < XCircle /> ,
41
+ } ,
42
+ data : {
43
+ header : "Data" ,
44
+ icon : < HardDrives /> ,
45
+ } ,
46
+ success : {
47
+ header : "Success" ,
48
+ icon : < Confetti /> ,
49
+ } ,
50
+ } ;
51
+
52
+ type Default = Record <
53
+ ( typeof VARIANTS ) [ number ] ,
54
+ {
55
+ header : string ;
56
+ icon : ReactNode ;
57
+ }
58
+ > ;
59
+
17
60
type Props = ComponentProps < "div" > & {
18
- icon : ReactNode ;
19
- header : ReactNode ;
61
+ icon ? : ReactNode ;
62
+ header ? : ReactNode ;
20
63
variant ?: ( typeof VARIANTS ) [ number ] | undefined ;
21
64
} ;
22
65
@@ -33,9 +76,9 @@ export const InfoBox = ({
33
76
data-variant = { variant }
34
77
{ ...props }
35
78
>
36
- < div className = { styles . icon } > { icon } </ div >
79
+ < div className = { styles . icon } > { icon ?? DEFAULTS [ variant ] . icon } </ div >
37
80
< div className = { styles . body } >
38
- < h3 className = { styles . header } > { header } </ h3 >
81
+ < h3 className = { styles . header } > { header ?? DEFAULTS [ variant ] . header } </ h3 >
39
82
< div className = { styles . contents } > { children } </ div >
40
83
</ div >
41
84
</ div >
You can’t perform that action at this time.
0 commit comments