UNPKG

kitten-components

Version:
258 lines (195 loc) 12.3 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.styles = exports.RewardCard = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _radium = require('radium'); var _radium2 = _interopRequireDefault(_radium); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _deprecated = require('prop-types-extra/lib/deprecated'); var _deprecated2 = _interopRequireDefault(_deprecated); var _colorsConfig = require('kitten/constants/colors-config'); var _colorsConfig2 = _interopRequireDefault(_colorsConfig); var _legacyRewardCardContainer = require('kitten/components/cards/reward-card/legacy-reward-card-container'); var _text = require('kitten/components/typography/text'); var _typography = require('kitten/helpers/utils/typography'); var _title = require('kitten/components/cards/reward-card/title'); var _row = require('kitten/components/cards/reward-card/row'); var _rowContent = require('kitten/components/cards/reward-card/row-content'); var _rowSide = require('kitten/components/cards/reward-card/row-side'); var _starredBadge = require('kitten/components/cards/reward-card/starred-badge'); var _checkedSection = require('kitten/components/cards/reward-card/checked-section'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Text = (0, _radium2.default)(_text.Text); // TODO: Move this class to a separate file after deprecated component with the // same name will be deleted. var RewardCardInfo = function (_Component) { _inherits(RewardCardInfo, _Component); function RewardCardInfo() { _classCallCheck(this, RewardCardInfo); return _possibleConstructorReturn(this, (RewardCardInfo.__proto__ || Object.getPrototypeOf(RewardCardInfo)).apply(this, arguments)); } _createClass(RewardCardInfo, [{ key: 'render', value: function render() { var _props = this.props, label = _props.label, value = _props.value, withMarginBottom = _props.withMarginBottom, disabled = _props.disabled; var infoStyles = [style.info, withMarginBottom && style.infoWithMargin, disabled && style.disabled]; return _react2.default.createElement( Text, { size: 'tiny', color: 'font1', weight: 'regular', style: infoStyles }, label + ' ', _react2.default.createElement( Text, { weight: 'light' }, value ) ); } }]); return RewardCardInfo; }(_react.Component); // TODO: Move this class to a separate file after deprecated component with the // same name will be deleted. RewardCardInfo.propTypes = { label: _propTypes2.default.string.isRequired, value: _propTypes2.default.string, withMarginBottom: _propTypes2.default.bool, disabled: _propTypes2.default.bool }; RewardCardInfo.defaultProps = { value: null, withMarginBottom: true, disabled: false }; var RewardCardImage = function (_Component2) { _inherits(RewardCardImage, _Component2); function RewardCardImage() { _classCallCheck(this, RewardCardImage); return _possibleConstructorReturn(this, (RewardCardImage.__proto__ || Object.getPrototypeOf(RewardCardImage)).apply(this, arguments)); } _createClass(RewardCardImage, [{ key: 'render', value: function render() { var _props2 = this.props, alt = _props2.alt, disabled = _props2.disabled, others = _objectWithoutProperties(_props2, ['alt', 'disabled']); var imageStyles = [{ width: '100%' }, disabled && styles.disabled]; return _react2.default.createElement('img', _extends({}, others, { alt: alt || '', style: imageStyles })); } }]); return RewardCardImage; }(_react.Component); RewardCardImage.propTypes = { disabled: _propTypes2.default.bool }; RewardCardImage.defaultProps = { disabled: false }; var RewardCard = exports.RewardCard = function (_Component3) { _inherits(RewardCard, _Component3); function RewardCard() { _classCallCheck(this, RewardCard); return _possibleConstructorReturn(this, (RewardCard.__proto__ || Object.getPrototypeOf(RewardCard)).apply(this, arguments)); } _createClass(RewardCard, [{ key: 'render', value: function render() { var _props3 = this.props, children = _props3.children, others = _objectWithoutProperties(_props3, ['children']); return _react2.default.createElement( _react.Fragment, null, _react2.default.createElement(_legacyRewardCardContainer.LegacyRewardCardContainer, this.props), children && _react2.default.createElement( 'div', _extends({}, others, { style: style.card }), children ) ); } }]); return RewardCard; }(_react.Component); RewardCard.Row = _row.RewardCardRow; RewardCard.RowContent = _rowContent.RewardCardRowContent; RewardCard.RowSide = _rowSide.RewardCardRowSide; RewardCard.Title = _title.RewardCardTitle; RewardCard.Image = (0, _radium2.default)(RewardCardImage); RewardCard.Info = RewardCardInfo; RewardCard.CheckedSection = _checkedSection.RewardCardCheckedSection; RewardCard.StarredBadge = _starredBadge.RewardCardStarredBadge; RewardCard.propTypes = { titleAmount: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Title` instead.'), titleTag: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Title` instead.'), subtitle: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), subtitleTag: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), description: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), manageContributionDescription: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard` sub-component instead.'), manageContributionLinkLabel: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard` sub-component instead.'), manageContributionLinkHref: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard` sub-component instead.'), buttonLabel: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Action` to insert your button and its callbacks instead.'), buttonOnMouseEnter: (0, _deprecated2.default)(_propTypes2.default.func, 'Use `RewardCard.Action` to insert your button and its callbacks instead.'), buttonOnMouseLeave: (0, _deprecated2.default)(_propTypes2.default.func, 'Use `RewardCard.Action` to insert your button and its callbacks instead.'), buttonOnClick: (0, _deprecated2.default)(_propTypes2.default.func, 'Use `RewardCard.Action` to insert your button and its callbacks instead.'), imageProps: (0, _deprecated2.default)(_propTypes2.default.object, 'Use `RewardCard.Image` instead.'), isDisabled: (0, _deprecated2.default)(_propTypes2.default.bool, 'You should handle the disabled state direcly on your component.'), starred: (0, _deprecated2.default)(_propTypes2.default.bool, 'Use `RewardCard` sub-component instead.'), starLabel: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard` sub-component instead.'), version: (0, _deprecated2.default)(_propTypes2.default.oneOf(['default', 'tiny']), '`RewardCard` is no longer handled with media-queries. The version of the component now is handled by the size of the parent container.'), // Deprecated props titleDescription: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), textDescription: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), textTag: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Row`, `RewardCard.RowContent` and `RewardCard.RowSide` to compose your card content instead.'), myContribution: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `manageContributionDescription` prop instead.'), manageContribution: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `manageContributionLinkLabel` prop instead.'), manageContributionLink: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `manageContributionLinkHref` prop instead.'), button: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `RewardCard.Action` to insert your button and its callbacks instead.'), titleContributors: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.'), titleDelivery: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.'), titleAvailability: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.'), valueContributors: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.'), valueDelivery: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.'), valueAvailability: (0, _deprecated2.default)(_propTypes2.default.string, 'Use `Reward.Info` to compose your card content now.') }; var style = { card: { backgroundColor: _colorsConfig2.default.background1, borderWidth: 2, borderStyle: 'solid', borderColor: _colorsConfig2.default.line1, width: '100%', padding: (0, _typography.pxToRem)(15) + ' 0', boxSizing: 'border-box' }, image: { width: '100%' }, info: { display: 'block', lineHeight: (0, _typography.pxToRem)(20) }, infoWithMargin: { marginBottom: (0, _typography.pxToRem)(10) }, disabled: { color: _colorsConfig2.default.font2, cursor: 'not-allowed' } // This export handles retro-compatibility. // TODO: remove this export when deleting all deprecated components. };var styles = exports.styles = _legacyRewardCardContainer.styles;