Skip to content

Commit

Permalink
Remove propTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Klynger authored and Klynger committed Oct 25, 2019
1 parent 36fb709 commit 5aa2b0a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 89 deletions.
49 changes: 8 additions & 41 deletions react/Banner.tsx
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types'
import React from 'react'
import { Link } from 'vtex.render-runtime'
import { useDevice } from 'vtex.device-detector'
Expand All @@ -8,18 +7,15 @@ import styles from './styles.css'

const CSS_HANDLES = ['imgRegular', 'img', 'bannerLink'] as const

interface DefaultProps {
/** Max height size of the banner */
height: number
}

export interface Props extends DefaultProps {
export interface Props {
/** The image of the banner */
image: string
/** Link for the mobile image of the banner */
mobileImage: string
/** The description of the image */
description: string
/** Max height size of the banner */
height: number
/** The url where the image is pointing to, in case of external route */
url: string
/** The page where the image is pointing to */
Expand Down Expand Up @@ -47,19 +43,16 @@ function getParams(params: string) {
return null
}

/**
* Banner component. Shows an image with a description and one link.
*/
const Banner = (props: Props) => {
const {
height,
image,
mobileImage,
description,
page,
url,
page,
image,
params,
mobileImage,
height = 420,
externalRoute,
description = '',
customInternalURL,
} = props

Expand Down Expand Up @@ -110,30 +103,4 @@ const Banner = (props: Props) => {
)
}

Banner.propTypes = {
/** The description of the image */
description: PropTypes.string.isRequired,
/** Indicates if the route is external or not */
externalRoute: PropTypes.bool,
/** Max height size of the banner */
height: PropTypes.number.isRequired,
/** The image of the banner */
image: PropTypes.string.isRequired,
/** The mobile image of the banner */
mobileImage: PropTypes.string,
/** The page where the image is pointing to */
page: PropTypes.string,
/** Params of the url */
params: PropTypes.string,
/** The url where the image is pointing to, in case of external route */
url: PropTypes.string,
/** The url where the image is pointing to, in case of internal route */
customInternalURL: PropTypes.string,
}

Banner.defaultProps = {
height: 420,
description: '',
}

export default Banner
57 changes: 11 additions & 46 deletions react/Carousel.tsx
@@ -1,5 +1,4 @@
import classnames from 'classnames'
import PropTypes from 'prop-types'
import React, { useState } from 'react'
import { Dots, Slide, Slider, SliderContainer } from 'vtex.slider'
import { Container } from 'vtex.store-components'
Expand Down Expand Up @@ -52,16 +51,23 @@ const CSS_HANDLES = [
'containerDots',
] as const

function Carousel(props: Props) {
const { height, showArrows, autoplay, autoplaySpeed, showDots, banners: bannersProp } = props
const Carousel = (props: Props) => {
const {
height = 420,
autoplay = true,
showDots = true,
showArrows = true,
autoplaySpeed = 5,
banners: bannersProp
} = props
const [currentSlide, setCurrentSlide] = useState(0)
const handles = useCssHandles(CSS_HANDLES)

if (!bannersProp.length) {
return null
}

function ArrowRender({ orientation, onClick }: ArrowProps) {
const ArrowRender = ({ orientation, onClick }: ArrowProps) => {
const containerClasses = classnames(handles.arrow, 'pointer z-1 flex', {
[handles.arrowLeft]: orientation === 'left',
[handles.arrowRight]: orientation === 'right',
Expand All @@ -73,7 +79,7 @@ function Carousel(props: Props) {
)
}

function ArrowContainerRender({ children }: ArrowContainerProps) {
const ArrowContainerRender = ({ children }: ArrowContainerProps) => {
const wrapperClasses = classnames(
handles.arrowsContainerWrapper,
'w-100 h-100 absolute left-0 top-0 flex justify-center'
Expand Down Expand Up @@ -156,15 +162,6 @@ function Carousel(props: Props) {
)
}

Carousel.defaultProps = {
autoplay: true,
autoplaySpeed: 5,
banners: [],
height: 420,
showArrows: true,
showDots: true,
}

Carousel.getSchema = () => {
const internalRouteSchema = {
customInternalURL: {
Expand Down Expand Up @@ -309,36 +306,4 @@ Carousel.getSchema = () => {
}
}

Carousel.propTypes = {
/** Should change images automatically */
autoplay: PropTypes.bool.isRequired,
/** How long it should wait to change the banner in secs */
autoplaySpeed: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/** Banners that will be displayed by the Carousel */
banners: PropTypes.arrayOf(
PropTypes.shape({
/** The url where the image is pointing to, in case of internal route */
customInternalURL: PropTypes.string,
/** The description of the image */
description: PropTypes.string,
/** The image url of the banner */
image: PropTypes.string,
/** The page where the image is pointing to */
page: PropTypes.string,
/** Params of the url */
params: PropTypes.string,
/** Indicates if the route is external or internal */
typeOfRoute: PropTypes.string,
/** The url where the image is pointing to, in case of external route */
url: PropTypes.string,
})
),
/** Max height size of the banners */
height: PropTypes.number.isRequired,
/** Set visibility of arrows */
showArrows: PropTypes.bool,
/** Set visibility of dots */
showDots: PropTypes.bool,
}

export default Carousel
1 change: 0 additions & 1 deletion react/package.json
Expand Up @@ -19,7 +19,6 @@
"devDependencies": {
"@types/classnames": "^2.2.7",
"@types/node": "^10.12.21",
"@types/prop-types": "^15.5.8",
"@types/react": "^16.8.1",
"@vtex/test-tools": "^0.2.0",
"coveralls": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion react/yarn.lock
Expand Up @@ -1009,7 +1009,7 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.22.tgz#91ee88ebfa25072433497f6f3150f84fa8c3a91b"
integrity sha512-rOsaPRUGTOXbRBOKToy4cgZXY4Y+QSVhxcLwdEveozbk7yuudhWMpxxcaXqYizLMP3VY7OcWCFtx9lGFh5j5kg==

"@types/prop-types@*", "@types/prop-types@^15.5.8", "@types/prop-types@^15.7.0":
"@types/prop-types@*", "@types/prop-types@^15.7.0":
version "15.7.3"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
Expand Down

0 comments on commit 5aa2b0a

Please sign in to comment.