-
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 #116 from 90lucasgabriel/feature/WJ-21
WJ-21 - Create Modal component
- Loading branch information
Showing
39 changed files
with
365 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import { SkeletonContainer } from './styles'; | ||
|
||
const AspectRatioLoading: React.FC = () => { | ||
return <SkeletonContainer />; | ||
}; | ||
|
||
export default AspectRatioLoading; |
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,8 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { Skeleton } from 'components'; | ||
|
||
export const SkeletonContainer = styled(Skeleton)` | ||
width: 100%; | ||
padding-top: 100%; | ||
`; |
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,19 @@ | ||
import React from 'react'; | ||
|
||
import Props from './types'; | ||
import { Container } from './styles'; | ||
|
||
const AspectRatio: React.FC<Props> = ({ | ||
width = 1, | ||
height = 1, | ||
borderRadius = '0', | ||
children, | ||
}) => { | ||
return ( | ||
<Container width={width} height={height} borderRadius={borderRadius}> | ||
{children} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default AspectRatio; |
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,21 @@ | ||
import styled from 'styled-components'; | ||
import Props from './types'; | ||
|
||
export const Container = styled.div<Props>` | ||
position: relative; | ||
width: 100%; | ||
padding-top: calc( | ||
(${props => props.height} / ${props => props.width}) * 100% | ||
); | ||
overflow: hidden; | ||
border-radius: ${props => props.borderRadius}; | ||
& > * { | ||
position: absolute; | ||
top: 0; | ||
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,5 @@ | ||
export default interface Props { | ||
width?: number; | ||
height?: number; | ||
borderRadius?: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const checkImageMedia = (media: string): boolean => { | ||
const imageExtensions = ['jpg', 'jpe', 'jpeg', 'png', 'gif']; | ||
|
||
return imageExtensions.some(extension => | ||
media.toUpperCase().endsWith(extension.toUpperCase()), | ||
); | ||
}; | ||
|
||
export default checkImageMedia; |
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 @@ | ||
export { default as checkImageMedia } from './checkImageMedia'; |
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,25 @@ | ||
import React from 'react'; | ||
|
||
import { checkImageMedia } from 'components/Media/helpers'; | ||
import { AspectRatio, AspectRatioLoading } from 'components'; | ||
import Props from './types'; | ||
|
||
import { LoadingContainer } from './styles'; | ||
|
||
const Media: React.FC<Props> = ({ src, ...rest }) => { | ||
return ( | ||
<AspectRatio {...rest}> | ||
{checkImageMedia(src) ? ( | ||
<img src={src} alt="media" /> | ||
) : ( | ||
<video src={src} autoPlay loop muted /> | ||
)} | ||
|
||
<LoadingContainer> | ||
<AspectRatioLoading /> | ||
</LoadingContainer> | ||
</AspectRatio> | ||
); | ||
}; | ||
|
||
export default Media; |
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,10 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const LoadingContainer = styled.div` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 100%; | ||
z-index: -1; | ||
`; |
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 AspectRatioProps from 'components/AspectRatio/types'; | ||
|
||
export default interface MediaProps extends AspectRatioProps { | ||
src: 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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import ModalContent from 'components/Modal/types/ModalContent'; | ||
import ModalProps from 'components/Modal/types/ModalProps'; | ||
import StyleProps from 'components/Modal/types/StyleProps'; | ||
|
||
export default interface ContextData { | ||
modalContent: any; | ||
setModalContent(params: ModalContent): void; | ||
modalProps: StyleProps; | ||
setModalContent(params: ModalProps): void; | ||
successCloseModal(): void; | ||
dismissModal(): void; | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import StyleProps from 'components/Modal/types/StyleProps'; | ||
|
||
export default interface ModalProps { | ||
value: any; | ||
callback?: any; | ||
dismissCallback?: any; | ||
props?: StyleProps; | ||
} |
Oops, something went wrong.