MCPcopy Create free account
hub / github.com/code-forge-io/react-router-devtools / Alert

Function Alert

docs/app/ui/alert.tsx:13–72  ·  view source on GitHub ↗
({ children, title, variant, className = "" }: AlertProps)

Source from the content-addressed store, hash-verified

11}
12
13export const Alert = ({ children, title, variant, className = "" }: AlertProps) => {
14 const { t } = useTranslation()
15 const getVariantStyles = () => {
16 switch (variant) {
17 case "info":
18 return {
19 container: "bg-[var(--color-info-bg)] border-[var(--color-info-border)] border-l-4",
20 title: "text-[var(--color-info-text)]",
21 content: "text-[var(--color-info-text)]",
22 icon: "text-[var(--color-info-icon)]",
23 }
24 case "warning":
25 return {
26 container: "bg-[var(--color-warning-bg)] border-[var(--color-warning-border)] border-l-4",
27 title: "text-[var(--color-warning-text)]",
28 content: "text-[var(--color-warning-text)]",
29 icon: "text-[var(--color-warning-icon)]",
30 }
31 default:
32 return {
33 container: "",
34 title: "",
35 content: "",
36 icon: "",
37 }
38 }
39 }
40
41 const getIcon = () => {
42 switch (variant) {
43 case "info":
44 return <Icon name="Info" className="size-6" />
45 case "warning":
46 return <Icon name="TriangleAlert" className="size-6" />
47 default:
48 return null
49 }
50 }
51
52 const styles = getVariantStyles()
53 const defaultTitle = variant === "info" ? t("titles.good_to_know") : t("titles.warning")
54
55 return (
56 <div className={cn("my-6 flex flex-col gap-2 rounded-xl border p-4 md:p-6", styles.container, className)}>
57 <div className="inline-flex items-center gap-2">
58 <div className={cn("inline-flex", styles.icon)}>{getIcon()}</div>
59 <p className={cn("mt-0 mb-0 font-semibold text-sm leading-6 sm:text-base md:text-lg", styles.title)}>{title || defaultTitle}</p>
60 </div>
61
62 <div
63 className={cn(
64 "prose prose-xs sm:prose-sm md:prose-base max-w-none text-sm sm:text-base md:text-lg leading-6 md:leading-7 xl:leading-8",
65 styles.content
66 )}
67 >
68 {children}
69 </div>
70 </div>

Callers

nothing calls this directly

Calls 4

cnFunction · 0.90
getVariantStylesFunction · 0.85
tFunction · 0.85
getIconFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…