@coko/client
Version:
Client side common code for coko apps
64 lines (63 loc) • 3.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _toolkit = require("../../toolkit");
var _templateObject;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var statuses = {
success: ['success', 'accept'],
error: ['error', 'reject'],
warning: ['warn', 'warning', 'revise'],
primary: ['primary', 'publish']
};
var StyledStatus = _styledComponents["default"].span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: 3px;\n color: ", ";\n display: flex;\n font-family: ", ";\n font-size: ", ";\n justify-content: space-around;\n line-height: ", ";\n max-width: ", ";\n min-width: ", ";\n padding: ", ";\n text-transform: uppercase;\n white-space: normal;\n"])), function (props) {
var reverseColors = props.reverseColors,
status = props.status;
if (!reverseColors) return null;
if (statuses.success.includes(status)) return (0, _toolkit.th)('colorSuccess');
if (statuses.error.includes(status)) return (0, _toolkit.th)('colorError');
if (statuses.warning.includes(status)) return (0, _toolkit.th)('colorWarning');
if (statuses.primary.includes(status)) return (0, _toolkit.th)('colorPrimary');
return (0, _toolkit.th)('colorSecondary');
}, function (props) {
var reverseColors = props.reverseColors,
status = props.status;
if (reverseColors) return (0, _toolkit.th)('colorTextReverse');
if (statuses.success.includes(status)) return (0, _toolkit.th)('colorSuccess');
if (statuses.error.includes(status)) return (0, _toolkit.th)('colorError');
if (statuses.warning.includes(status)) return (0, _toolkit.th)('colorWarning');
if (statuses.primary.includes(status)) return (0, _toolkit.th)('colorPrimary');
return (0, _toolkit.th)('colorText');
}, (0, _toolkit.th)('fontInterface'), (0, _toolkit.th)('fontSizeBaseSmall'), (0, _toolkit.th)('lineHeightBaseSmall'), (0, _toolkit.grid)(24), (0, _toolkit.grid)(12), function (props) {
return props.reverseColors && '4px 8px';
});
var InviteStatus = function InviteStatus(props) {
var children = props.children,
className = props.className,
reverseColors = props.reverseColors,
status = props.status;
if (!children) return null;
return /*#__PURE__*/_react["default"].createElement(StyledStatus, {
className: className,
reverseColors: reverseColors,
status: status
}, children);
};
InviteStatus.propTypes = {
/** Determines if theme colours are reversed */
reverseColors: _propTypes["default"].bool,
/** List of valid status values */
status: _propTypes["default"].oneOf(['success', 'error', 'warn', 'warning', 'accept', 'reject', 'revise', 'primary', 'publish'])
};
InviteStatus.defaultProps = {
reverseColors: false,
status: null
};
var _default = InviteStatus;
exports["default"] = _default;