({
dotSize = 1.2,
dotColor = '#fb3a5d',
backgroundColor = 'transparent',
gap = 15,
className,
fade = true,
style,
...props
})
| 11 | } |
| 12 | |
| 13 | export const BackgroundDots: React.FC<DotPatternBackgroundProps> = ({ |
| 14 | dotSize = 1.2, |
| 15 | dotColor = '#fb3a5d', |
| 16 | backgroundColor = 'transparent', |
| 17 | gap = 15, |
| 18 | className, |
| 19 | fade = true, |
| 20 | style, |
| 21 | ...props |
| 22 | }) => { |
| 23 | const encodedDotColor = encodeURIComponent(dotColor) |
| 24 | |
| 25 | const maskStyle: React.CSSProperties = fade |
| 26 | ? { |
| 27 | maskImage: 'radial-gradient(circle, white 10%, transparent 90%)', |
| 28 | WebkitMaskImage: 'radial-gradient(circle, white 10%, transparent 90%)', |
| 29 | } |
| 30 | : {} |
| 31 | |
| 32 | // SVG taken from https://heropatterns.com/ |
| 33 | const backgroundStyle: React.CSSProperties = { |
| 34 | backgroundColor, |
| 35 | backgroundImage: `url("data:image/svg+xml,%3Csvg width='${gap}' height='${gap}' viewBox='0 0 ${gap} ${gap}' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='${encodedDotColor}' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='${dotSize}' cy='${dotSize}' r='${dotSize}'/%3E%3C/g%3E%3C/svg%3E")`, |
| 36 | ...maskStyle, |
| 37 | ...style, |
| 38 | } |
| 39 | |
| 40 | return ( |
| 41 | <div |
| 42 | className={`absolute inset-0 h-full w-full ${className}`} |
| 43 | style={backgroundStyle} |
| 44 | {...props} |
| 45 | /> |
| 46 | ) |
| 47 | } |
| 48 | |
| 49 | export default BackgroundDots |
nothing calls this directly
no outgoing calls
no test coverage detected