UNPKG

@onesy/ui-react

Version:
99 lines (98 loc) 4.49 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _compilerRuntime = require("react/compiler-runtime"); var _react = _interopRequireDefault(require("react")); var _styleReact = require("@onesy/style-react"); var _utils = require("../utils"); var _jsxRuntime = require("react/jsx-runtime"); 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) { (0, _defineProperty2.default)(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; } const useStyle = (0, _styleReact.style)(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_ => { var _theme$ui, _theme$ui2; const $ = (0, _compilerRuntime.c)(6); const theme = (0, _styleReact.useOnesyTheme)(); const props = _objectSpread(_objectSpread(_objectSpread({}, theme === null || theme === void 0 || (_theme$ui = theme.ui) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.elements) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.all) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.props) === null || _theme$ui === void 0 ? void 0 : _theme$ui.default), theme === null || theme === void 0 || (_theme$ui2 = theme.ui) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.elements) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.onesyCardImage) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_); const { tonal: t0, color, version, elevation, alt, image, shape: t1, marginHorizontal, Component: t2, className, children } = props, other = (0, _objectWithoutProperties2.default)(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 = (0, _styleReact.classNames)([(0, _utils.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__*/(0, _jsxRuntime.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'; var _default = exports.default = CardImage;