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 11"use client" ;
22
3+ import {
4+ Confetti ,
5+ DotOutline ,
6+ HardDrives ,
7+ Info ,
8+ WarningCircle ,
9+ XCircle ,
10+ } from "@phosphor-icons/react" ;
311import clsx from "clsx" ;
412import type { ComponentProps , ReactNode } from "react" ;
513
@@ -14,9 +22,44 @@ export const VARIANTS = [
1422 "success" ,
1523] as const ;
1624
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+
1760type Props = ComponentProps < "div" > & {
18- icon : ReactNode ;
19- header : ReactNode ;
61+ icon ? : ReactNode ;
62+ header ? : ReactNode ;
2063 variant ?: ( typeof VARIANTS ) [ number ] | undefined ;
2164} ;
2265
@@ -33,9 +76,9 @@ export const InfoBox = ({
3376 data-variant = { variant }
3477 { ...props }
3578 >
36- < div className = { styles . icon } > { icon } </ div >
79+ < div className = { styles . icon } > { icon ?? DEFAULTS [ variant ] . icon } </ div >
3780 < div className = { styles . body } >
38- < h3 className = { styles . header } > { header } </ h3 >
81+ < h3 className = { styles . header } > { header ?? DEFAULTS [ variant ] . header } </ h3 >
3982 < div className = { styles . contents } > { children } </ div >
4083 </ div >
4184 </ div >
You can’t perform that action at this time.
0 commit comments