UNPKG

1.49 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = borderRadius;
5var _capitalizeString = _interopRequireDefault(require("../internalHelpers/_capitalizeString"));
6var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Shorthand that accepts a value for side and a value for radius and applies the radius value to both corners of the side.
10 * @example
11 * // Styles as object usage
12 * const styles = {
13 * ...borderRadius('top', '5px')
14 * }
15 *
16 * // styled-components usage
17 * const div = styled.div`
18 * ${borderRadius('top', '5px')}
19 * `
20 *
21 * // CSS as JS Output
22 *
23 * div {
24 * 'borderTopRightRadius': '5px',
25 * 'borderTopLeftRadius': '5px',
26 * }
27 */
28function borderRadius(side, radius) {
29 var uppercaseSide = (0, _capitalizeString["default"])(side);
30 if (!radius && radius !== 0) {
31 throw new _errors["default"](62);
32 }
33 if (uppercaseSide === 'Top' || uppercaseSide === 'Bottom') {
34 var _ref;
35 return _ref = {}, _ref["border" + uppercaseSide + "RightRadius"] = radius, _ref["border" + uppercaseSide + "LeftRadius"] = radius, _ref;
36 }
37 if (uppercaseSide === 'Left' || uppercaseSide === 'Right') {
38 var _ref2;
39 return _ref2 = {}, _ref2["borderTop" + uppercaseSide + "Radius"] = radius, _ref2["borderBottom" + uppercaseSide + "Radius"] = radius, _ref2;
40 }
41 throw new _errors["default"](63);
42}
43module.exports = exports.default;
\No newline at end of file