|
1
|
import React from "react" |
|
2
|
import clsx from "clsx" |
|
3
|
import { IconProps } from "@medusajs/icons/dist/types" |
|
4
|
import Image from "next/image" |
|
5
|
|
|
6
|
export type BorderedIconProps = { |
|
7
|
icon?: string |
|
8
|
IconComponent?: React.FC<IconProps> | null |
|
9
|
wrapperClassName?: string |
|
10
|
iconWrapperClassName?: string |
|
11
|
iconClassName?: string |
|
12
|
iconColorClassName?: string |
|
13
|
iconWidth?: number |
|
14
|
iconHeight?: number |
|
15
|
} & React.HTMLAttributes<HTMLSpanElement> |
|
16
|
|
|
17
|
export const BorderedIcon = ({ |
|
18
|
icon = "", |
|
19
|
IconComponent = null, |
|
20
|
iconWrapperClassName, |
|
21
|
iconClassName, |
|
22
|
iconColorClassName = "", |
|
23
|
wrapperClassName, |
|
24
|
iconWidth = 28, |
|
25
|
iconHeight = 28, |
|
26
|
...props |
|
27
|
}: BorderedIconProps) => { |
|
28
|
return ( |
|
29
|
<span |
|
30
|
className={clsx( |
|
31
|
"rounded-docs_sm p-docs_0.125 bg-medusa-bg-base inline-flex items-center justify-center", |
|
32
|
"shadow-border-base dark:shadow-border-base-dark", |
|
33
|
iconWrapperClassName |
|
34
|
)} |
|
35
|
{...props} |
|
36
|
> |
|
37
|
<span className={clsx("rounded-docs_xs", wrapperClassName)}> |
|
38
|
{!IconComponent && ( |
|
39
|
<Image |
|
40
|
src={icon || ""} |
|
41
|
className={clsx(iconClassName, "bordered-icon rounded-docs_xs")} |
|
42
|
width={iconWidth} |
|
43
|
height={iconHeight} |
|
44
|
alt="" |
|
45
|
/> |
|
46
|
)} |
|
47
|
{IconComponent && ( |
|
48
|
<IconComponent |
|
49
|
className={clsx( |
|
50
|
"text-medusa-fg-subtle rounded-docs_xs", |
|
51
|
iconClassName, |
|
52
|
"bordered-icon", |
|
53
|
iconColorClassName |
|
54
|
)} |
|
55
|
/> |
|
56
|
)} |
|
57
|
</span> |
|
58
|
</span> |
|
59
|
) |
|
60
|
} |