diff --git a/src/components/LoginModal/LoginModal.tsx b/src/components/LoginModal/LoginModal.tsx new file mode 100644 index 00000000..4c2e1955 --- /dev/null +++ b/src/components/LoginModal/LoginModal.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import Portal from '../../Portal' + +import Modal from '../Modal/Modal' +import Overlay from '../Overlay/Overlay' + +const LoginModal = ({ close }) => { + return ( + +
+ + + + + + +
+
+ ) +} + +export default LoginModal \ No newline at end of file diff --git a/src/components/Modal/Modal.css b/src/components/Modal/Modal.css new file mode 100644 index 00000000..40358135 --- /dev/null +++ b/src/components/Modal/Modal.css @@ -0,0 +1,57 @@ +.ModalContainer { + display: flex; + align-items: center; + justify-content: center; + + width: 100%; + height: 100%; + + position: absolute; + left: 0; + top: 0; +} + +.Modal { + background: #f5f5f5; + border-radius: 8px; + display: flex; + flex-direction: column; + max-height: 600px; + min-width: 360px; + max-width: 480px; + padding: 24px; + position: relative; + z-index: 10; +} + +.Modal > .Input { + -webkit-font-smoothing: antialiased; + border: none; + + background-color: white; + border-radius: 6px; + color: #555; + display: block; + font-size: 18px; + margin-bottom: 8px; + padding: 12px 0; + text-align: center; +} + +.Modal > .Button { + background: #61B3FF; + color: #315E87; + display: block; + min-height: 45px; + text-align: center; +} + +.Modal > .Button:hover { + background: #4B9BE5; + color: #233E56; +} + +::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: #a9a9a9 !important; + opacity: 1; /* Firefox */ + } \ No newline at end of file diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx new file mode 100644 index 00000000..4879b5ba --- /dev/null +++ b/src/components/Modal/Modal.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import classnames from 'classnames' + +import './Modal.css' + +interface Props { + styleName?: string +} + +class Modal extends React.Component { + render() { + return ( +
+
+ {this.props.children} +
+
+ ) + } +} + +export default Modal \ No newline at end of file diff --git a/src/components/Overlay/Overlay.css b/src/components/Overlay/Overlay.css new file mode 100644 index 00000000..1895992e --- /dev/null +++ b/src/components/Overlay/Overlay.css @@ -0,0 +1,12 @@ +.Overlay { + background: black; + position: absolute; + opacity: 0.28; + + height: 100%; + width: 100%; + + top: 0; + left: 0; + z-index: 2; +} \ No newline at end of file diff --git a/src/components/Overlay/Overlay.tsx b/src/components/Overlay/Overlay.tsx new file mode 100644 index 00000000..18f7e0e8 --- /dev/null +++ b/src/components/Overlay/Overlay.tsx @@ -0,0 +1,8 @@ +import React from 'react' +import './Overlay.css' + +const Overlay = ({ onClick }) => ( +
+) + +export default Overlay \ No newline at end of file diff --git a/src/components/SearchModal/SearchModal.css b/src/components/SearchModal/SearchModal.css new file mode 100644 index 00000000..d0829718 --- /dev/null +++ b/src/components/SearchModal/SearchModal.css @@ -0,0 +1,9 @@ +.SearchModal { + min-height: 320px; + min-width: 600px; +} + +.SearchModal > .Input { + padding: 12px 8px; + text-align: left; +} \ No newline at end of file diff --git a/src/components/SearchModal/SearchModal.tsx b/src/components/SearchModal/SearchModal.tsx new file mode 100644 index 00000000..3e93dc4c --- /dev/null +++ b/src/components/SearchModal/SearchModal.tsx @@ -0,0 +1,94 @@ +import React from 'react' +import { v1 as uuidv1 } from 'uuid' + +import Portal from '../../Portal' + +import Modal from '../Modal/Modal' +import Overlay from '../Overlay/Overlay' + +import './SearchModal.css' + +interface Props { + close: () => void + placeholderText: string +} + +interface State { + query: string, + results: { [key: string]: any } + isLoaded: boolean + message: string +} + +class SearchModal extends React.Component { + searchQuery + + constructor(props) { + super(props) + this.state = { + query: '', + results: {}, + isLoaded: false, + message: '' + } + } + + fetchResults = (query) => { + fetch(`http://127.0.0.1:3000/api/v1/search?query=${query}`) + .then(res => res.json()) + .then((result) => { + // console.log("hello world!") + console.log(result) + // this.setState({ + // isLoaded: true, + // results: result + // }) + }, (error) => { + // this.setState({ + // isLoaded: true, + // message: error + // }) + }) + } + + inputChanged = (event) => { + const query = this.searchQuery.value + if (query.length > 2) { + console.log(query) + this.fetchResults(query) + } + + // if (query) { + // this.setState({ query, isLoaded: true, message: '' }, () => { + // // this.fetchResults(query) + // }) + // } else { + // this.setState({ query, results: {}, message: '' }) + // } + } + + render() { + const { query, isLoaded, message } = this.state + + return ( + + + this.searchQuery = el} + onChange={this.inputChanged} + placeholder={this.props.placeholderText} + /> + + + + ) + } +} + +export default SearchModal \ No newline at end of file diff --git a/src/components/SignupModal/SignupModal.tsx b/src/components/SignupModal/SignupModal.tsx new file mode 100644 index 00000000..aba50542 --- /dev/null +++ b/src/components/SignupModal/SignupModal.tsx @@ -0,0 +1,24 @@ +import React from 'react' +import Portal from '../../Portal' + +import Modal from '../Modal/Modal' +import Overlay from '../Overlay/Overlay' + +const SignupModal = ({ close }) => { + return ( + +
+ + + + + + + + +
+
+ ) +} + +export default SignupModal \ No newline at end of file diff --git a/src/components/UnauthMenu/UnauthMenu.tsx b/src/components/UnauthMenu/UnauthMenu.tsx index 523cf107..3f67d14b 100644 --- a/src/components/UnauthMenu/UnauthMenu.tsx +++ b/src/components/UnauthMenu/UnauthMenu.tsx @@ -1,8 +1,15 @@ import React from 'react' import './UnauthMenu.css' +import LoginModal from '../LoginModal/LoginModal' +import SignupModal from '../SignupModal/SignupModal' + +import { useModal as useSignupModal } from '../../useModal' +import { useModal as useLoginModal } from '../../useModal' function UnauthMenu() { + const { open: signupOpen, openModal: openSignupModal, closeModal: closeSignupModal } = useSignupModal() + const { open: loginOpen, openModal: openLoginModal, closeModal: closeLoginModal } = useLoginModal() return (
    @@ -12,7 +19,16 @@ function UnauthMenu() {
  • Log in
  • + {loginOpen ? ( + + ) : null}
  • Sign up
  • + {signupOpen ? ( + ) : null}
    diff --git a/src/useModal.ts b/src/useModal.ts new file mode 100644 index 00000000..78c43ffd --- /dev/null +++ b/src/useModal.ts @@ -0,0 +1,17 @@ +import { useState } from 'react' + +export const useModal = () => { + const [open, onOpenModal] = useState(false) + const [close, onCloseModal] = useState(false) + + const openModal = () => { + onOpenModal(true) + } + + const closeModal = () => { + onCloseModal(true) + onOpenModal(false) + } + + return { open, close, openModal, closeModal } +}