--
This commit is contained in:
parent
3cd5d356cb
commit
25f973e2b3
37 changed files with 812 additions and 470 deletions
59
frontend/src/components/ImageUpload.jsx
Normal file
59
frontend/src/components/ImageUpload.jsx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import React, { useState } from 'react';
|
||||
import {
|
||||
Button, Container, Form, InputGroup,
|
||||
} from 'react-bootstrap';
|
||||
import { CSSTransition } from 'react-transition-group';
|
||||
import putImgHandler from '../axios/putImgHandler';
|
||||
|
||||
export default () => {
|
||||
const [file, setFile] = useState(null);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [resultUrl, setResultUrl] = useState(null);
|
||||
|
||||
const submit = (evt) => {
|
||||
evt.preventDefault();
|
||||
if (file && file.name.length) {
|
||||
setLoading(true);
|
||||
putImgHandler(file).then((data) => {
|
||||
setResultUrl(`http://${window.location.host}/i/${data}`.replace('5000', '3000'));
|
||||
setLoading(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<CSSTransition classNames="react-router" appear in timeout={300}>
|
||||
<Container className="perfect-width v-center">
|
||||
<h2 className="text-center py-3">Image Uploader</h2>
|
||||
|
||||
<Form onSubmit={submit} className="perfect-width">
|
||||
<Form.Group>
|
||||
<InputGroup>
|
||||
<Form.File
|
||||
custom
|
||||
required
|
||||
id="image"
|
||||
accept="image/*"
|
||||
label={(file && file.name) || 'Choose an Image..'}
|
||||
onChange={(evt) => setFile(evt.target.files[0])}
|
||||
/>
|
||||
<InputGroup.Append>
|
||||
<Button type="submit" disabled={isLoading}>
|
||||
{isLoading ? 'Loading...' : 'Submit'}
|
||||
</Button>
|
||||
</InputGroup.Append>
|
||||
</InputGroup>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
|
||||
{resultUrl && (
|
||||
<h5 className="text-center">
|
||||
<a rel="noopener noreferrer" href={resultUrl} target="_blank">
|
||||
{resultUrl}
|
||||
</a>
|
||||
</h5>
|
||||
)}
|
||||
</Container>
|
||||
</CSSTransition>
|
||||
);
|
||||
};
|
||||
1
frontend/src/components/TextUpload.jsx
Normal file
1
frontend/src/components/TextUpload.jsx
Normal file
|
|
@ -0,0 +1 @@
|
|||
import React from 'react';
|
||||
58
frontend/src/components/UrlShortener.jsx
Normal file
58
frontend/src/components/UrlShortener.jsx
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import React, { useState } from 'react';
|
||||
import {
|
||||
InputGroup, Container, Form, Button,
|
||||
} from 'react-bootstrap';
|
||||
import { CSSTransition } from 'react-transition-group';
|
||||
import putUrlHandler from '../axios/putUrlHandler';
|
||||
|
||||
export default () => {
|
||||
const [state, setState] = useState('');
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [resultUrl, setResultUrl] = useState(null);
|
||||
|
||||
const submit = (evt) => {
|
||||
evt.preventDefault();
|
||||
if (state.length) {
|
||||
setLoading(true);
|
||||
putUrlHandler(state).then((data) => {
|
||||
setResultUrl(`http://${window.location.host}/u/${data}`.replace('5000', '3000'));
|
||||
setLoading(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<CSSTransition classNames="react-router" appear in timeout={300}>
|
||||
<Container className="perfect-width v-center">
|
||||
<h2 className="text-center py-3">URL Shortener</h2>
|
||||
|
||||
<Form onSubmit={submit} className="perfect-width">
|
||||
<Form.Group>
|
||||
<InputGroup>
|
||||
<Form.Control
|
||||
type="text"
|
||||
value={state.url}
|
||||
placeholder="URL To Shorten (https://...)"
|
||||
onChange={(evt) => setState(evt.target.value)}
|
||||
required
|
||||
/>
|
||||
<InputGroup.Append>
|
||||
<Button type="submit" disabled={isLoading}>
|
||||
{isLoading ? 'Loading...' : 'Submit'}
|
||||
</Button>
|
||||
</InputGroup.Append>
|
||||
</InputGroup>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
|
||||
{resultUrl && (
|
||||
<h5 className="text-center">
|
||||
<a rel="noopener noreferrer" href={resultUrl} target="_blank">
|
||||
{resultUrl}
|
||||
</a>
|
||||
</h5>
|
||||
)}
|
||||
</Container>
|
||||
</CSSTransition>
|
||||
);
|
||||
};
|
||||
18
frontend/src/components/modules/NavBar.jsx
Normal file
18
frontend/src/components/modules/NavBar.jsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { faCode, faImage, faLink } from '@fortawesome/free-solid-svg-icons';
|
||||
import React from 'react';
|
||||
import { Nav, Navbar } from 'react-bootstrap';
|
||||
import NavLinkItem from './NavLinkItem';
|
||||
|
||||
export default () => (
|
||||
<Navbar expand="lg" collapseOnSelect bg="dark" variant="dark" fixed="top">
|
||||
<Navbar.Brand>oitsjustjo.se</Navbar.Brand>
|
||||
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
|
||||
<Navbar.Collapse>
|
||||
<Nav className="mr-auto">
|
||||
<NavLinkItem name="URL" dest="/" icon={faLink} />
|
||||
<NavLinkItem name="Img" dest="/img" icon={faImage} />
|
||||
<NavLinkItem name="Paste" dest="/paste" icon={faCode} />
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Navbar>
|
||||
);
|
||||
18
frontend/src/components/modules/NavLinkItem.jsx
Normal file
18
frontend/src/components/modules/NavLinkItem.jsx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import React from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { NavItem } from 'react-bootstrap';
|
||||
|
||||
export default ({
|
||||
name, dest, icon,
|
||||
}) => (
|
||||
<NavItem>
|
||||
<NavLink exact className="nav-link" activeClassName="nav-link active" to={dest}>
|
||||
<span>
|
||||
{icon && (<FontAwesomeIcon icon={icon} />)}
|
||||
{' '}
|
||||
{name}
|
||||
</span>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
);
|
||||
Loading…
Reference in a new issue