bpk-component-button
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "bpk-component-button", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Backpack button component.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,3 +10,3 @@ jest.unmock('./BpkButton') | ||
const wrapper = shallow(<BpkButton>My button</BpkButton>) | ||
expect(wrapper.children().length).toEqual(1) | ||
expect(wrapper.text()).toEqual('My button') | ||
expect(wrapper.name()).toEqual('button') | ||
@@ -17,3 +17,3 @@ }) | ||
const wrapper = shallow(<BpkButton href='#'>My button</BpkButton>) | ||
expect(wrapper.children().length).toEqual(1) | ||
expect(wrapper.text()).toEqual('My button') | ||
expect(wrapper.name()).toEqual('a') | ||
@@ -20,0 +20,0 @@ expect(wrapper.prop('href')).toEqual('#') |
import React, { PropTypes } from 'react' | ||
import './bpk-button.scss' | ||
const BpkButton = ({ href, submit, secondary, selected, large, link, ...rest }) => { | ||
const BpkButton = ({ children, disabled, href, submit, secondary, selected, large, link, onClick }) => { | ||
const classNames = [ 'bpk-button' ] | ||
@@ -15,10 +15,26 @@ | ||
if (href) { | ||
return <a href={href} className={className} {...rest} /> | ||
return <a | ||
href={href} | ||
className={className} | ||
children={children} | ||
onClick={onClick} | ||
/> | ||
} | ||
return <button type={submit ? 'submit' : 'button'} className={className} {...rest} /> | ||
return <button | ||
type={submit ? 'submit' : 'button'} | ||
disabled={disabled} | ||
className={className} | ||
children={children} | ||
onClick={onClick} | ||
/> | ||
} | ||
BpkButton.propTypes = { | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node | ||
]).isRequired, | ||
href: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
submit: PropTypes.bool, | ||
@@ -28,6 +44,9 @@ secondary: PropTypes.bool, | ||
large: PropTypes.bool, | ||
link: PropTypes.bool | ||
link: PropTypes.bool, | ||
onClick: PropTypes.func | ||
} | ||
BpkButton.defaultProps = { | ||
href: null, | ||
disabled: false, | ||
submit: false, | ||
@@ -37,5 +56,6 @@ secondary: false, | ||
large: false, | ||
link: false | ||
link: false, | ||
onClick: null | ||
} | ||
export default BpkButton |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4644
98