Skip to content

Commit

Permalink
Merge pull request #19 from smooth-code/border-width-utility
Browse files Browse the repository at this point in the history
fix: add border-width utility
  • Loading branch information
gregberge authored Jun 3, 2019
2 parents 5688b79 + df4c47f commit 5a4a213
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
21 changes: 20 additions & 1 deletion packages/styled-components/src/propGetters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
getColor,
getRadius,
getBorder,
getBorderWidth,
getBorderStyle,
getShadow,
getSize,
Expand All @@ -28,9 +29,16 @@ const getMultiValues = transform => value => {

const getNumberSpace = getNumber(getSpace)
const getMultiNumberSpace = getMultiValues(getNumberSpace)

const getNumberBorder = getNumber(getBorder)

const getNumberBorderWidth = getNumber(getBorderWidth)
const getMultiNumberBorderWidth = getMultiValues(getNumberBorderWidth)

const getNumberSize = getNumber(getSize)

const getMultiBorderStyle = getMultiValues(getBorderStyle)

export const propGetters = {
// getSpace
margin: getMultiNumberSpace,
Expand Down Expand Up @@ -65,8 +73,19 @@ export const propGetters = {
'border-bottom': getNumberBorder,
'border-left': getNumberBorder,

// getBorderWidth
'border-width': getMultiNumberBorderWidth,
'boder-top-width': getNumberBorderWidth,
'boder-right-width': getNumberBorderWidth,
'boder-bottom-width': getNumberBorderWidth,
'boder-left-width': getNumberBorderWidth,

// getBorderStyle
'border-style': getBorderStyle,
'border-style': getMultiBorderStyle,
'boder-top-style': getBorderStyle,
'boder-right-style': getBorderStyle,
'boder-bottom-style': getBorderStyle,
'boder-left-style': getBorderStyle,

// getShadow
'box-shadow': getShadow,
Expand Down
2 changes: 1 addition & 1 deletion packages/system/src/styles/borders.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const borderColor = style({
themeGet: getColor,
})

const getBorderWidth = themeGetter({
export const getBorderWidth = themeGetter({
key: 'borderWidths',
transform: px,
})
Expand Down
2 changes: 2 additions & 0 deletions packages/system/src/th.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getPercent,
getRadius,
getBorder,
getBorderWidth,
getBorderStyle,
getShadow,
getSize,
Expand All @@ -29,6 +30,7 @@ th.px = getPx
th.percent = getPercent
th.radius = getRadius
th.border = getBorder
th.borderWidth = getBorderWidth
th.borderStyle = getBorderStyle
th.shadow = getShadow
th.size = getSize
Expand Down
8 changes: 8 additions & 0 deletions packages/system/tests/styled-components/th.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ describe('#th', () => {
theme: { borders: { red: '1px solid red' } },
},
],
[
'borderWidth',
{
cssProp: 'borderWidth',
expectations: [[0, 0], [1, '1px'], ['sm', '2px']],
theme: { borderWidths: { sm: 2 } },
},
],
[
'borderStyle',
{
Expand Down

0 comments on commit 5a4a213

Please sign in to comment.