From 398cfc7bd83b23352a7abe6559c3e8070f36d82c Mon Sep 17 00:00:00 2001 From: Ryan Oglesby Date: Wed, 18 Oct 2017 10:56:35 -0400 Subject: [PATCH] feat(card): remove deprecated props - remove className and pass all props to safeRest --- src/components/Card/Card.jsx | 35 +++++---------------- src/components/Card/__tests__/Card.spec.jsx | 29 +++++++---------- 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/components/Card/Card.jsx b/src/components/Card/Card.jsx index ce3910f9fc..190da23921 100644 --- a/src/components/Card/Card.jsx +++ b/src/components/Card/Card.jsx @@ -1,43 +1,22 @@ import React from 'react' import PropTypes from 'prop-types' -import { deprecate } from '../../utils/warn' +import safeRest from '../../utils/safeRest' import styles from './Card.modules.scss' /** * A container that serves as an entry point to more detailed information. */ -const Card = ({ className, children, ...rest }) => { - if (className) { - deprecate( - 'Card', - 'Custom CSS classes are deprecated. This component does not support custom styling.' - ) - } - - if (rest.style) { - deprecate( - 'Card', - 'Inline styles are deprecated. This component does not support custom styling.' - ) - } - - return ( -
- {children} -
- ) -} +const Card = ({ children, ...rest }) => ( +
+ {children} +
+) Card.propTypes = { /** - * One or more CSS class names separated by spaces to append onto the container. - * @deprecated since v0.18.0. Card will no longer support custom styling. - */ - className: PropTypes.string, // eslint-disable-line react/require-default-props - /** - * The Card's content. Can be text, any HTML element, or any component. + * The content. Can be text, any HTML element, or any component. */ children: PropTypes.node.isRequired, } diff --git a/src/components/Card/__tests__/Card.spec.jsx b/src/components/Card/__tests__/Card.spec.jsx index 6bcc366b78..639f0d7fa8 100644 --- a/src/components/Card/__tests__/Card.spec.jsx +++ b/src/components/Card/__tests__/Card.spec.jsx @@ -2,35 +2,28 @@ import React from 'react' import { shallow } from 'enzyme' import toJson from 'enzyme-to-json' -import { deprecate } from '../../../utils/warn' - import Card from '../Card' -jest.mock('../../../utils/warn') - describe('', () => { + const doShallow = (props = {}) => shallow(Some content) + it('renders', () => { - const card = shallow(Some content) + const card = doShallow() expect(toJson(card)).toMatchSnapshot() }) - it('passes attributes to DOM node', () => { - const card = shallow( - - Some content - - ) + it('passes additional attributes to the input element', () => { + const card = doShallow({ role: 'some-role', 'data-some-value': 'some value' }) - expect(card).toHaveProp('id', 'hello') - expect(card).toHaveProp('title', 'my title') + expect(card).toHaveProp('role', 'some-role') + expect(card).toHaveProp('data-some-value', 'some value') }) - it('accepts but deprecates inline styles', () => { - const styles = { color: 'blue' } - const card = shallow(Some content) + it('does not allow custom CSS', () => { + const card = doShallow({ className: 'my-custom-class', style: { color: 'hotpink' } }) - expect(card).toHaveProp('style', styles) - expect(deprecate).toHaveBeenCalled() + expect(card).not.toHaveProp('className', 'my-custom-class') + expect(card).not.toHaveProp('style') }) })