/** * direction 规则 */ import { UNIT_STR, NONNEGATIVE_NUMBER_REGEX_STR, DIRECTION_MAP } from '../constant' export default { regExp: new RegExp(`^(?[trbl]|top|right|bottom|left)-(?m-)?(?${NONNEGATIVE_NUMBER_REGEX_STR})(?${UNIT_STR})?$`), render({ groups }) { let { direction, isMinus, num, unit } = groups if (isMinus) { num = 0 - num } // is only t r b l if (direction.length === 1) { direction = DIRECTION_MAP.get(direction)[0] } return { name: 'orientation', num, css: [`${direction}: ${num}${unit}`] } } }