-
Notifications
You must be signed in to change notification settings - Fork 55
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 #51 from Videodock/feat/trailer
Feat / trailer
- Loading branch information
Showing
17 changed files
with
248 additions
and
165 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,36 @@ | ||
@use '../../styles/variables'; | ||
@use '../../styles/theme'; | ||
|
||
.overlay { | ||
position: fixed; | ||
width: 100vw; | ||
height: 100vh; | ||
left: 0px; | ||
top: 0px; | ||
z-index: 1; | ||
} | ||
.backdrop { | ||
width: inherit; | ||
height: inherit; | ||
background: rgba(0, 0, 0, 0.6); | ||
} | ||
.modalContainer { | ||
position: absolute; | ||
top: 0px; | ||
left: 0px; | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.modal { | ||
position: relative; | ||
width: 80vw; | ||
background-color: rgba(0, 0, 0, 0.9); | ||
} | ||
.close { | ||
position: absolute; | ||
right: 30px; | ||
top: 30px; | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import Modal from './Modal'; | ||
|
||
describe('<Modal>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render( | ||
<Modal onClose={jest.fn()}> | ||
<p>Test modal</p> | ||
</Modal>, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,43 @@ | ||
import React, { ReactFragment, useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import IconButton from '../IconButton/IconButton'; | ||
import Close from '../../icons/Close'; | ||
|
||
import styles from './Modal.module.scss'; | ||
|
||
type Props = { | ||
onClose: () => void; | ||
children: ReactFragment; | ||
}; | ||
|
||
const Modal: React.FC<Props> = ({ onClose, children }: Props) => { | ||
const { t } = useTranslation('common'); | ||
|
||
useEffect(() => { | ||
const onKeyDown = (event: KeyboardEvent) => event.keyCode === 27 && onClose(); | ||
|
||
document.body.style.overflow = 'hidden'; | ||
document.addEventListener('keydown', onKeyDown); | ||
return () => { | ||
document.body.style.overflow = 'scroll'; | ||
document.removeEventListener('keydown', onKeyDown); | ||
}; | ||
}, [onClose]); | ||
|
||
return ( | ||
<div className={styles.overlay} onClick={onClose}> | ||
<div className={styles.backdrop} /> | ||
<div className={styles.modalContainer}> | ||
<div className={styles.modal} onClick={(event) => event.stopPropagation()}> | ||
<IconButton onClick={onClose} aria-label={t('close_modal')} className={styles.close}> | ||
<Close /> | ||
</IconButton> | ||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Modal; |
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,48 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Modal> renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="overlay" | ||
> | ||
<div | ||
class="backdrop" | ||
/> | ||
<div | ||
class="modalContainer" | ||
> | ||
<div | ||
class="modal" | ||
> | ||
<div | ||
aria-label="close_modal" | ||
class="iconButton close" | ||
role="button" | ||
tabindex="0" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="icon" | ||
focusable="false" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<g> | ||
<path | ||
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" | ||
/> | ||
<path | ||
d="M0 0h24v24H0z" | ||
fill="none" | ||
/> | ||
</g> | ||
</svg> | ||
</div> | ||
<p> | ||
Test modal | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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
Oops, something went wrong.