curls
Version:
💪 Responsive, expressive UI primitives for React written with Style Hooks and Emotion
92 lines (73 loc) • 1.9 kB
JavaScript
exports.__esModule = true
exports.br = void 0
var _core = require('@emotion/core')
var _styles = require('../Box/styles')
var _utils = require('../utils')
var _directionalScale = require('../utils/directionalScale')
const ws = /\s+/
const br = (0, _utils.memoTheme)((val, theme) => {
const vals = String(val).split(ws)
let topRadius = 't0',
bottomRadius = 'b0'
for (let val of vals) {
let abbr, value
if (
typeof val === 'number' ||
(typeof val === 'string' && parseInt(val) > -1)
) {
value = val
} else {
const av = String(val).split(_directionalScale.directionalRe)
abbr = av[0]
value = av[1]
}
switch (abbr) {
case 't':
topRadius = topRadius + ` t${value}`
break
case 'b':
bottomRadius = bottomRadius + ` b${value}`
break
case 'tl':
topRadius = topRadius + ` tl${value}`
break
case 'tr':
topRadius = topRadius + ` tr${value}`
break
case 'bl':
bottomRadius = bottomRadius + ` bl${value}`
break
case 'br':
bottomRadius = bottomRadius + ` br${value}`
break
case 'l':
topRadius = topRadius + ` tl${value}`
bottomRadius = bottomRadius + ` bl${value}`
break
case 'r':
topRadius = topRadius + ` tr${value}`
bottomRadius = bottomRadius + ` br${value}`
break
default:
topRadius = `t${value}`
bottomRadius = `b${value}`
}
}
return (
/*#__PURE__*/
(0, _core.css)(
(0, _styles.br)(val, theme),
' & > *:first-child{',
(0, _styles.br)(topRadius, theme),
';',
(0, _styles.br)('b0', theme),
';}& > *:last-child{',
(0, _styles.br)(bottomRadius, theme),
';',
(0, _styles.br)('t0', theme),
';}'
)
)
})
exports.br = br