├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── assets │ ├── css │ │ └── style.css │ └── img │ │ ├── container.gif │ │ └── posts.gif ├── favicon.ico ├── index.html └── robots.txt └── src ├── App.js ├── components ├── adminContentHeader │ ├── AdminContentHeader.jsx │ └── admincontentheader.css ├── adminContentPosts │ ├── AdminContentPosts.jsx │ └── admincontentposts.css ├── adminNavbar │ ├── AdminNavbar.jsx │ └── adminnavbar.css ├── article │ ├── Article.jsx │ └── article.css ├── blogs │ ├── Blogs.jsx │ └── blogs.css ├── editor │ ├── Editor.jsx │ └── editor.css ├── loading │ ├── Loading.jsx │ └── loading.css ├── menu │ ├── Menu.jsx │ └── menu.css ├── post │ ├── Post.jsx │ └── post.css ├── sideMenuUser │ ├── SideMenuUser.jsx │ └── sidemenuuser.css └── topbar │ ├── Topbar.jsx │ └── topbar.css ├── config └── routes.js ├── context ├── ProtectedRoute.js └── UserContext.js ├── index.css ├── index.js ├── pages ├── addpost │ ├── AddPost.jsx │ └── addpost.css ├── dashboard │ ├── Dashboard.js │ └── dashboard.css ├── home │ ├── Home.js │ └── home.css ├── login │ ├── Login.js │ └── login.css └── pagenotfound │ ├── PageNotFound.js │ └── pagenotfound.css └── templates ├── Template.jsx └── template.css /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog-gracesoft-net", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.15.0", 7 | "@testing-library/react": "^11.2.7", 8 | "@testing-library/user-event": "^12.8.3", 9 | "axios": "^0.24.0", 10 | "formik": "^2.2.9", 11 | "react": "^17.0.2", 12 | "react-dom": "^17.0.2", 13 | "react-router-dom": "^6.0.2", 14 | "react-scripts": "4.0.3", 15 | "web-vitals": "^1.1.2", 16 | "yup": "^0.32.11" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test", 22 | "eject": "react-scripts eject" 23 | }, 24 | "eslintConfig": { 25 | "extends": [ 26 | "react-app", 27 | "react-app/jest" 28 | ] 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "proxy": "http://gracesoft.wuletaw" 43 | } 44 | -------------------------------------------------------------------------------- /public/assets/css/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | font-family: "Roboto", sans-serif; 4 | } 5 | 6 | body { 7 | background-color: #f9f6ec; 8 | } 9 | 10 | *, 11 | *:before, 12 | *:after { 13 | box-sizing: border-box; 14 | } 15 | 16 | h2 { 17 | font-family: 'Times New Roman', Times, serif; 18 | } 19 | 20 | .row { 21 | display: flex; 22 | } 23 | 24 | .col-1 { 25 | width: 8.33%; 26 | } 27 | .col-2 { 28 | width: 16.66%; 29 | } 30 | .col-3 { 31 | width: 25%; 32 | } 33 | .col-4 { 34 | width: 33.33%; 35 | } 36 | .col-5 { 37 | width: 41.66%; 38 | } 39 | .col-6 { 40 | width: 50%; 41 | } 42 | .col-6 { 43 | width: 50%; 44 | } 45 | .col-7 { 46 | width: 58.33%; 47 | } 48 | .col-8 { 49 | width: 66.66%; 50 | } 51 | .col-9 { 52 | width: 75%; 53 | } 54 | .col-10 { 55 | width: 83.33%; 56 | } 57 | .col-11 { 58 | width: 91.66%; 59 | } 60 | .col-12 { 61 | width: 100%; 62 | } 63 | 64 | .container { 65 | width: 100%; 66 | padding-right: var(--bs-gutter-x,.75rem); 67 | padding-left: var(--bs-gutter-x,.75rem); 68 | margin-right: auto; 69 | margin-left: auto; 70 | } 71 | 72 | @media only screen and (min-width: 1400px) { 73 | .container { 74 | max-width: 1320px; 75 | } 76 | } 77 | 78 | @media only screen and (min-width: 1200px) and (max-width: 1400px) { 79 | .container { 80 | max-width: 1140px; 81 | } 82 | } 83 | 84 | @media only screen and (min-width: 992px) and (max-width: 1200px) { 85 | .container { 86 | max-width: 960px; 87 | } 88 | } 89 | 90 | @media only screen and (min-width: 768px) and (max-width: 992px) { 91 | .container { 92 | max-width: 720px; 93 | } 94 | } 95 | 96 | @media only screen and (min-width: 576px) and (max-width: 768px) { 97 | .container { 98 | max-width: 540px; 99 | } 100 | 101 | [class*="col-"] { 102 | width: 100%; 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /public/assets/img/container.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuletawwonte/react-blog-wordpress/64c04c898311b9c15ee4cfc77562b1bd4eddf46e/public/assets/img/container.gif -------------------------------------------------------------------------------- /public/assets/img/posts.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuletawwonte/react-blog-wordpress/64c04c898311b9c15ee4cfc77562b1bd4eddf46e/public/assets/img/posts.gif -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuletawwonte/react-blog-wordpress/64c04c898311b9c15ee4cfc77562b1bd4eddf46e/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 15 | 16 | React App 17 | 18 | 19 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { 3 | BrowserRouter as Router, 4 | Routes, 5 | Route, 6 | Navigate, 7 | } from "react-router-dom"; 8 | import routes from "./config/routes"; 9 | import UserContext from "./context/UserContext"; 10 | import AddPost from "./pages/addpost/AddPost"; 11 | import Dashboard from "./pages/dashboard/Dashboard"; 12 | import Template from "./templates/Template"; 13 | 14 | function App() { 15 | const [user, setUser] = useState({ 16 | isLoggedIn: false, 17 | user: null, 18 | token: null, 19 | avatar: null, 20 | }); 21 | 22 | return ( 23 | 24 | 25 | 26 | {routes.map((route) => { 27 | return ( 28 | 33 | ); 34 | })} 35 | 40 | ) : ( 41 | 42 | ) 43 | } 44 | > 45 | } /> 46 | } /> 47 | 48 | 49 | 50 | 51 | ); 52 | } 53 | 54 | export default App; 55 | -------------------------------------------------------------------------------- /src/components/adminContentHeader/AdminContentHeader.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import "./admincontentheader.css"; 3 | import axios from "axios"; 4 | import Loading from "../loading/Loading"; 5 | 6 | export default function AdminContentHeader(props) { 7 | const { activeCategory, setActiveCategory } = props.category; 8 | const [categories, setCategories] = useState({ 9 | isLoaded: false, 10 | data: null, 11 | }); 12 | 13 | useEffect(() => { 14 | axios("/wp-json/wp/v2/categories") 15 | .then((res) => { 16 | setCategories({ isLoaded: true, data: res.data }); 17 | }) 18 | .catch((err) => { 19 | console.log(err); 20 | }); 21 | }, []); 22 | 23 | return ( 24 |
25 |

All Posts posted either via wordpress or gracesoft

26 |
27 | 49 |
50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /src/components/adminContentHeader/admincontentheader.css: -------------------------------------------------------------------------------- 1 | .main-content-header { 2 | padding-top: 1rem; 3 | padding-left: 1rem; 4 | padding-right: 1rem; 5 | } 6 | 7 | .main-content-header > h3 { 8 | font-weight: normal; 9 | } 10 | 11 | .admin-header-menu-container { 12 | padding-top: 2ch; 13 | padding-right: 2ch; 14 | padding-bottom: 6px; 15 | overflow-x: auto; 16 | height: 70px; 17 | } 18 | 19 | ::-webkit-scrollbar { 20 | width: 0; /* Remove scrollbar space */ 21 | background: transparent; /* Optional: just make scrollbar invisible */ 22 | } 23 | 24 | .admin-header-menu { 25 | list-style-type: none; 26 | display: flex; 27 | padding-left: 0; 28 | width: 100%; 29 | } 30 | 31 | .admin-header-menu li { 32 | text-decoration: none; 33 | margin-left: 0; 34 | } 35 | 36 | .header-link { 37 | background-color: transparent; 38 | color: #333; 39 | font-size: 1rem; 40 | padding: 5px 2ch; 41 | border: none; 42 | cursor: pointer; 43 | } 44 | 45 | .header-link:hover { 46 | border-bottom: solid lavender 3px; 47 | } 48 | 49 | .active, .active:hover { 50 | background-color: rgb(241, 241, 252); 51 | border-bottom: solid orange 3px; 52 | } 53 | -------------------------------------------------------------------------------- /src/components/adminContentPosts/AdminContentPosts.jsx: -------------------------------------------------------------------------------- 1 | import "./admincontentposts.css"; 2 | import axios from "axios"; 3 | import { useState, useEffect } from 'react'; 4 | import Post from "../post/Post"; 5 | import Loading from "../loading/Loading"; 6 | 7 | export default function AdminContentPosts(props) { 8 | const activeCategory = props.category; 9 | const [posts, setPosts] = useState({ 10 | isLoaded: false, 11 | data: null, 12 | category: null, 13 | }); 14 | 15 | useEffect(() => { 16 | axios(`/wp-json/wp/v2/posts${activeCategory ? `?categories=${activeCategory}` : ""}`) 17 | .then((res) => { 18 | setPosts({ 19 | isLoaded: true, 20 | data: res.data, 21 | }); 22 | }) 23 | .catch((err) => { 24 | console.log(err); 25 | }); 26 | }, [activeCategory]); 27 | 28 | return ( 29 |
30 | {posts.isLoaded 31 | ? posts.data.map((post) => { 32 | return ( 33 |
34 | 40 |
41 | ); 42 | }) 43 | : } 44 |
45 | ); 46 | } 47 | -------------------------------------------------------------------------------- /src/components/adminContentPosts/admincontentposts.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuletawwonte/react-blog-wordpress/64c04c898311b9c15ee4cfc77562b1bd4eddf46e/src/components/adminContentPosts/admincontentposts.css -------------------------------------------------------------------------------- /src/components/adminNavbar/AdminNavbar.jsx: -------------------------------------------------------------------------------- 1 | import React, { useContext, useState } from "react"; 2 | import { useNavigate } from "react-router"; 3 | import { Link } from "react-router-dom"; 4 | import UserContext from "../../context/UserContext"; 5 | import "./adminnavbar.css"; 6 | 7 | export default function AdminNavbar() { 8 | const [extendedBtn, setExtendedBtn] = useState(false); 9 | const { user, setUser } = useContext(UserContext); 10 | const navigate = useNavigate(); 11 | 12 | return ( 13 |
21 |
22 |
23 | 24 | GRACESOFT 25 | 26 |
27 |
28 |
29 | 30 | Home 31 | 32 | 33 | Pages 34 | 35 | 36 | {user.name} 37 | 38 | 47 |
48 | 56 |
57 |
58 | {extendedBtn && ( 59 |
60 | 61 | Home 62 | 63 | 64 | Pages 65 | 66 | 67 | 68 | {user.name} 69 | 70 |
71 | )} 72 |
73 | ); 74 | } 75 | -------------------------------------------------------------------------------- /src/components/adminNavbar/adminnavbar.css: -------------------------------------------------------------------------------- 1 | .navbar-container { 2 | height: 60px; 3 | width: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | } 7 | 8 | .left-navbar { 9 | display: flex; 10 | flex: 30%; 11 | align-items: center; 12 | background-color: transparent; 13 | } 14 | 15 | .right-navbar { 16 | background-color: transparent; 17 | display: flex; 18 | flex: 70%; 19 | align-items: center; 20 | justify-content: flex-end; 21 | } 22 | 23 | .links-container { 24 | background-color: transparent; 25 | } 26 | 27 | .navbar-inner-container { 28 | background-color: gold; 29 | display: flex; 30 | width: 100%; 31 | height: 60px; 32 | padding-left: 8%; 33 | padding-right: 8%; 34 | } 35 | 36 | .text-link { 37 | text-decoration: none; 38 | font-size: larger; 39 | margin: 10px; 40 | color: black; 41 | background-color: transparent; 42 | } 43 | 44 | .logout-btn { 45 | background-color: transparent; 46 | outline: none; 47 | border: none; 48 | height: 60px; 49 | font-size: larger; 50 | cursor: pointer; 51 | } 52 | 53 | .logo-text { 54 | cursor: pointer; 55 | font-size: xx-large; 56 | font-weight: bolder; 57 | color: black; 58 | background-color: transparent; 59 | text-decoration: none; 60 | border: solid white 3px; 61 | padding: 0 15px; 62 | } 63 | 64 | .logo-text span { 65 | background-color: transparent; 66 | font-weight: 100; 67 | } 68 | 69 | .hidden-menu-btn { 70 | font-size: 50px; 71 | width: 50px; 72 | border: none; 73 | background: none; 74 | cursor: pointer; 75 | align-content: center; 76 | } 77 | 78 | .hidden-menu-btn:focus { 79 | background: none; 80 | border: none; 81 | } 82 | 83 | .extended-container { 84 | background-color: gold; 85 | height: 100%; 86 | display: flex; 87 | flex-flow: column; 88 | align-items: center; 89 | } 90 | 91 | @media only screen and (min-width: 700px) { 92 | .hidden-menu-btn { 93 | display: none; 94 | } 95 | 96 | .extended-container { 97 | display: none; 98 | } 99 | } 100 | 101 | @media only screen and (max-width: 700px) { 102 | .links-container { 103 | display: none; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/components/article/Article.jsx: -------------------------------------------------------------------------------- 1 | import "./article.css"; 2 | import Editor from "../../components/editor/Editor"; 3 | import {useEffect, useState} from 'react'; 4 | import axios from 'axios'; 5 | 6 | export default function Article(props) { 7 | const {title, featured_image_url, excerpt, author} = props.blog; 8 | const [authorData, setAuthorData] = useState({}); 9 | 10 | useEffect(() => { 11 | axios.get(`/wp-json/wp/v2/users/${author}`) 12 | .then((res) => { 13 | setAuthorData({ 14 | isLoading: true, 15 | data: res.data 16 | }); 17 | }) 18 | .catch((err) => { 19 | console.log(err); 20 | }); 21 | }, [author]); 22 | 23 | return ( 24 | <> 25 | {featured_image_url ? ( 26 | title.rendered 31 | ) : ( 32 | "" 33 | )} 34 |

37 |

42 | {authorData.isLoading ? : 'Loading' } 43 | 44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /src/components/article/article.css: -------------------------------------------------------------------------------- 1 | .articleImage { 2 | width: 100%; 3 | object-fit: cover; 4 | } 5 | 6 | .article { 7 | padding-left: 10px; 8 | padding-right: 10px; 9 | padding-bottom: 10px; 10 | } 11 | 12 | .article h2 { 13 | color: rgba(0, 0, 0, 0.849); 14 | } 15 | 16 | .article p { 17 | font-size: 0.8rem; 18 | color: rgb(116, 114, 114); 19 | font-weight: normal; 20 | } -------------------------------------------------------------------------------- /src/components/blogs/Blogs.jsx: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { useState, useEffect } from "react"; 3 | import Article from "../article/Article"; 4 | import "./blogs.css"; 5 | 6 | export default function Blogs() { 7 | const [blogs, setBlogs] = useState({}); 8 | 9 | useEffect(() => { 10 | axios 11 | .get("/wp-json/wp/v2/posts?per_page=8") 12 | .then((res) => { 13 | setBlogs({ 14 | data: res.data, 15 | isLoaded: true 16 | }); 17 | }) 18 | .catch((err) => { 19 | console.log(err); 20 | }); 21 | }, []); 22 | 23 | return ( 24 |
25 | {blogs.isLoaded ? ( 26 | blogs.data.map((blog) => { 27 | return ( 28 |
29 |
30 |
31 | ); 32 | }) 33 | ) : ( 34 |

Loading...

35 | )} 36 |
37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /src/components/blogs/blogs.css: -------------------------------------------------------------------------------- 1 | .blogsContainer { 2 | margin-left: 5%; 3 | margin-right: 5%; 4 | margin-top: 25px; 5 | display: grid; 6 | grid-template-columns: 20% 35% 25% 20%; 7 | grid-auto-rows: auto; 8 | height: 60vh; 9 | grid-auto-flow: row; 10 | } 11 | 12 | @media only screen and (max-width: 1024px) { 13 | .blogsContainer { 14 | margin-left: 2%; 15 | margin-right: 2%; 16 | grid-auto-flow: row; 17 | grid-template-columns : repeat(auto-fit, minmax(33%, 1rem)); 18 | } 19 | .blogsContainer div:nth-child(n) { 20 | border: none; 21 | } 22 | } 23 | 24 | @media only screen and (max-width: 768px) { 25 | .blogsContainer { 26 | grid-auto-flow: row; 27 | grid-template-columns : repeat(auto-fill, minmax(50%, 1rem)); 28 | grid-auto-rows: auto auto; 29 | } 30 | .blogsContainer div:nth-child(2n) { 31 | border-right: none; 32 | } 33 | .blogsContainer div:nth-child(n) { 34 | border: none; 35 | } 36 | } 37 | @media only screen and (max-width: 636px) { 38 | .blogsContainer { 39 | grid-auto-flow: row; 40 | grid-template-columns : repeat(auto-fill, minmax(100%, 1rem)); 41 | grid-auto-rows: auto; 42 | } 43 | body { 44 | width: 100%; 45 | } 46 | .blogsContainer div:nth-child(n) { 47 | border: none; 48 | } 49 | } 50 | 51 | .blogsContainer div:nth-child(n) { 52 | border-right: groove rgba(0, 0, 0, 0.068) 1pt; 53 | } 54 | .blogsContainer div:nth-child(4n) { 55 | border-right: none; 56 | } 57 | -------------------------------------------------------------------------------- /src/components/editor/Editor.jsx: -------------------------------------------------------------------------------- 1 | import "./editor.css"; 2 | 3 | export default function Editor(props) { 4 | const { avatar_urls, name } = props.editorData; 5 | return ( 6 |
7 | {name} 8 |

{name}

9 |
10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/components/editor/editor.css: -------------------------------------------------------------------------------- 1 | .editorContainer { 2 | display: flex; 3 | align-items: center; 4 | margin-top: 10px; 5 | margin-bottom: 10px; 6 | } 7 | 8 | .editorContainer img { 9 | height: 35px; 10 | width: 35px; 11 | border-radius: 10px; 12 | margin-right: 5px; 13 | outline: solid rgb(192, 191, 191) 0.01rem; 14 | } -------------------------------------------------------------------------------- /src/components/loading/Loading.jsx: -------------------------------------------------------------------------------- 1 | import "./loading.css"; 2 | 3 | export default function Loading(props) { 4 | return ( 5 |
6 | loading 7 |
8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /src/components/loading/loading.css: -------------------------------------------------------------------------------- 1 | .loading-container { 2 | display: flex; 3 | justify-content: center; 4 | } 5 | 6 | .loading { 7 | max-width: 50px; 8 | } -------------------------------------------------------------------------------- /src/components/menu/Menu.jsx: -------------------------------------------------------------------------------- 1 | import { NavLink } from "react-router-dom"; 2 | import "./menu.css"; 3 | 4 | export default function Menu() { 5 | return ( 6 | <> 7 | 41 | 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /src/components/menu/menu.css: -------------------------------------------------------------------------------- 1 | .menu { 2 | list-style-type: none; 3 | padding: 0; 4 | margin-bottom: 10px; 5 | } 6 | 7 | .menu-item-link { 8 | background-color: white; 9 | display: block; 10 | color: black; 11 | padding: 12px; 12 | text-decoration: none; 13 | font-size: 20px; 14 | } 15 | 16 | .menu-item-link:hover { 17 | background-color: #eeeeee; 18 | } 19 | 20 | .menu-active, .menu-active:hover{ 21 | background-color: #dfdede; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/components/post/Post.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import axios from "axios"; 3 | import "./post.css"; 4 | import Editor from "../editor/Editor"; 5 | 6 | export default function Post(props) { 7 | const { title, excerpt, featured_image_url, author_id } = props; 8 | const [authorData, setAuthorData] = useState(null); 9 | 10 | useEffect(() => { 11 | axios(`/wp-json/wp/v2/users/${author_id}`) 12 | .then((res) => { 13 | setAuthorData(res.data); 14 | }) 15 | .catch((err) => { 16 | console.log(err); 17 | }); 18 | }, [author_id]); 19 | 20 | return ( 21 |
22 |
23 | {featured_image_url ? ( 24 | {title} 29 | ) : ( 30 | "" 31 | )} 32 |
33 |
34 |

35 |

40 | {authorData ? : ""} 41 |
42 |
43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /src/components/post/post.css: -------------------------------------------------------------------------------- 1 | .post-container { 2 | border-bottom: solid #e2e0da 1px; 3 | padding: 15px 2%; 4 | display: flex; 5 | gap: 3%; 6 | flex-wrap: wrap; 7 | } 8 | 9 | .post-img-container { 10 | flex-basis: 27%; 11 | flex-grow: 0; 12 | } 13 | 14 | .post-img-content { 15 | max-width: 100%; 16 | object-fit: cover; 17 | } 18 | 19 | .post-img-content:hover { 20 | transform: scale(1.02); 21 | background-size: 150%; 22 | transition: all .5s; 23 | cursor: pointer; 24 | } 25 | 26 | .post-text-content { 27 | flex-basis: 70%; 28 | } 29 | 30 | @media only screen and (max-width: 575px) { 31 | .post-img-container, 32 | .post-text-content { 33 | min-width: 100%; 34 | } 35 | 36 | .post-container { 37 | border-bottom: solid #f9f6ec 10px; 38 | } 39 | } 40 | 41 | .post-text-content h2 { 42 | color: black; 43 | } 44 | 45 | .post-text-content p { 46 | color: gray; 47 | } 48 | -------------------------------------------------------------------------------- /src/components/sideMenuUser/SideMenuUser.jsx: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { useContext, useEffect, useState } from "react"; 3 | import UserContext from "../../context/UserContext"; 4 | import "./sidemenuuser.css"; 5 | 6 | export default function SideMenuUser() { 7 | const { user } = useContext(UserContext); 8 | const [avatar, setAvatar] = useState(null); 9 | 10 | useEffect(() => { 11 | axios 12 | .get(`/wp-json/wp/v2/users/?search=${user.name}`) 13 | .then((res) => { 14 | setAvatar(res.data[0].avatar_urls[96]); 15 | }) 16 | .catch((err) => { 17 | console.log(err); 18 | }); 19 | }, [user]); 20 | 21 | return ( 22 |
23 | {avatar ? 24 | {user.name} : ""} 25 |

{user.name}

26 |

@{user.nice_name}

27 |
28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /src/components/sideMenuUser/sidemenuuser.css: -------------------------------------------------------------------------------- 1 | 2 | .user-container { 3 | width: inherit; 4 | background-color: white; 5 | margin-bottom: 10px; 6 | padding: 1rem 1rem; 7 | display: flex; 8 | flex-flow: column; 9 | align-items: center; 10 | border-top-left-radius: 5px; 11 | border-top-right-radius: 5px; 12 | } 13 | 14 | .avatar { 15 | max-width: 96px; 16 | border: solid white 2px; 17 | outline: solid orange 2px; 18 | border-radius: 50%; 19 | margin-bottom: 10px; 20 | } 21 | 22 | .user-container p { 23 | color: gray; 24 | } -------------------------------------------------------------------------------- /src/components/topbar/Topbar.jsx: -------------------------------------------------------------------------------- 1 | import "./topbar.css"; 2 | import { Link } from "react-router-dom"; 3 | 4 | export default function Topbar() { 5 | return ( 6 |
7 |
8 | 9 | 10 | Grace 11 | soft 12 | 13 | 14 |
15 |
16 | Call Us: +251926350413 17 | / 18 | hello@gracesoft.net 19 |
20 |
21 |
22 | 23 | Login 24 | 25 |
26 |
27 | 28 |
29 |
30 | Menu 31 |
32 |
33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /src/components/topbar/topbar.css: -------------------------------------------------------------------------------- 1 | .topbarContainer { 2 | margin-left: 5%; 3 | margin-right: 5%; 4 | height: 120px; 5 | width: 90%; 6 | display: flex; 7 | align-items: center; 8 | top: 0; 9 | } 10 | 11 | .topbarLeft { 12 | flex: 4; 13 | } 14 | .logo , .logo:active { 15 | margin-left: 10px; 16 | font-size: 30px; 17 | text-decoration: none; 18 | color: inherit; 19 | } 20 | .topbarCenter { 21 | flex: 4; 22 | display: flex; 23 | justify-content: center; 24 | } 25 | 26 | .topbarCenter span { 27 | font-size: 15px; 28 | font-weight: 600; 29 | } 30 | .callUsSeparator { 31 | margin-left: 6px; 32 | } 33 | .callUsEmail { 34 | margin-left: 8px; 35 | } 36 | 37 | .topbarRight { 38 | flex: 4; 39 | display: flex; 40 | align-items: center; 41 | justify-content: flex-end; 42 | } 43 | .loginLink , .loginLink:active { 44 | text-decoration: none; 45 | color: inherit; 46 | } 47 | .topbarSubscribeBtn button{ 48 | margin-left: 12px; 49 | padding-left: 20px; 50 | padding-right: 20px; 51 | font-size: 14px; 52 | font-weight: 600; 53 | background-color: black; 54 | color: white; 55 | border: none; 56 | height: 35px; 57 | border-radius: 3px; 58 | } 59 | .topbarSubscribeBtn button:hover{ 60 | cursor: pointer; 61 | } 62 | .topbarLinks { 63 | margin-left: 12px; 64 | margin-right: 10px; 65 | } 66 | 67 | @media only screen and (max-width: 636px) { 68 | .topbarCenter { 69 | display: none; 70 | } 71 | .topbarRight { 72 | display: none; 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /src/config/routes.js: -------------------------------------------------------------------------------- 1 | import Login from "../pages/login/Login"; 2 | import Home from "../pages/home/Home"; 3 | import PageNotFound from "../pages/pagenotfound/PageNotFound"; 4 | 5 | const routes = [ 6 | { 7 | path: "/", 8 | component: , 9 | }, 10 | { 11 | path: "/login", 12 | component: , 13 | }, 14 | { 15 | path: "/*", 16 | component: , 17 | }, 18 | ]; 19 | 20 | export default routes; 21 | -------------------------------------------------------------------------------- /src/context/ProtectedRoute.js: -------------------------------------------------------------------------------- 1 | import { Route, Navigate } from "react-router-dom"; 2 | import { useContext } from "react"; 3 | import UserContext from "./UserContext"; 4 | 5 | export default function ProtectedRoute({ component: Component , ...rest}) { 6 | const { isLoggedIn } = useContext(UserContext); 7 | 8 | return ( 9 | { 11 | if (isLoggedIn) { 12 | return ; 13 | } else { 14 | return ; 15 | } 16 | }} 17 | /> 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /src/context/UserContext.js: -------------------------------------------------------------------------------- 1 | import {createContext} from 'react'; 2 | 3 | const UserContext = createContext(); 4 | 5 | export default UserContext; -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root') 11 | ); 12 | -------------------------------------------------------------------------------- /src/pages/addpost/AddPost.jsx: -------------------------------------------------------------------------------- 1 | import "./addpost.css"; 2 | import { Formik } from "formik"; 3 | 4 | export default function AddPost() { 5 | return ( 6 |
7 |
8 |

Add Post

9 |

The title and the content of the post must be added here.

10 |
11 | { 14 | const errors = {}; 15 | if (!values.title) { 16 | errors.title = "Post title is required"; 17 | } 18 | if (!values.content) { 19 | errors.content = 20 | "The content of a post cannot be empty"; 21 | } 22 | return errors; 23 | }} 24 | onSubmit={(values, { setSubmitting }) => { 25 | setTimeout(() => { 26 | alert(JSON.stringify(values, null, 2)); 27 | setSubmitting(false); 28 | }, 400); 29 | }} 30 | > 31 | {({ 32 | values, 33 | errors, 34 | touched, 35 | handleChange, 36 | handleBlur, 37 | handleSubmit, 38 | isSubmitting, 39 | /* and other goodies */ 40 | }) => ( 41 |
42 | 51 | {touched.title && errors.title ? {errors.title}: ''} 52 |