Skip to content

Commit eadc14e

Browse files
Initial commit
1 parent 6ae7ef0 commit eadc14e

39 files changed

+12219
-2
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.idea
2+
*.iml
3+
4+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
5+
.gradle
6+
7+
# dependencies
8+
/node_modules
9+
/.pnp
10+
.pnp.js
11+
12+
# testing
13+
/coverage
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
.env.local
21+
.env.development.local
22+
.env.test.local
23+
.env.production.local
24+
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1-
# devzone-ui-reactjs
2-
DevZone UI using ReactJS
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `yarn start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `yarn test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `yarn build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `yarn eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
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.
35+
36+
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.
37+
38+
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.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "devzone-reactjs",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@fortawesome/fontawesome-free": "^5.11.2",
7+
"@testing-library/jest-dom": "^4.2.4",
8+
"@testing-library/react": "^9.3.2",
9+
"@testing-library/user-event": "^7.1.2",
10+
"@types/classnames": "^2.2.10",
11+
"@types/jest": "^24.0.0",
12+
"@types/jquery": "^3.5.1",
13+
"@types/node": "^12.0.0",
14+
"@types/react": "^16.9.0",
15+
"@types/react-dom": "^16.9.0",
16+
"@types/react-router-dom": "^5.1.5",
17+
"axios": "^0.19.0",
18+
"bootstrap": "^4.3.1",
19+
"classnames": "^2.2.6",
20+
"jquery": "^3.5.1",
21+
"lodash": "^4.17.15",
22+
"moment": "^2.24.0",
23+
"popper.js": "^1.16.1",
24+
"primeflex": "^1.0.0",
25+
"primeicons": "^2.0.0",
26+
"primereact": "^3.3.2",
27+
"react": "^16.13.1",
28+
"react-dom": "^16.13.1",
29+
"react-router-dom": "^5.2.0",
30+
"react-scripts": "3.4.3",
31+
"typescript": "~3.7.2"
32+
},
33+
"scripts": {
34+
"start": "react-scripts start",
35+
"build": "react-scripts build",
36+
"test": "react-scripts test",
37+
"eject": "react-scripts eject"
38+
},
39+
"eslintConfig": {
40+
"extends": "react-app"
41+
},
42+
"browserslist": {
43+
"production": [
44+
">0.2%",
45+
"not dead",
46+
"not op_mini all"
47+
],
48+
"development": [
49+
"last 1 chrome version",
50+
"last 1 firefox version",
51+
"last 1 safari version"
52+
]
53+
}
54+
}

public/favicon.ico

3.08 KB
Binary file not shown.

public/index.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Valuable resources for software developers"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>DevZone UI ReactJS</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

public/logo192.png

5.22 KB
Loading

public/logo512.png

9.44 KB
Loading

public/manifest.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

public/robots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

src/App.css

Whitespace-only changes.

src/App.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import App from './App';
4+
5+
test('renders learn react link', () => {
6+
//const { getByText } = render(<App />);
7+
//const linkElement = getByText(/learn react/i);
8+
//expect(linkElement).toBeInTheDocument();
9+
});

src/App.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from "react";
2+
import {Route, Switch, Redirect} from "react-router-dom";
3+
import Posts from "./pages/posts/Posts";
4+
import Login from "./pages/login/Login";
5+
import Registration from "./pages/registration/Registration";
6+
import NavBar from "./components/layout/NavBar";
7+
import NewPost from "./pages/posts/NewPost";
8+
import NotFound from "./pages/error/NotFound";
9+
10+
const App = () => (
11+
<div className="App">
12+
<NavBar/>
13+
<main role="main" className="container-fluid">
14+
<Switch>
15+
<Route path="/login" component={Login}/>
16+
<Route path="/registration" component={Registration}/>
17+
<Route path="/posts/new" component={NewPost}/>
18+
<Route path="/posts/page/:page" render={(props) => (
19+
<Posts key={props.location.search} {...props}/>)
20+
} />
21+
<Route path="/posts" component={Posts} />
22+
<Redirect exact path="/" to="/posts"/>
23+
<Route path="*">
24+
<NotFound />
25+
</Route>
26+
</Switch>
27+
</main>
28+
<footer className="footer">
29+
<div className="container">
30+
<p className="text-center">SivaLabs &copy; 2020</p>
31+
</div>
32+
</footer>
33+
</div>
34+
);
35+
36+
export default App;

src/bootswatch.min.css

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/layout/NavBar.tsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from "react";
2+
import { NavLink } from "react-router-dom";
3+
import AuthService from "../../services/AuthService";
4+
5+
const NavBar = () => {
6+
const authService = new AuthService()
7+
8+
const logoutHandler = () => {
9+
authService.logout();
10+
window.location.href = "/";
11+
};
12+
13+
let authenticatedLinks;
14+
const user = authService.getCurrentUser();
15+
if (user.access_token) {
16+
authenticatedLinks = (
17+
<ul className="navbar-nav">
18+
<li className="nav-item">
19+
<NavLink className="nav-link" to="/posts/new">
20+
<i className="fas fa-plus-circle"/> Add
21+
</NavLink>
22+
</li>
23+
<li className="nav-item dropdown">
24+
<NavLink className="nav-link dropdown-toggle" to="#" id="navbarDropdown" role="button"
25+
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
26+
<i className="fas fa-user"/> <span>{user.name}</span>
27+
</NavLink>
28+
<div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
29+
<NavLink className="dropdown-item" to="/profile">
30+
<i className="fas fa-address-card"/> My Profile
31+
</NavLink>
32+
<div className="dropdown-divider"/>
33+
34+
<NavLink className="dropdown-item" to="/logout" onClick={logoutHandler}>
35+
<i className="fas fa-sign-out-alt"/> Logout
36+
</NavLink>
37+
</div>
38+
</li>
39+
</ul>
40+
);
41+
} else {
42+
authenticatedLinks = (
43+
<ul className="navbar-nav">
44+
<li className="nav-item">
45+
<NavLink className="nav-link" to="/login">
46+
Login
47+
</NavLink>
48+
</li>
49+
<li className="nav-item">
50+
<NavLink className="nav-link" to="/registration">
51+
Register
52+
</NavLink>
53+
</li>
54+
</ul>
55+
);
56+
}
57+
return (
58+
<nav className="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
59+
<NavLink className="navbar-brand" to="/">
60+
DevZone
61+
</NavLink>
62+
<button className="navbar-toggler" type="button" data-toggle="collapse"
63+
data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
64+
aria-expanded="false" aria-label="Toggle navigation">
65+
<span className="navbar-toggler-icon"/>
66+
</button>
67+
68+
<div className="collapse navbar-collapse" id="navbarSupportedContent">
69+
<ul className="navbar-nav mr-auto">
70+
71+
</ul>
72+
{authenticatedLinks}
73+
</div>
74+
</nav>
75+
);
76+
};
77+
78+
export default NavBar;

src/components/posts/Pagination.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from "react";
2+
import {PostsModel} from "../../models/PostModels";
3+
import classNames from "classnames";
4+
import {NavLink} from "react-router-dom";
5+
6+
const Pagination: React.FC<PostsModel> = (posts) => {
7+
8+
return (
9+
<div>
10+
{ posts.totalPages > 1 &&
11+
<nav aria-label="Page navigation">
12+
<ul className="pagination pagination justify-content-center">
13+
<li className={classNames({
14+
"page-item": true,
15+
disabled: !posts.hasPrevious
16+
})}>
17+
<NavLink className="page-link" to="/posts">First</NavLink>
18+
</li>
19+
<li className={classNames({
20+
"page-item": true,
21+
disabled: !posts.hasPrevious
22+
})}>
23+
<NavLink className="page-link" to={`/posts/page/${posts.pageNumber-1}`}>Previous</NavLink>
24+
</li>
25+
<li className={classNames({
26+
"page-item": true,
27+
disabled: !posts.hasNext
28+
})}>
29+
<NavLink className="page-link" to={`/posts/page/${posts.pageNumber+1}`}>Next</NavLink>
30+
</li>
31+
<li className={classNames({
32+
"page-item": true,
33+
disabled: !posts.hasNext
34+
})}>
35+
<NavLink className="page-link" to={`/posts/page/${posts.totalPages}`}>Last</NavLink>
36+
</li>
37+
</ul>
38+
</nav>
39+
}
40+
</div>
41+
);
42+
}
43+
44+
export default Pagination;

0 commit comments

Comments
 (0)