-
Notifications
You must be signed in to change notification settings - Fork 0
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 #34 from 90lucasgabriel/feature/WJ-14
WJ-14 - New: Movie component;
- Loading branch information
Showing
22 changed files
with
218 additions
and
19 deletions.
There are no files selected for viewing
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
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,5 @@ | ||
import PopularProps from 'domains/Movie/api/Popular/Response'; | ||
|
||
export default interface Props extends PopularProps { | ||
isFavorite?: boolean; | ||
} |
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,32 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { BsHeartFill } from 'react-icons/bs'; | ||
|
||
import Route from 'routes/enums'; | ||
import { Color } from 'shared/enums'; | ||
import { Container, IconButton, Poster } from './styles'; | ||
|
||
import Props from './dtos'; | ||
|
||
const Movie: React.FC<Props> = ({ ...movie }) => { | ||
const history = useHistory(); | ||
const [isFavorite, setIsFavorite] = useState(false); | ||
|
||
const handleFavorite = useCallback(() => { | ||
setIsFavorite(!isFavorite); | ||
}, [isFavorite]); | ||
|
||
return ( | ||
<Container> | ||
<IconButton onClick={handleFavorite}> | ||
<BsHeartFill fill={isFavorite ? Color.Primary : Color.Empty} /> | ||
</IconButton> | ||
<Poster | ||
src={movie.poster} | ||
onClick={() => history.push(`${Route.MOVIE}/${movie.id}`)} | ||
/> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Movie; |
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,29 @@ | ||
import styled from 'styled-components'; | ||
import { PosterHeight, PosterWidth, Size } from 'shared/enums'; | ||
|
||
export const Container = styled.div` | ||
position: relative; | ||
width: ${PosterWidth.Default}; | ||
height: ${PosterHeight.Default}; | ||
border-radius: ${Size.Smallest}; | ||
overflow: hidden; | ||
`; | ||
|
||
export const IconButton = styled.button` | ||
position: absolute; | ||
right: ${Size.Smallest}; | ||
top: ${Size.Smallest}; | ||
background: transparent; | ||
border: none; | ||
svg { | ||
height: ${Size.Default}; | ||
width: ${Size.Default}; | ||
} | ||
`; | ||
|
||
export const Poster = styled.img` | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
`; |
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,6 @@ | ||
import DefaultProps from 'shared/dtos'; | ||
|
||
export default interface Props extends DefaultProps { | ||
title?: string; | ||
data: any[]; | ||
} |
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,32 @@ | ||
import React from 'react'; | ||
|
||
import { Wrapper } from 'components/Layout'; | ||
import Movie from 'containers/Movie'; | ||
import { Container, Title, ListContainer, ListContent } from './styles'; | ||
|
||
import Props from './dtos'; | ||
|
||
const MovieList: React.FC<Props> = ({ | ||
theme, | ||
background, | ||
color, | ||
title, | ||
data, | ||
}) => { | ||
return ( | ||
<Wrapper theme={theme} background={background} color={color}> | ||
<Container> | ||
{title && <Title>{title}</Title>} | ||
<ListContainer> | ||
<ListContent> | ||
{data.map(movie => ( | ||
<Movie key={movie.id} {...movie} /> | ||
))} | ||
</ListContent> | ||
</ListContainer> | ||
</Container> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default MovieList; |
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,51 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { Container as DefaultContainer } from 'components/Layout'; | ||
import { Size } from 'shared/enums'; | ||
|
||
export const Container = styled(DefaultContainer)` | ||
padding: ${Size.Medium} 0; | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const Title = styled.h2` | ||
margin-bottom: ${Size.Small}; | ||
margin-left: ${Size.Medium}; | ||
`; | ||
|
||
export const ListContainer = styled.div` | ||
/* overflow-x: hidden; | ||
&:hover { */ | ||
overflow-x: auto; | ||
/* } */ | ||
scroll-snap-type: x mandatory; | ||
-webkit-overflow-scrolling: touch; | ||
scroll-behavior: smooth; | ||
-ms-overflow-style: none; | ||
scrollbar-width: 10px; | ||
&::-webkit-scrollbar { | ||
/* visibility: visible; */ | ||
display: none; | ||
} | ||
`; | ||
|
||
export const ListContent = styled.div` | ||
display: inline-flex; | ||
margin-left: ${Size.Medium}; | ||
& > div { | ||
flex: 1 0 auto; | ||
scroll-snap-align: start; | ||
scroll-margin-left: ${Size.Large}; | ||
margin-right: ${Size.Medium}; | ||
@media (max-width: 915px) { | ||
scroll-margin-left: ${Size.Medium}; | ||
margin-right: ${Size.Smallest}; | ||
} | ||
} | ||
`; |
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
File renamed without changes.
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
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,5 @@ | ||
export default interface Props { | ||
theme?: string; | ||
background?: string; | ||
color?: string; | ||
} |
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,6 @@ | ||
enum PosterHeight { | ||
Default = '25.3rem', | ||
Large = '45.2rem', | ||
} | ||
|
||
export default PosterHeight; |
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,6 @@ | ||
enum PosterWidth { | ||
Default = '16.5rem', | ||
Large = '29.5rem', | ||
} | ||
|
||
export default PosterWidth; |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
enum Size { | ||
Smallest = '0.8rem', | ||
Smallest = '1rem', | ||
Small = '1.4rem', | ||
Default = '1.8rem', | ||
Medium = '2.4rem', | ||
|
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { default as Color } from './Color'; | ||
export { default as PosterHeight } from './PosterHeight'; | ||
export { default as PosterWidth } from './PosterWidth'; | ||
export { default as Size } from './Size'; |
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