Skip to content

Commit

Permalink
use prop-types package
Browse files Browse the repository at this point in the history
  • Loading branch information
lipp committed May 30, 2017
1 parent 222653a commit ff5b869
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 121 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"attr-accept": "^1.0.3",
"classnames": "^2.2.4",
"keycode": "^2.1.8",
"prop-types": "^15.5.10",
"react-motion": "^0.4.3"
},
"standard": {
Expand Down
3 changes: 2 additions & 1 deletion src/js/bottomnavigation/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'

export class BottomNavigation extends React.Component {
static propTypes = {
scrollDuration: React.PropTypes.number
scrollDuration: PropTypes.number
}

static defaultProps = {
Expand Down
9 changes: 5 additions & 4 deletions src/js/button/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

const Button = ({children, className, filled, raised, dense, ...rest}) => (
Expand All @@ -16,10 +17,10 @@ const Button = ({children, className, filled, raised, dense, ...rest}) => (
)

Button.propTypes = {
className: React.PropTypes.string,
dense: React.PropTypes.bool,
filled: React.PropTypes.bool,
raised: React.PropTypes.bool
className: PropTypes.string,
dense: PropTypes.bool,
filled: PropTypes.bool,
raised: PropTypes.bool
}

Button.defaultProps = {
Expand Down
11 changes: 6 additions & 5 deletions src/js/checkbox/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {CheckBox, CheckBoxOutlineBlank} from '../icon'

Expand Down Expand Up @@ -50,11 +51,11 @@ export default class Checkbox extends React.Component {
}

Checkbox.propTypes = {
checked: React.PropTypes.bool,
defaultChecked: React.PropTypes.bool,
disabled: React.PropTypes.bool,
label: React.PropTypes.string,
onChange: React.PropTypes.func
checked: PropTypes.bool,
defaultChecked: PropTypes.bool,
disabled: PropTypes.bool,
label: PropTypes.string,
onChange: PropTypes.func
}

Checkbox.defaultProps = {
Expand Down
17 changes: 9 additions & 8 deletions src/js/chip/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import {Cancel} from '../icon'
import keycode from 'keycode'

Expand All @@ -23,14 +24,14 @@ const focusLeftOrRight = (event, leftKeys, rightKeys) => {
// input fields which handles all logic
export default class Chip extends React.Component {
static propTypes = {
autoFocus: React.PropTypes.bool,
deletable: React.PropTypes.bool,
delimiters: React.PropTypes.arrayOf(React.PropTypes.number),
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func,
placeholder: React.PropTypes.string,
value: React.PropTypes.arrayOf(React.PropTypes.object)
autoFocus: PropTypes.bool,
deletable: PropTypes.bool,
delimiters: PropTypes.arrayOf(PropTypes.number),
onBlur: PropTypes.func,
onChange: PropTypes.func,
onFocus: PropTypes.func,
placeholder: PropTypes.string,
value: PropTypes.arrayOf(PropTypes.object)
}

static defaultProps = {
Expand Down
5 changes: 3 additions & 2 deletions src/js/header/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {ChevronRight} from '../icon'

Expand All @@ -9,8 +10,8 @@ export default class Header extends React.Component {
}

static propTypes = {
title: React.PropTypes.string,
subtitle: React.PropTypes.string
title: PropTypes.string,
subtitle: PropTypes.string
}

componentDidMount () {
Expand Down
31 changes: 16 additions & 15 deletions src/js/list/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import keycode from 'keycode'

Expand Down Expand Up @@ -88,28 +89,28 @@ export const Row = ({
}

const stringOrElement = () => {
return React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.string
return PropTypes.oneOfType([
PropTypes.element,
PropTypes.arrayOf(PropTypes.element),
PropTypes.string
])
}

Row.propTypes = {
avatar: React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.string
avatar: PropTypes.oneOfType([
PropTypes.element,
PropTypes.string
]),
className: React.PropTypes.string,
icon: React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.string
className: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.element,
PropTypes.string
]),
onBlur: React.PropTypes.func,
onClick: React.PropTypes.func,
onFocus: React.PropTypes.func,
onBlur: PropTypes.func,
onClick: PropTypes.func,
onFocus: PropTypes.func,
primary: stringOrElement().isRequired,
secondary: stringOrElement(),
style: React.PropTypes.object,
style: PropTypes.object,
subheader: stringOrElement()
}
7 changes: 4 additions & 3 deletions src/js/menu/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import {Motion, spring} from 'react-motion'

export const Divider = 'DIVIDER'
Expand Down Expand Up @@ -65,9 +66,9 @@ export function Menu ({items, children, visible, onClick, transformX, transformY
* Property types
*/
Menu.propTypes = {
items: React.PropTypes.array,
onClick: React.PropTypes.func.isRequired,
visible: React.PropTypes.bool
items: PropTypes.array,
onClick: PropTypes.func.isRequired,
visible: PropTypes.bool
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/js/modal/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'

/**
Expand Down Expand Up @@ -32,11 +33,11 @@ var Modal = ({header, body, footer, visible, toggle}) => (
)

Modal.propTypes = {
header: React.PropTypes.element,
body: React.PropTypes.element,
footer: React.PropTypes.element,
visible: React.PropTypes.bool,
toggle: React.PropTypes.func
header: PropTypes.element,
body: PropTypes.element,
footer: PropTypes.element,
visible: PropTypes.bool,
toggle: PropTypes.func
}

Modal.defaultProps = {
Expand Down
5 changes: 3 additions & 2 deletions src/js/progress/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

import React from 'react'
import PropTypes from 'prop-types'
import {Motion, spring} from 'react-motion'

class Linear extends React.Component {
static propTypes = {
percentage: React.PropTypes.number
percentage: PropTypes.number
}

static defaultProps = {
Expand Down Expand Up @@ -43,7 +44,7 @@ class Linear extends React.Component {

class Circular extends React.Component {
static propTypes = {
percentage: React.PropTypes.number
percentage: PropTypes.number
}

static defaultProps = {
Expand Down
9 changes: 5 additions & 4 deletions src/js/radiobutton/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import keycode from 'keycode'
import {RadioButtonChecked, RadioButtonUnchecked} from '../icon'
Expand Down Expand Up @@ -71,10 +72,10 @@ class RadioButton extends React.Component {
}

RadioButton.propTypes = {
name: React.PropTypes.string.isRequired,
selectedValue: React.PropTypes.string,
items: React.PropTypes.array,
onChange: React.PropTypes.func.isRequired
name: PropTypes.string.isRequired,
selectedValue: PropTypes.string,
items: PropTypes.array,
onChange: PropTypes.func.isRequired
}

RadioButton.defaultProps = {
Expand Down
25 changes: 13 additions & 12 deletions src/js/select/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import {Motion, spring} from 'react-motion'

const PADDING_TOP_WITH_LABEL = -14
Expand All @@ -14,12 +15,12 @@ const MAX_LIST_LENGTH = 5
*/
export default class Select extends React.Component {
static propTypes = {
disabled: React.PropTypes.bool,
label: React.PropTypes.string,
options: React.PropTypes.array,
placeholder: React.PropTypes.string,
onChange: React.PropTypes.func.isRequired,
name: React.PropTypes.string
disabled: PropTypes.bool,
label: PropTypes.string,
options: PropTypes.array,
placeholder: PropTypes.string,
onChange: PropTypes.func.isRequired,
name: PropTypes.string
}

static defaultProps = {
Expand Down Expand Up @@ -163,12 +164,12 @@ export default class Select extends React.Component {
*/
class List extends React.Component {
static propTypes = {
hasLabel: React.PropTypes.bool,
options: React.PropTypes.array.isRequired,
isInsideTable: React.PropTypes.bool,
selectedIndex: React.PropTypes.number.isRequired,
onClick: React.PropTypes.func.isRequired,
width: React.PropTypes.number
hasLabel: PropTypes.bool,
options: PropTypes.array.isRequired,
isInsideTable: PropTypes.bool,
selectedIndex: PropTypes.number.isRequired,
onClick: PropTypes.func.isRequired,
width: PropTypes.number
}

/**
Expand Down
13 changes: 7 additions & 6 deletions src/js/slider/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'

/**
* Slider
Expand All @@ -17,12 +18,12 @@ const clip = (v, min, max) => {

export default class Slider extends React.Component {
static propTypes = {
value: React.PropTypes.number,
min: React.PropTypes.number.isRequired,
max: React.PropTypes.number.isRequired,
step: React.PropTypes.number,
onChange: React.PropTypes.func,
onMove: React.PropTypes.func
value: PropTypes.number,
min: PropTypes.number.isRequired,
max: PropTypes.number.isRequired,
step: PropTypes.number,
onChange: PropTypes.func,
onMove: PropTypes.func
}

defaultProps = {
Expand Down
9 changes: 5 additions & 4 deletions src/js/snackbar/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import {Motion, spring} from 'react-motion'

/**
Expand Down Expand Up @@ -48,10 +49,10 @@ var Snackbar = ({text, action, onAction, visible}) => (
* Snackbar property types
*/
Snackbar.propTypes = {
text: React.PropTypes.string,
action: React.PropTypes.string,
onAction: React.PropTypes.func,
visible: React.PropTypes.bool
text: PropTypes.string,
action: PropTypes.string,
onAction: PropTypes.func,
visible: PropTypes.bool
}

/**
Expand Down
17 changes: 9 additions & 8 deletions src/js/stepper/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {ReportProblem} from '../icon/'
import Button from '../button/'
Expand Down Expand Up @@ -145,13 +146,13 @@ class StepperComponent extends React.Component {
export const Stepper = withRouter(StepperComponent)

Stepper.propTypes = {
steps: React.PropTypes.arrayOf(React.PropTypes.shape({
title: React.PropTypes.string.isRequired,
href: React.PropTypes.string.isRequired,
component: React.PropTypes.func.isRequired,
optional: React.PropTypes.string
steps: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string.isRequired,
href: PropTypes.string.isRequired,
component: PropTypes.func.isRequired,
optional: PropTypes.string
})).isRequired,
horizontal: React.PropTypes.bool,
onCancel: React.PropTypes.func,
onError: React.PropTypes.func
horizontal: PropTypes.bool,
onCancel: PropTypes.func,
onError: PropTypes.func
}
9 changes: 5 additions & 4 deletions src/js/switch/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import React from 'react'
import PropTypes from 'prop-types'

/**
* Switch component
Expand All @@ -24,10 +25,10 @@ var Switch = ({checked, disabled, name, onChange}) => (
* Property types
*/
Switch.propTypes = {
checked: React.PropTypes.bool,
disabled: React.PropTypes.bool,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired
checked: PropTypes.bool,
disabled: PropTypes.bool,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired
}

/**
Expand Down
Loading

0 comments on commit ff5b869

Please sign in to comment.