mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
init
This commit is contained in:
12
frontend/.gitignore
vendored
Normal file
12
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
.idea/
|
||||
.vscode/
|
||||
node_modules/
|
||||
build/
|
||||
tmp/
|
||||
temp/
|
||||
dist/
|
||||
ormconfig.json
|
||||
ormconfig.test.json
|
||||
.env
|
||||
.cache
|
||||
.directory
|
||||
8990
frontend/package-lock.json
generated
Normal file
8990
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
frontend/package.json
Normal file
30
frontend/package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "writer-frontend",
|
||||
"scripts": {
|
||||
"start": "parcel src/index.html",
|
||||
"build": "parcel build src/index.html",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-sass": "^3.10.32",
|
||||
"@types/parcel-bundler": "^1.10.1",
|
||||
"@types/react": "^16.7.18",
|
||||
"@types/react-dom": "^16.0.11",
|
||||
"@types/react-redux": "^6.0.11",
|
||||
"@types/react-router": "^4.4.3",
|
||||
"@types/react-router-dom": "^4.3.1",
|
||||
"node-sass": "^4.11.0",
|
||||
"parcel-bundler": "^1.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blueprintjs/core": "^3.10.0",
|
||||
"@blueprintjs/icons": "^3.4.0",
|
||||
"react": "^16.7.0",
|
||||
"react-dom": "^16.7.0",
|
||||
"react-redux": "^6.0.0",
|
||||
"react-router": "^4.3.1",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"redux": "^4.0.1",
|
||||
"redux-saga": "^0.16.2"
|
||||
}
|
||||
}
|
||||
15
frontend/src/App.tsx
Normal file
15
frontend/src/App.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as React from "react";
|
||||
import { Route, Switch } from "react-router";
|
||||
import { Login } from "~Auth/Login";
|
||||
import { Home } from "~Home";
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<>
|
||||
<Switch>
|
||||
<Route exact={true} path="/" component={Home} />
|
||||
<Route path="/login" component={Login} />
|
||||
</Switch>
|
||||
</>
|
||||
);
|
||||
}
|
||||
21
frontend/src/Auth/Auth.scss
Normal file
21
frontend/src/Auth/Auth.scss
Normal file
@@ -0,0 +1,21 @@
|
||||
.AuthForm {
|
||||
margin: auto;
|
||||
margin-top: 10rem;
|
||||
width: 20rem;
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
h2 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
button.submit {
|
||||
margin-left: auto;
|
||||
justify-self: flex-end;
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
frontend/src/Auth/Login.tsx
Normal file
27
frontend/src/Auth/Login.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import "./Auth.scss";
|
||||
|
||||
import { Button, Card, FormGroup, H2, InputGroup } from "@blueprintjs/core";
|
||||
import * as React from "react";
|
||||
|
||||
export function Login() {
|
||||
return (
|
||||
<>
|
||||
<Card className="AuthForm" elevation={2}>
|
||||
<form>
|
||||
<H2>Login</H2>
|
||||
<FormGroup label="Username">
|
||||
<InputGroup leftIcon="person" />
|
||||
</FormGroup>
|
||||
<FormGroup label="Password">
|
||||
<InputGroup leftIcon="key" />
|
||||
</FormGroup>
|
||||
<div className="buttons">
|
||||
<Button className="submit" intent="primary">
|
||||
Login
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
26
frontend/src/Home.tsx
Normal file
26
frontend/src/Home.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Alignment, Button, Classes, Navbar } from "@blueprintjs/core";
|
||||
import * as React from "react";
|
||||
|
||||
export function Home() {
|
||||
return (
|
||||
<>
|
||||
{" "}
|
||||
<Navbar>
|
||||
<Navbar.Group align={Alignment.LEFT}>
|
||||
<Navbar.Heading>Writer</Navbar.Heading>
|
||||
<Navbar.Divider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon="home"
|
||||
text="Home"
|
||||
/>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon="document"
|
||||
text="Files"
|
||||
/>
|
||||
</Navbar.Group>
|
||||
</Navbar>
|
||||
</>
|
||||
);
|
||||
}
|
||||
15
frontend/src/index.html
Normal file
15
frontend/src/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Writer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="body">
|
||||
|
||||
</div>
|
||||
<script src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
19
frontend/src/index.tsx
Normal file
19
frontend/src/index.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import "@blueprintjs/core/lib/css/blueprint.css";
|
||||
import "@blueprintjs/icons/lib/css/blueprint-icons.css";
|
||||
import "normalize.css/normalize.css";
|
||||
|
||||
import * as React from "react";
|
||||
import { render } from "react-dom";
|
||||
import { Provider } from "react-redux";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { App } from "~App";
|
||||
import { store } from "~redux/store";
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</Provider>,
|
||||
document.getElementById("body"),
|
||||
);
|
||||
10
frontend/src/redux/auth/actions.ts
Normal file
10
frontend/src/redux/auth/actions.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Action } from "redux";
|
||||
|
||||
export const AUTH_SUCCESS = "AUTH_SUCCESS";
|
||||
|
||||
class AuthSuccessAction implements Action {
|
||||
public readonly type = AUTH_SUCCESS;
|
||||
constructor(public jwt: string) {}
|
||||
}
|
||||
|
||||
export type AuthAction = AuthSuccessAction;
|
||||
27
frontend/src/redux/auth/reducer.ts
Normal file
27
frontend/src/redux/auth/reducer.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Reducer } from "react";
|
||||
|
||||
import { AUTH_SUCCESS, AuthAction } from "./actions";
|
||||
|
||||
export interface IAuthState {
|
||||
jwt: string | null;
|
||||
inProgress: boolean;
|
||||
}
|
||||
|
||||
const defaultAuthState: IAuthState = {
|
||||
jwt: null,
|
||||
inProgress: false,
|
||||
};
|
||||
|
||||
export const auth: Reducer<IAuthState, AuthAction> = (
|
||||
state: IAuthState = defaultAuthState,
|
||||
action: AuthAction,
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case AUTH_SUCCESS:
|
||||
return { ...state, jwt: action.jwt, inProgress: false };
|
||||
break;
|
||||
default:
|
||||
return state;
|
||||
break;
|
||||
}
|
||||
};
|
||||
4
frontend/src/redux/reducers.ts
Normal file
4
frontend/src/redux/reducers.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { combineReducers } from "redux";
|
||||
import { auth } from "~redux/auth/reducer";
|
||||
|
||||
export const rootReducer = combineReducers({ auth });
|
||||
4
frontend/src/redux/store.ts
Normal file
4
frontend/src/redux/store.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { createStore } from "redux";
|
||||
import { rootReducer } from "~redux/reducers";
|
||||
|
||||
export const store = createStore(rootReducer);
|
||||
0
frontend/src/redux/types.ts
Normal file
0
frontend/src/redux/types.ts
Normal file
23
frontend/tsconfig.json
Normal file
23
frontend/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"jsx": "react",
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./dist",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"~*": [
|
||||
"./*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user