import { BorderInterface } from '../../types'; import { stringOrNumberHelper } from './stringOrNumberHelper'; export const borderDecorator = ({ b, bc, bs, bt, br, bb, bl, bx, by, }: BorderInterface) => { // Address directions separately instead of in bulk let response = ''; let borderT = ' border-top-width: 0;'; let borderR = ' border-right-width: 0;'; let borderB = ' border-bottom-width: 0;'; let borderL = ' border-left-width: 0;'; if (!!bt || !!br || !!bb || !!bl || !!bx || !!by) { response += ` border-color: ${bc || '#aaaaaa'}; border-style: ${bs || 'solid'}; `; if (bt) { borderT = `border-top-width: ${stringOrNumberHelper(bt, 'px')};`; } if (br) { borderR = `border-right-width: ${stringOrNumberHelper(br, 'px')};`; } if (bb) { borderB = `border-bottom-width: ${stringOrNumberHelper(bb, 'px')};`; } if (bl) { borderL = `border-left-width: ${stringOrNumberHelper(bl, 'px')};`; } if (bx) { borderR = `border-right-width: ${stringOrNumberHelper(bx, 'px')};`; borderL = `border-left-width: ${stringOrNumberHelper(bx, 'px')};`; } if (by) { borderT = `border-top-width: ${stringOrNumberHelper(by, 'px')};`; borderB = `border-bottom-width: ${stringOrNumberHelper(by, 'px')};`; } response += borderT + borderR + borderB + borderL; } if (b) { response = `border: ${b};`; } return response; };