({
crossColor = '#fb3a5d',
backgroundColor = 'transparent',
crossSize = 40,
className,
fade = true,
style,
...props
})
| 11 | } |
| 12 | |
| 13 | export const BackgroundCross: React.FC<CrossPatternBackgroundProps> = ({ |
| 14 | crossColor = '#fb3a5d', |
| 15 | backgroundColor = 'transparent', |
| 16 | crossSize = 40, |
| 17 | className, |
| 18 | fade = true, |
| 19 | style, |
| 20 | ...props |
| 21 | }) => { |
| 22 | const encodedCrossColor = encodeURIComponent(crossColor) |
| 23 | |
| 24 | const maskStyle: React.CSSProperties = fade |
| 25 | ? { |
| 26 | maskImage: 'radial-gradient(circle, white 10%, transparent 90%)', |
| 27 | WebkitMaskImage: 'radial-gradient(circle, white 10%, transparent 90%)', |
| 28 | } |
| 29 | : {} |
| 30 | |
| 31 | // SVG taken from https://heropatterns.com/ |
| 32 | const backgroundStyle: React.CSSProperties = { |
| 33 | backgroundColor, |
| 34 | backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${crossSize}' height='${crossSize}' viewBox='0 0 40 40'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='${encodedCrossColor}' fill-opacity='0.4'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`, |
| 35 | ...maskStyle, |
| 36 | ...style, |
| 37 | } |
| 38 | |
| 39 | return ( |
| 40 | <div |
| 41 | className={`absolute inset-0 h-full w-full ${className}`} |
| 42 | style={backgroundStyle} |
| 43 | {...props} |
| 44 | /> |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | export default BackgroundCross |
nothing calls this directly
no outgoing calls
no test coverage detected