Skip to content

Commit

Permalink
feat(card): use css modules and disallow custom classes
Browse files Browse the repository at this point in the history
- move card to components dir
  • Loading branch information
ryanoglesby08 authored and theetrain committed Oct 18, 2017
1 parent 40fd2ab commit dcc8dba
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module.exports = {
{
name: 'Content',
components() {
return [path.resolve('src/old-components/Card/Card.jsx')]
return [path.resolve('src/components/Card/Card.jsx')]
},
sections: compact([
{
Expand Down
18 changes: 11 additions & 7 deletions src/old-components/Card/Card.jsx → src/components/Card/Card.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'

import classNames from 'classnames'

import { deprecate } from '../../utils/warn'

import './Card.scss'
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.')
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.')
deprecate(
'Card',
'Inline styles are deprecated. This component does not support custom styling.'
)
}

return (
<div {...rest} className={classNames('card', className)}>
<div {...rest} className={styles.card}>
{children}
</div>
)
Expand All @@ -35,7 +39,7 @@ Card.propTypes = {
/**
* The Card's content. Can be text, any HTML element, or any component.
*/
children: PropTypes.node.isRequired
children: PropTypes.node.isRequired,
}

export default Card
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
border: 0;
box-sizing: border-box;
border-radius: 4px;
box-shadow: 0 0 16px 0 rgba(213, 213, 213, .5);
box-shadow: 0 0 16px 0 rgba(213, 213, 213, 0.5);
background-color: $color-white;
padding: 30px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ describe('<Card />', () => {
expect(card).toHaveProp('title', 'my title')
})

it('accepts but deprecates custom classes', () => {
const card = shallow(<Card className="some-class">Some content</Card>)

expect(card).toHaveClassName('some-class')
expect(deprecate).toHaveBeenCalled()
})

it('accepts but deprecates inline styles', () => {
const styles = { color: 'blue' }
const card = shallow(<Card style={styles}>Some content</Card>)
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './scss/global.scss'

export { default as Button } from './components/Button/Button'
export { default as ButtonLink } from './components/Link/ButtonLink/ButtonLink'
export { default as Card } from './old-components/Card/Card'
export { default as Card } from './components/Card/Card'
export { default as ChevronLink } from './components/Link/ChevronLink/ChevronLink'
export { default as DecorativeIcon } from './components/Icons/DecorativeIcon/DecorativeIcon'
export { default as DimpleDivider } from './components/Dividers/DimpleDivider/DimpleDivider'
Expand Down

0 comments on commit dcc8dba

Please sign in to comment.