-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from femioladeji/remove-prop-types
Remove prop-types depedency
- Loading branch information
Showing
6 changed files
with
120 additions
and
135 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const defaultProps = { | ||
duration: 5000, | ||
transitionDuration: 1000, | ||
defaultIndex: 0, | ||
infinite: true, | ||
autoplay: true, | ||
indicators: false, | ||
arrows: true, | ||
pauseOnHover: true, | ||
scale: 1, | ||
easing: 'linear' | ||
}; | ||
|
||
export const getProps = componentProps => ({ | ||
...defaultProps, | ||
...componentProps | ||
}); | ||
|
||
export const propTypes = { | ||
duration: 'number', | ||
transitionDuration: 'number', | ||
defaultIndex: 'number', | ||
infinite: 'boolean', | ||
indicators: ['boolean', 'function'], | ||
autoplay: 'boolean', | ||
arrows: 'boolean', | ||
onChange: 'function', | ||
pauseOnHover: 'boolean', | ||
prevArrow: ['object', 'function'], | ||
nextArrow: ['object', 'function'], | ||
scale: 'number', | ||
easing: 'string' | ||
}; | ||
|
||
export const validatePropTypes = props => { | ||
for (const key in props) { | ||
const propValueType = typeof props[key]; | ||
if (propTypes[key]) { | ||
if ( | ||
Array.isArray(propTypes[key]) && | ||
!propTypes[key].includes(propValueType) | ||
) { | ||
console.warn( | ||
`${key} must be of one of type ${propTypes[key].join(', ')}` | ||
); | ||
} else if ( | ||
!Array.isArray(propTypes[key]) && | ||
propValueType !== propTypes[key] | ||
) { | ||
console.warn(`${key} must be of type ${propTypes[key]}`); | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.