1 import { ExclamationCircleSolid } from "@medusajs/icons"
2 import { VariantProps, cva } from "cva"
3 import * as React from "react"
4
5 import { clx } from "@/utils/clx"
6
7 const hintVariants = cva({
8 base: "txt-small",
9 variants: {
10 variant: {
11 info: "text-ui-fg-subtle",
12 error: "text-ui-fg-error grid grid-cols-[20px_1fr] gap-1 items-start",
13 },
14 },
15 defaultVariants: {
16 variant: "info",
17 },
18 })
19
20 interface HintProps
21 extends VariantProps<typeof hintVariants>,
22 React.ComponentPropsWithoutRef<"span"> {}
23
24 const Hint = React.forwardRef<HTMLSpanElement, HintProps>(
25 (
26 {
27 className,
28 /**
29 * The hint's style.
30 */
31 variant = "info",
32 children,
33 ...props
34 }: HintProps,
35 ref
36 ) => {
37 return (
38 <span
39 ref={ref}
40 className={clx(hintVariants({ variant }), className)}
41 {...props}
42 >
43 {variant === "error" && <div className="size-5 flex items-center justify-center"><ExclamationCircleSolid /></div>}
44 {children}
45 </span>
46 )
47 }
48 )
49 Hint.displayName = "Hint"
50
51 export { Hint }