diff --git a/components/CharacterGrid/index.scss b/components/CharacterGrid/index.scss index be6aa48e..42ec275b 100644 --- a/components/CharacterGrid/index.scss +++ b/components/CharacterGrid/index.scss @@ -11,6 +11,7 @@ margin: 0; padding: 0; max-width: 761px; + isolation: isolate; @include breakpoint(tablet) { justify-content: space-between; diff --git a/components/JobSection/index.scss b/components/JobSection/index.scss index 6d95238b..ed393f57 100644 --- a/components/JobSection/index.scss +++ b/components/JobSection/index.scss @@ -45,6 +45,7 @@ box-sizing: border-box; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); display: block; + isolation: isolate; flex-grow: 2; flex-shrink: 0; height: $height; diff --git a/components/Overlay/index.scss b/components/Overlay/index.scss new file mode 100644 index 00000000..6059c821 --- /dev/null +++ b/components/Overlay/index.scss @@ -0,0 +1,13 @@ +.Overlay { + isolation: isolate; + position: fixed; + z-index: 30; + top: 0; + right: 0; + bottom: 0; + left: 0; + + &.Visible { + background: rgba(0, 0, 0, 0.6); + } +} diff --git a/components/Overlay/index.tsx b/components/Overlay/index.tsx new file mode 100644 index 00000000..2cb360f7 --- /dev/null +++ b/components/Overlay/index.tsx @@ -0,0 +1,52 @@ +import React, { useEffect, useState } from 'react' +import classNames from 'classnames' +import './index.scss' + +interface Props { + visible: boolean + open: boolean +} + +const defaultProps = { + visible: true, +} + +const Overlay = ({ + visible: displayed, + open, +}: { + visible: boolean + open: boolean +}) => { + const [visible, setVisible] = useState(open) + + const classes = classNames({ + Overlay: true, + Visible: displayed, + }) + + useEffect(() => { + if (!open) { + console.log('No longer open, setting timeout...') + const timer = setTimeout(() => { + console.log('Timeout cleared!') + setVisible(false) + }, 200) + return () => { + clearTimeout(timer) + } + } + setVisible(true) + return () => {} + }, [open]) + + function handleClick(event: React.MouseEvent) { + event.stopPropagation() + } + + return visible ?
: null +} + +Overlay.defaultProps = defaultProps + +export default Overlay diff --git a/components/Select/index.tsx b/components/Select/index.tsx index 5321a9cc..82643d75 100644 --- a/components/Select/index.tsx +++ b/components/Select/index.tsx @@ -5,6 +5,7 @@ import classNames from 'classnames' import ArrowIcon from '~public/icons/Arrow.svg' import './index.scss' +import Overlay from '~components/Overlay' // Props interface Props @@ -76,19 +77,24 @@ const Select = React.forwardRef(function Select( - - - - - {props.children} - - - - + <> + + + + + + + {props.children} + + + + + ) diff --git a/styles/globals.scss b/styles/globals.scss index 5288caee..562d7797 100644 --- a/styles/globals.scss +++ b/styles/globals.scss @@ -119,16 +119,6 @@ select { } } -.Overlay { - background: rgba(0, 0, 0, 0.6); - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 20; -} - .Hovercard { background: #222; border-radius: $unit;