From 28f0e55475ecac41034e3fac8c48ea0a332d364c Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Wed, 13 May 2020 23:34:12 -0700 Subject: on new paste modal --- frontend/src/components/Inputs.js | 39 ++++++++++--- frontend/src/components/NewPaste.js | 11 +--- frontend/src/components/PasswordModal.js | 75 ------------------------- frontend/src/components/ViewPaste.js | 2 +- frontend/src/components/modals/PasswordModal.js | 62 ++++++++++++++++++++ frontend/src/components/modals/PasteModal.js | 69 +++++++++++++++++++++++ frontend/src/components/modals/shared.js | 13 +++++ 7 files changed, 178 insertions(+), 93 deletions(-) delete mode 100644 frontend/src/components/PasswordModal.js create mode 100644 frontend/src/components/modals/PasswordModal.js create mode 100644 frontend/src/components/modals/PasteModal.js create mode 100644 frontend/src/components/modals/shared.js (limited to 'frontend/src/components') diff --git a/frontend/src/components/Inputs.js b/frontend/src/components/Inputs.js index da540d0..4bb7b33 100644 --- a/frontend/src/components/Inputs.js +++ b/frontend/src/components/Inputs.js @@ -4,7 +4,7 @@ import styled from 'styled-components' import FloatingLabel from './decorators/FloatingLabel' import Dropdown from 'react-dropdown'; -const CharLimitContainer = styled.div` +const RelPositioning = styled.div` position: relative; ` @@ -16,7 +16,7 @@ const FlexChild = styled.div` class TitleInput extends React.Component { render() { return ( - + - + ); } } @@ -43,7 +43,7 @@ class TitleInput extends React.Component { class PasteInput extends React.Component { render() { return ( - + - + ); } } @@ -69,7 +69,7 @@ class PassInput extends React.Component { render() { return ( - + - + ); } @@ -127,4 +127,27 @@ class ExpiryInput extends React.Component { } } -export { TitleInput, PasteInput, PassInput, ExpiryInput } \ No newline at end of file +class PasteURLInput extends React.Component { + render() { + return ( + + + + + + + ); + } +} + +export { TitleInput, PasteInput, PassInput, ExpiryInput, PasteURLInput } \ No newline at end of file diff --git a/frontend/src/components/NewPaste.js b/frontend/src/components/NewPaste.js index f48f48b..0b1c795 100644 --- a/frontend/src/components/NewPaste.js +++ b/frontend/src/components/NewPaste.js @@ -1,9 +1,9 @@ import React from 'react'; import { TitleInput, PasteInput } from './Inputs' import OptionsContainer from './Options' -import { Redirect } from 'react-router-dom' import Error from './Err' import { PostNewPaste } from '../helpers/httpHelper' +import PasteModal from './modals/PasteModal' class NewPaste extends React.Component { constructor(props) { @@ -22,13 +22,6 @@ class NewPaste extends React.Component { this.ErrorLabel = React.createRef(); } - renderRedirect = () => { - if (this.state.hash !== '') { - const redirUrl = `/${this.state.hash}` - return - } - } - componentDidUpdate() { if (this.state.title === "") { document.title = `ctrl-v`; @@ -69,7 +62,7 @@ class NewPaste extends React.Component { render() { return (
- {this.renderRedirect()} + - - - 🚧 err: password protected - - - - - - - - - - - ); - } -} - -export default PasswordModal \ No newline at end of file diff --git a/frontend/src/components/ViewPaste.js b/frontend/src/components/ViewPaste.js index 7232825..835deaf 100644 --- a/frontend/src/components/ViewPaste.js +++ b/frontend/src/components/ViewPaste.js @@ -2,7 +2,7 @@ import React from 'react'; import Error from './Err'; import { TitleInput, PasteInput } from './Inputs'; import PasteInfo from './PasteInfo'; -import PasswordModal from './PasswordModal' +import PasswordModal from './modals/PasswordModal' import { FetchPaste, FetchPasswordPaste } from '../helpers/httpHelper' const RENDER_MODES = Object.freeze({ diff --git a/frontend/src/components/modals/PasswordModal.js b/frontend/src/components/modals/PasswordModal.js new file mode 100644 index 0000000..619e60a --- /dev/null +++ b/frontend/src/components/modals/PasswordModal.js @@ -0,0 +1,62 @@ +import React from 'react'; +import Modal from 'react-modal'; +import { PassInput } from '../Inputs' +import { RightPad, LeftPad, ModalHeader } from './shared' +import Error from '../Err'; + +const modalStyles = { + content: { + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '400px', + height: '250px', + border: '1px solid #11111188' + } +}; + +class PasswordModal extends React.Component { + + componentWillMount() { + Modal.setAppElement('body'); + } + + constructor(props) { + super(props); + this.submitPassword = this.submitPassword.bind(this); + this.ErrorLabel = React.createRef(); + } + + submitPassword(event) { + const password = this.props.value + this.props.validateCallback(password) + event.preventDefault(); + } + + render() { + return( + +
+ + 🚧 err: password protected + + + + + + + + +
+
+ ); + } +} + +export default PasswordModal \ No newline at end of file diff --git a/frontend/src/components/modals/PasteModal.js b/frontend/src/components/modals/PasteModal.js new file mode 100644 index 0000000..75c28a8 --- /dev/null +++ b/frontend/src/components/modals/PasteModal.js @@ -0,0 +1,69 @@ +import React from 'react'; +import Modal from 'react-modal'; +import { LeftPad, ModalHeader, RightPad } from './shared' +import { useHistory } from 'react-router-dom'; +import { PasteURLInput } from '../Inputs' +import { useClipboard } from 'use-clipboard-copy'; + +const modalStyles = { + content: { + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '500px', + height: '250px', + border: '1px solid #11111188' + } +}; + +const PasteModal = (props) => { + const history = useHistory(); + const fullURL = `${window.location.href}${props.hash}`; + const clipboard = useClipboard({ copiedTimeout: 3000 }); + Modal.setAppElement('body'); + + const redir = () => { + const redirUrl = `/${props.hash}` + history.push(redirUrl); + } + + return ( + +
+ + 📎 paste created + + + + + + + + + +
+
+ ); +} + +export default PasteModal \ No newline at end of file diff --git a/frontend/src/components/modals/shared.js b/frontend/src/components/modals/shared.js new file mode 100644 index 0000000..9359436 --- /dev/null +++ b/frontend/src/components/modals/shared.js @@ -0,0 +1,13 @@ +import styled from 'styled-components' + +export const RightPad = styled.div` + margin-right: 3em; +` + +export const LeftPad = styled.div` + margin-left: 2em; +` + +export const ModalHeader = styled.h3` + font-weight: 700 +` -- cgit v1.2.3