Skip to content

Commit

Permalink
fix(core-react): add custom class support (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraider authored Aug 15, 2019
1 parent ae7e7ea commit cd5cfb1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
7 changes: 7 additions & 0 deletions packages/core-react/src/components/Button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ describe('Button', () => {
const wrapper = mount(<Button>hello world</Button>);
expect(wrapper.find('.ray-button--primary').length).toBe(1);
});

test('it supports a custom class', () => {
const wrapper = mount(
<Button className="some-custom-class">hello world</Button>
);
expect(wrapper.find('.ray-button.some-custom-class').length).toBe(1);
});
});
17 changes: 12 additions & 5 deletions packages/core-react/src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ export default function Button({
compact,
danger,
disabled,
className,
...props
}) {
return (
<Tag
{...props}
className={clsx('ray-button', `ray-button--${type}`, {
'ray-button--compact': compact,
'ray-button--danger': danger
})}
className={clsx(
'ray-button',
`ray-button--${type}`,
{
'ray-button--compact': compact,
'ray-button--danger': danger
},
className
)}
disabled={disabled}
>
{children}
Expand All @@ -31,7 +37,8 @@ Button.propTypes = {
danger: PropTypes.bool,
children: PropTypes.node,
Tag: PropTypes.oneOf(['button', 'a']),
disabled: PropTypes.bool
disabled: PropTypes.bool,
className: PropTypes.string
};

Button.defaultProps = {
Expand Down
7 changes: 4 additions & 3 deletions packages/core-react/src/components/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';

export default function Card({ heading, body, img, row }) {
export default function Card({ heading, body, img, row, className }) {
return (
<div className={clsx('ray-card', { 'ray-card--row': row })}>
<div className={clsx('ray-card', { 'ray-card--row': row }, className)}>
<div className="ray-card__image ray-image ray-image--16by9">{img}</div>
<div className="ray-card__content">
<div className="ray-card__heading">{heading}</div>
Expand All @@ -18,5 +18,6 @@ Card.propTypes = {
heading: PropTypes.node,
body: PropTypes.node,
img: PropTypes.node,
row: PropTypes.bool
row: PropTypes.bool,
className: PropTypes.string
};

0 comments on commit cd5cfb1

Please sign in to comment.