UNPKG

@wix/design-system

Version:

@wix/design-system

39 lines 1.92 kB
import React from 'react'; import { st, classes } from './Image.st.css.js'; const placeholder = { source: `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='164' height='120' viewBox='0 0 164 120'%3E%3Cg fill='none'%3E%3Crect width='164' height='120' fill='%23DAEFFE'/%3E%3Cpath fill='%23B9E3FF' d='M-8.52651283e-14,120 L49.0917544,74.9616932 C52.151039,72.1550101 56.848961,72.1550101 59.9082456,74.9616932 L71.293,85.4057534 L96.9019846,59.8591624 C100.0299,56.7386931 105.095216,56.744729 108.215685,59.8726439 C108.284098,59.9412201 108.35126,60.0110332 108.417137,60.0820486 L164,120 L-8.52651283e-14,120 Z'/%3E%3Ccircle cx='67.5' cy='43.5' r='10.5' fill='%23F5FBFF'/%3E%3C/g%3E%3C/svg%3E%0A`, style: { objectFit: 'cover', }, }; const Image = ({ width = '100%', fit = 'cover', position = 'center', showBorder = false, borderRadius, transparent = false, alt = '', ...propsWithNoDefaults }) => { const { dataHook, src, style, className, ...otherProps } = { width, ...propsWithNoDefaults, }; const source = src || placeholder.source; const isTiled = !!src && fit === 'tile'; const imgStyle = !src ? placeholder.style : isTiled ? { backgroundPosition: position, backgroundImage: source ? `url("${source}")` : undefined, } : { objectFit: fit, objectPosition: position, }; return (React.createElement("img", { ...otherProps, className: st(classes.root, { tiled: isTiled, showBorder, transparent, }, className), "data-hook": dataHook, "data-transparent": transparent, src: source, alt: alt, style: { ...style, ...imgStyle, borderRadius, } })); }; Image.displayName = 'Image'; export default Image; //# sourceMappingURL=Image.js.map