|
1
|
import { clx } from "@/utils/clx" |
|
2
|
import * as React from "react" |
|
3
|
|
|
4
|
interface InlineTipProps extends React.ComponentPropsWithoutRef<"div"> { |
|
5
|
label: string |
|
6
|
variant?: "info" | "warning" | "error" | "success" |
|
7
|
} |
|
8
|
|
|
9
|
/** |
|
10
|
* This component is based on the `div` element and supports all of its props. |
|
11
|
*/ |
|
12
|
export const InlineTip = React.forwardRef<HTMLDivElement, InlineTipProps>( |
|
13
|
( |
|
14
|
{ |
|
15
|
/** |
|
16
|
* The variant of the tip. |
|
17
|
*/ |
|
18
|
variant = "info", |
|
19
|
/** |
|
20
|
* The label to display in the tip. |
|
21
|
*/ |
|
22
|
label, |
|
23
|
className, |
|
24
|
children, |
|
25
|
...props |
|
26
|
}: InlineTipProps, ref) => { |
|
27
|
return ( |
|
28
|
<div |
|
29
|
ref={ref} |
|
30
|
className={clx( |
|
31
|
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3", |
|
32
|
className |
|
33
|
)} |
|
34
|
{...props} |
|
35
|
> |
|
36
|
<div |
|
37
|
role="presentation" |
|
38
|
className={clx("bg-ui-tag-neutral-icon h-full w-1 rounded-full", { |
|
39
|
"bg-ui-tag-orange-icon": variant === "warning", |
|
40
|
"bg-ui-tag-red-icon": variant === "error", |
|
41
|
"bg-ui-tag-green-icon": variant === "success", |
|
42
|
})} |
|
43
|
/> |
|
44
|
<div className="text-pretty"> |
|
45
|
<strong className="txt-small-plus text-ui-fg-base">{label}:</strong>{" "} |
|
46
|
{children} |
|
47
|
</div> |
|
48
|
</div> |
|
49
|
) |
|
50
|
} |
|
51
|
) |
|
52
|
|
|
53
|
InlineTip.displayName = "InlineTip" |