Skip to content

Commit

Permalink
feat(component): add individual border props to Box
Browse files Browse the repository at this point in the history
  • Loading branch information
deini committed Apr 26, 2019
1 parent b6ebbd2 commit 2559e28
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/big-design/src/components/Box/Box.tsx
Expand Up @@ -11,6 +11,10 @@ export interface BoxProps extends React.HTMLAttributes<HTMLDivElement>, MarginPr
backgroundColor?: keyof Colors;
elevation?: keyof Elevation;
border?: keyof Border;
borderBottom?: keyof Border;
borderLeft?: keyof Border;
borderRight?: keyof Border;
borderTop?: keyof Border;
borderRadius?: keyof BorderRadius;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/big-design/src/components/Box/__snapshots__/spec.tsx.snap
Expand Up @@ -21,3 +21,14 @@ exports[`has elevation props 1`] = `
elevation="floating"
/>
`;

exports[`has individual border props 1`] = `
.c0 {
border-right: 1px solid #D9DCE9;
border-bottom: 1px solid #D9DCE9;
}
<div
class="c0"
/>
`;
6 changes: 6 additions & 0 deletions packages/big-design/src/components/Box/spec.tsx
Expand Up @@ -50,6 +50,12 @@ test('has border props', () => {
expect(container.firstChild).toMatchSnapshot();
});

test('has individual border props', () => {
const { container } = render(<Box borderBottom="box" borderRight="box" />);

expect(container.firstChild).toMatchSnapshot();
});

test('has elevation props', () => {
const { container } = render(<Box elevation="floating" />);

Expand Down
38 changes: 36 additions & 2 deletions packages/big-design/src/components/Box/styled.tsx
Expand Up @@ -16,8 +16,42 @@ export const StyledBox = styled.div<BoxProps>`
`};
${({ elevation, theme }) => elevation && theme.elevation[elevation]};
${({ border, theme }) => border && theme.border[border]};
${({ borderRadius, theme }) => borderRadius && theme.borderRadius[borderRadius]};
${({ border, theme }) =>
border &&
css`
border: ${theme.border[border]};
`};
${({ borderTop, theme }) =>
borderTop &&
css`
border-top: ${theme.border[borderTop]};
`};
${({ borderRight, theme }) =>
borderRight &&
css`
border-right: ${theme.border[borderRight]};
`};
${({ borderBottom, theme }) =>
borderBottom &&
css`
border-bottom: ${theme.border[borderBottom]};
`};
${({ borderLeft, theme }) =>
borderLeft &&
css`
border-left: ${theme.border[borderLeft]};
`};
${({ borderRadius, theme }) =>
borderRadius &&
css`
border-radius: ${theme.borderRadius[borderRadius]};
`};
`;

StyledBox.defaultProps = { theme: defaultTheme };

0 comments on commit 2559e28

Please sign in to comment.