bpk-component-button
Advanced tools
Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "bpk-component-button", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Backpack button component.", | ||
@@ -12,4 +12,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"backpack": "git+http://git.prod.skyscanner.local/backpack/backpack.git#v0.0.1" | ||
"backpack": "git+http://git.prod.skyscanner.local/backpack/backpack.git#v0.0.2" | ||
} | ||
} |
@@ -14,2 +14,9 @@ jest.unmock('./BpkButton') | ||
it('should render the correct element if an href is provided', () => { | ||
const wrapper = shallow(<BpkButton href='#'>My button</BpkButton>) | ||
expect(wrapper.children().length).toEqual(1) | ||
expect(wrapper.name()).toEqual('a') | ||
expect(wrapper.prop('href')).toEqual('#') | ||
}) | ||
it('should render the correct class by default', () => { | ||
@@ -16,0 +23,0 @@ const wrapper = shallow(<BpkButton>My button</BpkButton>) |
import React, { PropTypes } from 'react' | ||
import './bpk-button.scss' | ||
const BpkButton = ({ secondary, selected, large, link, ...rest }) => { | ||
const BpkButton = ({ href, submit, secondary, selected, large, link, ...rest }) => { | ||
const classNames = [ 'bpk-button' ] | ||
@@ -12,6 +12,14 @@ | ||
return <button type='button' className={classNames.join(' ')} {...rest} /> | ||
const className = classNames.join(' ') | ||
if (href) { | ||
return <a href={href} className={className} {...rest} /> | ||
} | ||
return <button type={submit ? 'submit' : 'button'} className={className} {...rest} /> | ||
} | ||
BpkButton.propTypes = { | ||
href: PropTypes.string, | ||
submit: PropTypes.bool, | ||
secondary: PropTypes.bool, | ||
@@ -24,2 +32,3 @@ selected: PropTypes.bool, | ||
BpkButton.defaultProps = { | ||
submit: false, | ||
secondary: false, | ||
@@ -26,0 +35,0 @@ selected: false, |
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
4286
78
15