Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/.env.development.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=Development
REACT_APP_GRAPHQL_API_BASE_URL=http://localhost:8080
2 changes: 2 additions & 0 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=Production
REACT_APP_GRAPHQL_API_BASE_URL=https://gql-sampleapp.short-d.com
2 changes: 2 additions & 0 deletions frontend/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=Staging
REACT_APP_GRAPHQL_API_BASE_URL=https://gql-sampleapp-staging.short-d.com
26 changes: 26 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# environmental variables
.env.local
.env.development
.env.development.local
.env.test.local
.env.production.local

# misc
.DS_Store

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions frontend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
3 changes: 3 additions & 0 deletions frontend/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["stylelint-prettier/recommended"]
}
10 changes: 10 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Create production container
FROM nginx:1.17.5-alpine

WORKDIR /usr/share/nginx/html

COPY build/ .

RUN rm -rf /etc/nginx/conf.d/default.conf

COPY nginx/default.conf /etc/nginx/conf.d/
12 changes: 12 additions & 0 deletions frontend/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

error_page 404 =200 /index.html;
error_page 500 502 503 504 /index.html;
}
59 changes: 59 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"node-sass": "^4.14.1",
"prettier": "^2.0.5",
"react-scripts": "3.4.3",
"stylelint": "^13.6.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^20.0.0",
"stylelint-prettier": "^1.1.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts build'",
"build:development": "REACT_APP_ENV=development yarn build",
"build:staging": "REACT_APP_ENV=staging yarn build",
"build:production": "REACT_APP_ENV=production yarn build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"tslint:lint": "yarn tslint -c tslint.json 'src/**/*.ts'",
"stylelint:lint": "yarn stylelint --config=.stylelintrc src/**/*.{scss,css}",
"prettier:base": "prettier --parser typescript --single-quote",
"prettier:check": "yarn prettier:base --list-different \"src/**/*.{ts,tsx}\"",
"prettier:write": "yarn prettier:base --write \"src/**/*.{ts,tsx}\"",
"stylelint:write": "yarn stylelint --config=.stylelintrc --fix src/**/*.{scss,css}"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added frontend/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added frontend/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions frontend/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
4 changes: 4 additions & 0 deletions frontend/scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

yarn
yarn build:development
3 changes: 3 additions & 0 deletions frontend/scripts/code-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

yarn test --coverage --watchAll=false
4 changes: 4 additions & 0 deletions frontend/scripts/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

yarn
yarn start
4 changes: 4 additions & 0 deletions frontend/scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

yarn stylelint:write
yarn prettier:write
4 changes: 4 additions & 0 deletions frontend/scripts/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

yarn tslint:lint
yarn stylelint:lint
3 changes: 3 additions & 0 deletions frontend/scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

yarn test
30 changes: 30 additions & 0 deletions frontend/src/component/App.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.App {
margin-top: 50px;
margin-left: auto;
margin-right: auto;
width: 300px;
text-align: center;
}

.Env {
font-weight: bold;
font-size: 20px;
padding: 20px 0;
border: 2px dashed gray;
margin-bottom: 20px;
}

.Content {
padding: 20px 0;
border: 2px dashed gray;

h1 {
margin-top: 0;
}
}

.ChangeLog {
list-style: none;
padding: 0;
margin: 0;
}
59 changes: 59 additions & 0 deletions frontend/src/component/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, {Component} from 'react';
import styles from './App.module.scss';
import {SampleAppGraphqlService} from '../service/sampleapp.graphql.service';
import {Change} from '../entity/change';
import {EnvService} from '../service/env.service';

interface IProps {
sampleAppGraphQLService: SampleAppGraphqlService;
envService: EnvService;
}

interface IState {
env: string;
changes: Change[];
}

export class App extends Component<IProps, IState> {
constructor(props: IProps) {
super(props);
this.state = {
env: '',
changes: [],
};
}

async componentDidMount() {
const changeLog = await this.props.sampleAppGraphQLService.getChangeLog();
const env = this.props.envService.getEnv().env;
this.setState({
changes: changeLog.changes,
env
});
}

render() {
return (
<div className={styles.App}>
{this.state.env &&
<div className={styles.Env}>
{this.state.env}
</div>
}
<div className={styles.Content}>
<h1>Frontend Works!</h1>
<h2>Change Log</h2>
<ul className={styles.ChangeLog}>
{this.state.changes.map(change =>
<li>
{`${change.title}`}
</li>
)}
</ul>
</div>
</div>
);
}
}

export default App;
4 changes: 4 additions & 0 deletions frontend/src/entity/change.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Change {
id: string;
title: string;
}
5 changes: 5 additions & 0 deletions frontend/src/entity/changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Change} from './change';

export interface ChangeLog {
changes: Change[];
}
13 changes: 13 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
29 changes: 29 additions & 0 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './component/App';
import * as serviceWorker from './serviceWorker';
import {GraphQLService} from './service/fw/GraphQL.service';
import {FetchHTTPService} from './service/fw/http.service';
import {SampleAppGraphqlService} from './service/sampleapp.graphql.service';
import {EnvService} from './service/env.service';

const envService = new EnvService();
const fetchHTTPService = new FetchHTTPService();
const graphQLService = new GraphQLService(fetchHTTPService);
const sampleAppGraphQLService = new SampleAppGraphqlService(graphQLService, envService);

ReactDOM.render(
<React.StrictMode>
<App
envService={envService}
sampleAppGraphQLService={sampleAppGraphQLService}
/>
</React.StrictMode>,
document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
1 change: 1 addition & 0 deletions frontend/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
Loading