@onesy/ui-react
Version:
UI for React
91 lines • 3.51 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
const _excluded = ["tonal", "color", "version", "elevation", "alt", "image", "shape", "marginHorizontal", "Component", "className", "children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { c as _c } from "react/compiler-runtime";
import React from 'react';
import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react';
import { staticClassName } from '../utils';
import { jsx as _jsx } from "react/jsx-runtime";
const useStyle = styleMethod(theme => ({
root: {
display: 'block',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
objectFit: 'cover',
width: '100%',
height: '100%'
},
shape_top: {
borderRadius: `${theme.shape.radius.unit * 3}px ${theme.shape.radius.unit * 3}px 0 0`
},
shape_left: {
borderRadius: `${theme.shape.radius.unit * 3}px 0 0 ${theme.shape.radius.unit * 3}px`
},
shape_right: {
borderRadius: `0 ${theme.shape.radius.unit * 3}px ${theme.shape.radius.unit * 3}px 0`
},
shape_bottom: {
borderRadius: `0 0 ${theme.shape.radius.unit * 3}px ${theme.shape.radius.unit * 3}px`
},
shape_all: {
borderRadius: `${theme.shape.radius.unit * 3}px`
},
shape_none: {
borderRadius: `0`
},
marginHorizontal: {
width: 'calc(100% - 48px)',
margin: '0 24px'
}
}), {
name: 'onesy-CardImage'
});
const CardImage = props_ => {
const $ = _c(6);
const theme = useOnesyTheme();
const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyCardImage?.props?.default), props_);
const {
tonal: t0,
color,
version,
elevation,
alt,
image,
shape: t1,
marginHorizontal,
Component: t2,
className,
children
} = props,
other = _objectWithoutProperties(props, _excluded);
t0 === undefined ? true : t0;
const shape = t1 === undefined ? "bottom" : t1;
const Component = t2 === undefined ? "img" : t2;
const {
classes
} = useStyle();
const t3 = alt || "";
const t4 = classNames([staticClassName("CardImage", theme) && ["onesy-CardImage-root"], className, classes.root, classes[`shape_${shape}`], marginHorizontal && classes.marginHorizontal]);
let t5;
if ($[0] !== Component || $[1] !== image || $[2] !== other || $[3] !== t3 || $[4] !== t4) {
t5 = /*#__PURE__*/_jsx(Component, _objectSpread({
alt: t3,
src: image,
className: t4
}, other));
$[0] = Component;
$[1] = image;
$[2] = other;
$[3] = t3;
$[4] = t4;
$[5] = t5;
} else {
t5 = $[5];
}
return t5;
};
CardImage.displayName = 'onesy-CardImage';
export default CardImage;