Skip to content

Commit

Permalink
feat(component): allow Box to render with a different tag (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini committed Nov 8, 2019
1 parent 17e3c57 commit a933b45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/big-design/src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MarginProps, PaddingProps } from '../../mixins';
import { StyledBox } from './styled';

export interface BoxProps extends React.HTMLAttributes<HTMLDivElement>, MarginProps, PaddingProps {
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
backgroundColor?: keyof Colors;
shadow?: keyof Shadow;
border?: keyof Border;
Expand Down
7 changes: 7 additions & 0 deletions packages/big-design/src/components/Box/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ test('theme prop overrides default theme', () => {

expect(container.firstChild).toHaveStyle(`background-color: red`);
});

test('renders as a different tag', () => {
const { getByTestId } = render(<Box data-testid="box" as="section" />);
const tag = getByTestId('box').tagName;

expect(tag).toBe('SECTION');
});
5 changes: 5 additions & 0 deletions packages/docs/PropTables/BoxPropTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import React from 'react';
import { NextLink, Prop, PropTable, PropTableWrapper } from '../components';

const boxProps: Prop[] = [
{
name: 'as',
types: ['string', 'React.ComponentType<any>'],
description: 'Use a different HTML tag or a different custom component',
},
{
name: 'backgroundColor',
types: (
Expand Down

0 comments on commit a933b45

Please sign in to comment.