@pubsweet/ui
Version:
React component library for use in pubsweet apps
87 lines (66 loc) • 5.42 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["default"] = void 0;
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _uiToolkit = require("@pubsweet/ui-toolkit");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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 _templateObject3() {
var data = _taggedTemplateLiteral(["\n background: ", ";\n border: ", " ", " ", ";\n border-radius: ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n line-height: calc(", " * 3);\n min-width: calc(", " * 12);\n padding: ", ";\n\n &:focus,\n &:hover {\n background-color: ", ";\n transition: ", " ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n\n &[disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n\n &:focus,\n &:hover,\n &:active {\n background: ", ";\n }\n }\n\n ", ";\n ", "\n ", ";\n"]);
_templateObject3 = function _templateObject3() {
return data;
};
return data;
}
function _templateObject2() {
var data = _taggedTemplateLiteral(["\n background: ", ";\n color: ", ";\n\n &:focus,\n &:hover {\n background-color: ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n\n &[disabled] {\n &:focus,\n &:hover,\n &:active {\n background: ", ";\n }\n }\n"]);
_templateObject2 = function _templateObject2() {
return data;
};
return data;
}
function _templateObject() {
var data = _taggedTemplateLiteral(["\n border: ", " ", " ", ";\n text-decoration: none;\n padding: ", ";\n\n &:hover,\n &:focus,\n &:active {\n border: ", " ", " ", ";\n }\n"]);
_templateObject = function _templateObject() {
return data;
};
return data;
}
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var backgroundColor = function backgroundColor(props) {
return props.background ? props.background : props.theme.colorPrimary;
};
var borderColor = function borderColor(props) {
return props.color ? props.color : props.colorPrimary;
};
var outline = (0, _styledComponents.css)(_templateObject(), (0, _uiToolkit.th)('borderWidth'), (0, _uiToolkit.th)('borderStyle'), borderColor, function (props) {
return props.size === 'small' ? '0' : props.theme.gridUnit;
}, (0, _uiToolkit.th)('borderWidth'), (0, _uiToolkit.th)('borderStyle'), borderColor);
var primary = (0, _styledComponents.css)(_templateObject2(), backgroundColor, function (props) {
return props.color ? props.color : props.theme.colorTextReverse;
}, function (props) {
return props.background ? (0, _uiToolkit.darken)(props.background, 0.3) : (0, _uiToolkit.darken)(props.theme.colorPrimary, 0.3);
}, function (props) {
return props.background ? (0, _uiToolkit.darken)(props.background, 0.5) : (0, _uiToolkit.darken)(props.theme.colorPrimary, 0.5);
}, backgroundColor);
var StyledButton = _styledComponents["default"].button.attrs(function (props) {
return {
'data-test-id': props['data-test-id'],
type: props.type || 'button'
};
})(_templateObject3(), (0, _uiToolkit.th)('colorSecondary'), (0, _uiToolkit.th)('borderWidth'), (0, _uiToolkit.th)('borderStyle'), (0, _uiToolkit.th)('colorBorder'), (0, _uiToolkit.th)('borderRadius'), function (props) {
return props.color ? props.color : props.theme.colorText;
}, (0, _uiToolkit.th)('fontInterface'), function (props) {
return props.size === 'small' ? props.theme.fontSizeBaseSmall : props.theme.fontSizeBase;
}, (0, _uiToolkit.th)('gridUnit'), (0, _uiToolkit.th)('gridUnit'), function (props) {
return props.size === 'small' ? '0' : props.theme.gridUnit;
}, (0, _uiToolkit.darken)('colorSecondary', 0.3), (0, _uiToolkit.th)('transitionDuration'), (0, _uiToolkit.th)('transitionTimingFunction'), (0, _uiToolkit.darken)('colorSecondary', 0.5), (0, _uiToolkit.th)('colorSecondary'), function (props) {
return props.primary && primary;
}, function (props) {
return props.outline && outline;
}, (0, _uiToolkit.override)('ui.Button'));
var _default = StyledButton;
exports["default"] = _default;