@sberdevices/plasma-temple
Version:
SberDevices CanvasApp Templates.
84 lines (71 loc) • 4.06 kB
JavaScript
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CartItemCaption = void 0;
var _react = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react"));
var _styledComponents = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("styled-components"));
var _plasmaTokens = /*#__PURE__*/require("@sberdevices/plasma-tokens");
var _plasmaUi = /*#__PURE__*/require("@sberdevices/plasma-ui");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var contentMap = {
'sold-out': function soldOut(value) {
return value || 'Раскупили';
},
'few-left': function fewLeft(value) {
return value || 'Больше нет';
},
'price-changed': function priceChanged(value) {
return value || 'Изменилась цена';
},
sale: function sale(value) {
return "\u0421\u043A\u0438\u0434\u043A\u0430 ".concat(value, "%");
},
'you-want': function youWant(value) {
return "\u0412\u044B \u0445\u043E\u0442\u0435\u043B\u0438 ".concat(value, " \u0442\u043E\u0432\u0430\u0440\u0430");
},
present: function present(value) {
return value || 'Подарок';
},
warning: function warning(value) {
return value || '';
},
critical: function critical(value) {
return value || '';
},
accent: function accent(value) {
return value || '';
}
};
var textColorMap = {
'sold-out': _plasmaTokens.warning,
'few-left': _plasmaTokens.warning,
'price-changed': _plasmaTokens.warning,
sale: _plasmaTokens.accent,
present: _plasmaTokens.accent,
'you-want': _plasmaTokens.warning,
warning: _plasmaTokens.warning,
critical: _plasmaTokens.critical,
accent: _plasmaTokens.accent
};
var StyledLabel = /*#__PURE__*/_styledComponents["default"].div.withConfig({
componentId: "plasma-temple__sc-4lms02-0"
})(["", " ", " color:", ";"], _plasmaTokens.footnote1, /*#__PURE__*/(0, _plasmaUi.mediaQuery)('M', 2)( /*#__PURE__*/(0, _styledComponents.css)(["", ""], _plasmaTokens.caption)), function (_ref) {
var type = _ref.type;
return textColorMap[type];
});
var CartItemCaption = function CartItemCaption(_ref2) {
var type = _ref2.type,
content = _ref2.content,
className = _ref2.className;
var contentProvider = contentMap[type];
return /*#__PURE__*/_react["default"].createElement(StyledLabel, {
className: className,
type: type
}, contentProvider(content));
};
exports.CartItemCaption = CartItemCaption;
//# sourceMappingURL=CartItemCaption.js.map
;