You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
3 years ago
|
"use strict";
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
exports["default"] = borderRadius;
|
||
|
|
||
|
var _capitalizeString = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("../internalHelpers/_capitalizeString"));
|
||
|
|
||
|
var _errors = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("../internalHelpers/_errors"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||
|
|
||
|
/**
|
||
|
* Shorthand that accepts a value for side and a value for radius and applies the radius value to both corners of the side.
|
||
|
* @example
|
||
|
* // Styles as object usage
|
||
|
* const styles = {
|
||
|
* ...borderRadius('top', '5px')
|
||
|
* }
|
||
|
*
|
||
|
* // styled-components usage
|
||
|
* const div = styled.div`
|
||
|
* ${borderRadius('top', '5px')}
|
||
|
* `
|
||
|
*
|
||
|
* // CSS as JS Output
|
||
|
*
|
||
|
* div {
|
||
|
* 'borderTopRightRadius': '5px',
|
||
|
* 'borderTopLeftRadius': '5px',
|
||
|
* }
|
||
|
*/
|
||
|
function borderRadius(side, radius) {
|
||
|
var uppercaseSide = (0, _capitalizeString["default"])(side);
|
||
|
|
||
|
if (!radius && radius !== 0) {
|
||
|
throw new _errors["default"](62);
|
||
|
}
|
||
|
|
||
|
if (uppercaseSide === 'Top' || uppercaseSide === 'Bottom') {
|
||
|
var _ref;
|
||
|
|
||
|
return _ref = {}, _ref["border" + uppercaseSide + "RightRadius"] = radius, _ref["border" + uppercaseSide + "LeftRadius"] = radius, _ref;
|
||
|
}
|
||
|
|
||
|
if (uppercaseSide === 'Left' || uppercaseSide === 'Right') {
|
||
|
var _ref2;
|
||
|
|
||
|
return _ref2 = {}, _ref2["borderTop" + uppercaseSide + "Radius"] = radius, _ref2["borderBottom" + uppercaseSide + "Radius"] = radius, _ref2;
|
||
|
}
|
||
|
|
||
|
throw new _errors["default"](63);
|
||
|
}
|
||
|
|
||
|
module.exports = exports.default;
|