-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d5e63c
commit 873aef6
Showing
40 changed files
with
2,159 additions
and
86 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { IconContext } from 'react-icons/lib'; | ||
import { BiHomeAlt, BiSearch, BiMessageAdd, BiHeart} from 'react-icons/bi'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
export default function Footer() { | ||
|
||
return ( | ||
<footer className="footer"> | ||
<IconContext.Provider value={{ className: 'icon' }}> | ||
<NavLink className="link" to="/"><BiHomeAlt /></NavLink> | ||
{/* <BiHomeAlt /> */} | ||
<BiSearch /> | ||
<NavLink className="link" to="/addpost"><BiMessageAdd /></NavLink> | ||
<NavLink className="link" to="/following"><BiHeart /></NavLink> | ||
</IconContext.Provider> | ||
</footer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { useContext } from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
import { BiUser } from 'react-icons/bi'; | ||
import { IconContext } from 'react-icons/lib'; | ||
import { IsLoggedContext } from '../../../shared/contexts/IsLoggedContext'; | ||
|
||
|
||
export default function Header() { | ||
|
||
const { isLogged } = useContext(IsLoggedContext); | ||
|
||
return ( | ||
<header className="header"> | ||
<h1 className="header__logo">inBlog</h1> | ||
<nav className="header__nav nav"> | ||
{isLogged && <IconContext.Provider value={{ className: 'nav__icon icon' }}> | ||
<NavLink to="/me"><BiUser /></NavLink> | ||
</IconContext.Provider>} | ||
</nav> | ||
</header> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { useContext } from 'react'; | ||
import { LoaderContext } from './context/LoaderContext'; | ||
|
||
|
||
export default function Loader() { | ||
|
||
const {isLoading} = useContext(LoaderContext); | ||
|
||
return ( | ||
isLoading && <div className="c-loader"> | ||
<div className="lds-default"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import React from 'react'; | ||
|
||
export const LoaderContext = React.createContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useContext } from 'react'; | ||
import { Switch, Route, Redirect } from 'react-router-dom'; | ||
import HomePage from '../../pages/HomePage/HomePage'; | ||
import UserPage from '../../pages/UserPage/UserPage'; | ||
import SignInPage from '../../pages/SignInPage/SignInPage'; | ||
import SignUpPage from '../../pages/SignUpPage/SignUpPage'; | ||
import LandingPage from '../../pages/LandingPage/LandingPage'; | ||
import AddPost from '../../pages/AddPost/AddPost'; | ||
import Following from '../../pages/Following/Following'; | ||
import Error404 from '../../pages/Error404/Error404'; | ||
import { IsLoggedContext } from '../../shared/contexts/IsLoggedContext'; | ||
|
||
export default function Routes() { | ||
|
||
const { isLogged } = useContext(IsLoggedContext); | ||
return ( | ||
<Switch> | ||
<Route path="/following"> | ||
{ !isLogged ? <LandingPage /> : <Following />} | ||
</Route> | ||
<Route path="/addpost"> | ||
{ !isLogged ? <LandingPage /> : <AddPost />} | ||
</Route> | ||
<Route path="/signup"> | ||
<SignUpPage /> | ||
</Route> | ||
<Route path="/signin"> | ||
<SignInPage /> | ||
</Route> | ||
<Route path="/me"> | ||
{ !isLogged ? <LandingPage /> : <UserPage />} | ||
</Route> | ||
<Route exact path="/"> | ||
{ isLogged ? <HomePage /> : <LandingPage />} | ||
</Route> | ||
<Route> | ||
<Error404 /> | ||
</Route> | ||
</Switch> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function fixHeight () { | ||
const section$$ = document.querySelector('.section'); | ||
const height = window.innerHeight; | ||
if (section$$) { | ||
section$$.style.minHeight = `${ height - 120 }px`; | ||
section$$.style.transition = `min-height 0.5s`; | ||
} | ||
window.addEventListener('resize', fixHeight) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import './styles/imports/settings.import'; | ||
@import './styles/imports/generics.import'; | ||
@import './styles/imports/elements.import'; | ||
@import './styles/imports/blocks.import'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import axios from 'axios'; | ||
import React, { useState } from 'react'; | ||
import { useToasts } from 'react-toast-notifications'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
|
||
export default function AddPost() { | ||
|
||
const [ title, setTitle ] = useState(''); | ||
const [ body, setBody ] = useState(''); | ||
const [ photo, setPhoto ] = useState(''); | ||
|
||
const { addToast } = useToasts(); | ||
const history = useHistory(); | ||
|
||
const path = 'assets/images/default-image.jpg'; | ||
|
||
const post = { | ||
title: title, | ||
body: body, | ||
photo: photo | ||
} | ||
|
||
const config = {headers: {Authorization: `Bearer ${localStorage.getItem('token')}`}} | ||
|
||
const handleImageError = (el) => { | ||
el.src = path; | ||
} | ||
|
||
const handleImageUplaod = (e) => { | ||
const image = e.target.files[0]; | ||
const data = new FormData(); | ||
data.append('file', image); | ||
data.append('upload_preset', 'inBlog'); | ||
data.append('cloud_name', 'tamasigerald'); | ||
axios.post('https://api.cloudinary.com/v1_1/tamasigerald/image/upload', data) | ||
.then(function(res) { | ||
setPhoto(res.data.secure_url); | ||
}) | ||
.catch(function(err) { | ||
console.log(err); | ||
}) | ||
} | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
axios.post('/createpost', post, config) | ||
.then(function(res) { | ||
addToast(res.data.message, { appearance: 'success', autoDismiss: true }); | ||
setTimeout(() => { history.push('/') }, 1500) | ||
}) | ||
.catch(function(err) { | ||
if(err.response) { | ||
addToast(err.response.data.error, { appearance: 'error', autoDismiss: true }); | ||
} | ||
}) | ||
} | ||
|
||
return ( | ||
<section className="section section--addpost"> | ||
<header className="section__header section__header--addpost"> | ||
<figure className="section__figure"> | ||
<img className="section__photo section__photo--addpost" onError={(e) => {handleImageError(e.target)}} src={post.photo || path} alt="test"/> | ||
</figure> | ||
</header> | ||
<article className="section__content section__content--addpost"> | ||
<form className="section__form" onSubmit={(e) => {handleSubmit(e)}}> | ||
<input className="section__form__input" type="text" name="title" placeholder="title" onChange={(e) => {setTitle(e.target.value)}}/> | ||
<div className="upload"> | ||
<input className="section__form__input section__form__input--file upload--file" type='file' name="photo" placeholder="photo" onChange={(e) => {handleImageUplaod(e)}}/> | ||
<button type="button" className="btn btn--primary btn--file">Upload file</button> | ||
</div> | ||
<textarea className="section__form__input" type="text" name="body" placeholder="body" onChange={(e) => {setBody(e.target.value)}}/> | ||
<button type="submit" className="btn btn--success btn--form">Post</button> | ||
</form> | ||
</article> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
export default function Error404() { | ||
|
||
const history = useHistory(); | ||
|
||
const handleClick = (route) => { | ||
history.push(route); | ||
} | ||
|
||
return ( | ||
<section className="section section--error"> | ||
<header className="section__header"> | ||
<h2 className="section__title">Welcome to <span className="section__logo">inBlog</span></h2> | ||
<h3 className="section__subt">Made for real bloggers</h3> | ||
<p className="section__text">The page you are trying to reach was not found! Please, visit home page!</p> | ||
<div className="section__btns"> | ||
<button className="btn btn--primary" onClick={() => {handleClick('/')}}>Home</button> | ||
</div> | ||
</header> | ||
</section> | ||
) | ||
} |
Oops, something went wrong.