Skip to content

Commit

Permalink
refactor scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
Deturium committed Sep 2, 2018
1 parent da39449 commit 5b21152
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 6,306 deletions.
29 changes: 29 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"presets": [
["@babel/env", {
"modules": false,
"targets": { "esmodules": true }
}],
"@babel/react",
"@babel/typescript"
],
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }],
["transform-imports", {
"@material-ui/core": { "transform": "@material-ui/core/${member}" },
"@material-ui/icons": { "transform": "@material-ui/icons/${member}" }
}]
],
"env": {
"development": {
"plugins": [
["emotion", { "sourceMap": true, "autoLabel": true }]
]
},
"production": {
"plugins": [
["emotion", { "hoist": true }]
]
}
}
}
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
26 changes: 22 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
node_modules
# See https://help.github.com/ignore-files/ for more about ignoring files.

dist
yarn-error.log
# dependencies
/node_modules

mock
# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# lock
yarn.lock
3 changes: 3 additions & 0 deletions images.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '*.svg'
declare module '*.png'
declare module '*.jpg'
17 changes: 0 additions & 17 deletions index.html

This file was deleted.

53 changes: 33 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
{
"name": "cc98-pwa",
"version": "1.0.0",
"version": "0.2.0",
"description": "CC98 Forum PWA version.",
"author": "Hydrogen",
"license": "MIT",
"private": true,
"scripts": {
"dev": "webpack-dev-server --progress --hot --inline",
"build": "webpack --mode production"
"dev": "cross-env NODE_ENV=development webpack-dev-server --progress --hot --inline",
"build": "cross-env NODE_ENV=production webpack",
"serve": "serve dist -s -p 8000"
},
"dependencies": {
"@material-ui/core": "^1.0.0-rc.0",
"@material-ui/icons": "^1.0.0-rc.0",
"classnames": "^2.2.5",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-router-dom": "^4.2.2"
"@material-ui/core": "^3.0.1",
"@material-ui/icons": "^3.0.1",
"emotion": "^9.2.8",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-emotion": "^9.2.8",
"react-router-dom": "^4.3.1"
},
"devDependencies": {
"@types/classnames": "^2.2.3",
"@types/react": "^16.3.12",
"@types/react-dom": "^16.0.5",
"@types/react-router-dom": "^4.2.6",
"html-webpack-plugin": "^3.2.0",
"ts-loader": "^4.2.0",
"typescript": "^2.8.3",
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "^3.1.4"
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@types/react": "^16.4.13",
"@types/react-dom": "^16.0.7",
"@types/react-router-dom": "^4.3.0",
"babel-loader": "^8.0.0-beta.6",
"babel-plugin-emotion": "^9.2.8",
"babel-plugin-transform-imports": "^1.5.0",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.2",
"cross-env": "^5.2.0",
"html-webpack-plugin": "^4.0.0-alpha",
"typescript": "^3.0.3",
"url-loader": "^1.1.1",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.7",
"webpack-merge": "^4.1.4",
"workbox-webpack-plugin": "^3.4.1"
}
}
File renamed without changes.
Binary file added public/icons/snowball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="<%= htmlWebpackPlugin.options.MANIFEST_PATH %>">
<title>CC98 PWA</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>
16 changes: 16 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"short_name": "H2C",
"name": "CC98",
"description": "H2C - CC98 Forum PWA version.",
"icons": [
{
"src": "icons/snowball.png",
"sizes": "144x144",
"type": "image/png"
}
],
"start_url": "/",
"display": "standalone",
"theme_color": "#66ccff",
"background_color": "#ffffff"
}
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Hot from './pages/Hot'
import Topic from './pages/Topic'
import LogIn from './pages/LogIn'

const App = (props) => (
const App = () => (
<BrowserRouter>
<div>
<TopBar />
Expand Down
19 changes: 12 additions & 7 deletions src/components/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import React from 'react'

import { withStyles, WithStyles, StyleRules } from '@material-ui/core/styles'

import AppBar from '@material-ui/core/AppBar'
import Toolbar from '@material-ui/core/Toolbar'
import IconButton from '@material-ui/core/IconButton'
import MenuIcon from '@material-ui/icons/Menu'
import Typography from '@material-ui/core/Typography'
import Button from '@material-ui/core/Button'
import {
AppBar,
Toolbar,
IconButton,
Typography,
Button,
} from '@material-ui/core'

import {
Menu
} from '@material-ui/icons'

const styles: StyleRules = {
root: {
Expand Down Expand Up @@ -42,7 +47,7 @@ class TopBar extends React.Component<Props & WithStyles, State> {
<AppBar className={classes.root} position="static">
<Toolbar>
<IconButton className={classes.menuButton} color="inherit">
<MenuIcon />
<Menu onClick={() => history.back()}/>
</IconButton>
<Typography className={classes.title} color="inherit">
{ this.props.text }
Expand Down
16 changes: 13 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import React from 'react'
import ReactDOM from 'react-dom'

import App from './App'

ReactDOM.render(
<App />,
document.getElementById('root')
);
)

// if ('serviceWorker' in navigator) {
// window.addEventListener('load', () => {
// navigator.serviceWorker.register('/service-worker.js').then(registration => {
// console.log('SW registered: ', registration);
// }).catch(registrationError => {
// console.log('SW registration failed: ', registrationError);
// });
// });
// }
6 changes: 3 additions & 3 deletions src/utility/logIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ export function logIn() {

const param = {
client_id: "d3c6b528-1eb1-4bf3-8f39-08d5b8a11569",
// redirect_uri: "http://localhost:8080/login",
redirect_uri: "http://cc98.dustdown.cn/login",
redirect_uri: "http://localhost:8000/login",
// redirect_uri: "http://cc98.dustdown.cn/login",
response_type: "token",
scope: "cc98-api",
state: ""
}

const URL = 'https://openid.cc98.org/connect/authorize?'
+ Object.keys(param).map(key =>
+ Object.keys(param).map((key: keyof typeof param) =>
`${encodeURIComponent(key)}=${encodeURIComponent(param[key])}`
).join('&')

Expand Down
21 changes: 9 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"compilerOptions": {
"strictNullChecks": true,
// "module": "es6",
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"target": "es6",
// "allowJs": true,

"jsx": "preserve",
"sourceMap": false,
"pretty": true,

"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"baseUrl": ".",
"rootDir": "src",
"noImplicitAny": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
},

"exclude": [
"node_modules",
"dist",
]
}
Loading

0 comments on commit 5b21152

Please sign in to comment.