aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/modals
diff options
context:
space:
mode:
authorRyan Mehri <[email protected]>2020-05-14 12:55:40 -0600
committerGitHub <[email protected]>2020-05-14 12:55:40 -0600
commitfcadb1bf21403f357e48542fd94c78828044e07b (patch)
tree421ab164e447c63cb163aff4f081072385d8ca4f /frontend/src/components/modals
parentMerge pull request #20 from jackyzha0/pass-rendering (diff)
parenton new paste modal (diff)
downloadctrl-v-fcadb1bf21403f357e48542fd94c78828044e07b.tar.xz
ctrl-v-fcadb1bf21403f357e48542fd94c78828044e07b.zip
Merge pull request #22 from jackyzha0/paste-modal
on new paste modal
Diffstat (limited to 'frontend/src/components/modals')
-rw-r--r--frontend/src/components/modals/PasswordModal.js62
-rw-r--r--frontend/src/components/modals/PasteModal.js69
-rw-r--r--frontend/src/components/modals/shared.js13
3 files changed, 144 insertions, 0 deletions
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(
+ <Modal
+ isOpen={this.props.hasPass && !this.props.validPass}
+ style={modalStyles}
+ contentLabel="enter paste password"
+ >
+ <form onSubmit={this.submitPassword}>
+ <LeftPad>
+ <ModalHeader><span role="img" aria-label="warning">🚧&nbsp;</span>err: password protected</ModalHeader>
+ </LeftPad>
+ <RightPad>
+ <PassInput
+ value={this.props.value}
+ onChange={this.props.onChange} />
+ </RightPad>
+ <LeftPad>
+ <input className="lt-button lt-shadow lt-hover" type="submit" value="continue" />
+ <Error ref={this.ErrorLabel} />
+ </LeftPad>
+ </form>
+ </Modal>
+ );
+ }
+}
+
+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 (
+ <Modal
+ isOpen={props.hash !== ''}
+ style={modalStyles}
+ contentLabel="paste created"
+ >
+ <form onSubmit={redir}>
+ <LeftPad>
+ <ModalHeader><span role="img" aria-label="success">📎&nbsp;</span>paste created</ModalHeader>
+ </LeftPad>
+ <RightPad>
+ <PasteURLInput
+ id="paste_modal"
+ fullURL={fullURL} />
+ <input
+ hidden
+ type="text"
+ value={fullURL}
+ readOnly
+ ref={clipboard.target} />
+ </RightPad>
+ <LeftPad>
+ <button
+ className="lt-button lt-shadow lt-hover"
+ type="submit">
+ view
+ </button>
+ <button
+ className="lt-button lt-shadow lt-hover"
+ type="button"
+ onClick={clipboard.copy}>
+ {clipboard.copied ? 'copied' : 'copy url'}
+ </button>
+ </LeftPad>
+ </form>
+ </Modal>
+ );
+}
+
+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
+`