upgrade everything

This commit is contained in:
Antti Pilto 2018-11-17 01:22:44 +02:00
commit eaf95c395e
11 changed files with 11878 additions and 7546 deletions

View file

@ -1,4 +1,7 @@
{ {
"presets" : ["es2015", "react"], "presets" : [
"plugins" : ["transform-object-assign"] ["@babel/preset-env", { "useBuiltIns": "usage" }],
} "@babel/preset-react"
],
"plugins": ["@babel/plugin-proposal-class-properties"]
}

View file

@ -5,6 +5,6 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
charset = utf-8 charset = utf-8
indent_style = space indent_style = space
indent_size = 4 indent_size = 2
trim_trailing_whitespace = true trim_trailing_whitespace = true

7338
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load diff

11666
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
{ {
"name": "kanaquiz", "name": "kanaquiz",
"version": "2.0.0", "version": "2.1.0",
"description": "Application for studying hiragana & katakana characters.", "description": "Application for studying hiragana & katakana characters.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --host 0.0.0.0", "start": "webpack-dev-server --open --mode development --host 0.0.0.0 --config webpack.config.js",
"mobile": "webpack-dev-server --host 0.0.0.0 --public 192.168.1.8:8080", "mobile": "webpack-dev-server --open --mode development --host 0.0.0.0 --public 192.168.1.8:8080",
"build": "webpack -p --config webpack.config.prod.js" "build": "webpack --mode production --config webpack.config.prod.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -19,32 +19,37 @@
"url": "https://github.com/anzzstuff/kanaquiz/issues" "url": "https://github.com/anzzstuff/kanaquiz/issues"
}, },
"homepage": "https://github.com/anzzstuff/kanaquiz#readme", "homepage": "https://github.com/anzzstuff/kanaquiz#readme",
"browserslist": [
"> 0.25%",
"not dead"
],
"devDependencies": { "devDependencies": {
"autoprefixer": "^6.3.7", "@babel/core": "^7.1.6",
"babel-core": "^6.24.0", "@babel/plugin-proposal-class-properties": "^7.1.0",
"babel-loader": "^6.2.4", "@babel/preset-env": "^7.1.6",
"babel-plugin-transform-object-assign": "^6.22.0", "@babel/preset-react": "^7.0.0",
"babel-preset-es2015": "^6.9.0", "autoprefixer": "^9.3.1",
"babel-preset-react": "^6.11.1", "babel-loader": "^8.0.4",
"css-loader": "^0.27.3", "css-loader": "^1.0.1",
"file-loader": "^0.10.1", "file-loader": "^2.0.0",
"html-webpack-plugin": "^2.22.0", "html-webpack-plugin": "^3.2.0",
"postcss": "^5.0.21", "postcss": "^7.0.5",
"postcss-loader": "^1.3.3", "postcss-loader": "^3.0.0",
"precss": "^1.4.0", "precss": "^3.1.2",
"react-hot-loader": "^1.3.0", "react-hot-loader": "^4.3.12",
"style-loader": "^0.14.1", "style-loader": "^0.23.1",
"sw-precache-webpack-plugin": "^0.10.1", "sw-precache-webpack-plugin": "^0.11.5",
"url-loader": "^0.5.7", "url-loader": "^1.1.2",
"webpack": "^2.2.1", "webpack": "^4.25.1",
"webpack-dev-server": "^2.4.2" "webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
}, },
"dependencies": { "dependencies": {
"postcss": "^5.1.0", "@babel/polyfill": "^7.0.0",
"prop-types": "^15.5.8", "prop-types": "^15.6.2",
"react": "^15.2.1", "react": "^16.6.3",
"react-addons-css-transition-group": "^15.3.0", "react-dom": "^16.6.3",
"react-dom": "^15.2.1", "react-toggle-switch": "^3.0.4",
"react-toggle-switch": "^2.1.2" "react-transition-group": "^2.5.0"
} }
} }

6
postcss.config.js Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
plugins: [
require('precss'),
require('autoprefixer')
]
}

View file

@ -1,66 +1,68 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import './ShowStage.scss'; import './ShowStage.scss';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import { TransitionGroup, CSSTransition } from 'react-transition-group';
class ShowStage extends Component { class ShowStage extends Component {
constructor(props) { state = {
super(props); show: false,
this.state = { entered: false
stageContent: '' }
}
this.showStage = this.showStage.bind(this);
this.removeStage = this.removeStage.bind(this);
}
removeStage() { componentDidMount() {
this.setState({stageContent: ''}); this.setState({show: true});
clearTimeout(this.timeoutID); if(this.props.stage <= 4)
this.timeoutID = setTimeout(this.props.handleShowQuestion, 1000) // how soon we go to question (1000) this.timeoutID = setTimeout(this.removeStage, 1200); // how soon we start fading out (1500)
} window.scrollTo(0,0);
}
showStage() { componentWillUnmount() {
let stageDescription; clearTimeout(this.timeoutID);
let stageSecondaryDescription = false; }
if(this.props.stage==1) stageDescription = 'Choose one';
if(this.props.stage==2) { stageDescription = 'Choose one'; stageSecondaryDescription = 'Reverse'; }
if(this.props.stage==3) stageDescription = 'Write the answer';
if(this.props.stage==4) { stageDescription = 'Write the answer'; stageSecondaryDescription = 'Three at once'; }
let stageContent = (<div className="text-center show-stage">
<h1>Stage {this.props.stage}</h1>
<h3>{stageDescription}</h3>
{stageSecondaryDescription?<h4>{stageSecondaryDescription}</h4>:''}
</div>);
if(this.props.stage==5) { removeStage = () => {
stageContent = (<div className="text-center show-end"> this.setState({show: false});
<h1>Congratulations!</h1> clearTimeout(this.timeoutID);
<h3>You have passed all 4 stages.</h3> this.timeoutID = setTimeout(this.props.handleShowQuestion, 1000) // how soon we go to question (1000)
<h4>Would you like to keep playing or go back to menu?</h4> }
<p><button className="btn btn-danger keep-playing" onClick={()=>this.props.lockStage(4)}>Keep playing</button></p>
<p><button className="btn btn-danger back-to-menu" onClick={this.props.handleEndGame}>Back to menu</button></p>
</div>)
}
this.setState({stageContent: stageContent});
}
componentDidMount() { showStage() {
if(this.props.stage<=4) let stageDescription;
this.timeoutID = setTimeout(this.removeStage, 1200); // how soon we start fading out (1500) let stageSecondaryDescription = false;
this.showStage();
window.scrollTo(0,0);
}
componentWillUnmount() { if(this.props.stage==1) stageDescription = 'Choose one';
clearTimeout(this.timeoutID); else if(this.props.stage==2) { stageDescription = 'Choose one'; stageSecondaryDescription = 'Reverse'; }
} else if(this.props.stage==3) stageDescription = 'Write the answer';
else if(this.props.stage==4) { stageDescription = 'Write the answer'; stageSecondaryDescription = 'Three at once'; }
else if(this.props.stage==5)
return (
<div className="text-center show-end">
<h1>Congratulations!</h1>
<h3>You have passed all 4 stages.</h3>
<h4>Would you like to keep playing or go back to menu?</h4>
<p><button className="btn btn-danger keep-playing" onClick={()=>this.props.lockStage(4)}>Keep playing</button></p>
<p><button className="btn btn-danger back-to-menu" onClick={this.props.handleEndGame}>Back to menu</button></p>
</div>
);
render() { return (
return ( <div className="text-center show-stage">
<ReactCSSTransitionGroup transitionName="stage" transitionEnterTimeout={900} transitionLeaveTimeout={900}> <h1>Stage {this.props.stage}</h1>
{this.state.stageContent} <h3>{stageDescription}</h3>
</ReactCSSTransitionGroup> { stageSecondaryDescription ? <h4>{stageSecondaryDescription}</h4> : '' }
); </div>
} );
}
render() {
const content = this.showStage();
const { show } = this.state;
return (
<CSSTransition classNames="stage" timeout={{enter: 900, exit: 900}} in={show} unmountOnExit>
{state => content}
</CSSTransition>
);
}
} }
export default ShowStage; export default ShowStage;

View file

@ -30,11 +30,11 @@
transition: opacity 1s ease-in; transition: opacity 1s ease-in;
} }
.stage-leave { .stage-exit {
opacity: 1; opacity: 1;
} }
.stage-leave.stage-leave-active { .stage-exit.stage-exit-active {
opacity: 0.01; opacity: 0.01;
transition: opacity 1s ease-in; transition: opacity 1s ease-in;
} }

View file

@ -4,4 +4,4 @@ import Bootstrap from './assets/stylesheets/bootstrap.min.css';
import App from './components/App/App'; import App from './components/App/App';
let element = React.createElement(App, {}); let element = React.createElement(App, {});
render(element, document.querySelector('.app')); render(element, document.querySelector('.app'));

View file

@ -1,57 +1,53 @@
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebPackPlugin = require('html-webpack-plugin'); const HtmlWebPackPlugin = require('html-webpack-plugin');
module.exports = { module.exports = {
entry: [ resolve: {
'webpack-dev-server/client?http://localhost:8080', extensions: ['.js', '.jsx']
'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors },
'./src/index' plugins: [
], new HtmlWebPackPlugin({
output: { template: './src/index.html',
path: path.resolve(__dirname, './dist'), filename: './index.html'
publicPath: '/', })
filename: 'bundle.js' ],
}, module: {
resolve: { rules: [
extensions: ['.js', '.jsx'] {
}, test: /\.(js|jsx)$/,
plugins: [ exclude: /node_modules/,
new HtmlWebPackPlugin({ use: {
template: 'src/index.html', loader: 'babel-loader'
filename: './index.html' }
}), },
new webpack.HotModuleReplacementPlugin(), {
new webpack.LoaderOptionsPlugin({ test: /\.scss$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: { options: {
postcss: function() { importLoaders: 1
return [autoprefixer, precss];
}
}
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot-loader', 'babel-loader']
}, {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
}, {
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
}, {
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=25000'
}, {
test: /\.(eot|ttf)$/,
loader: 'file-loader'
} }
},
{
loader: 'postcss-loader'
}
] ]
} },
}; {
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=25000'
},
{
test: /\.(eot|ttf)$/,
loader: 'file-loader'
}
]
}
};

View file

@ -1,75 +1,67 @@
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const path = require('path');
module.exports = { module.exports = {
context: __dirname, context: __dirname,
devtool: 'cheap-module-source-map', output: {
entry: [ path: path.resolve(__dirname, './dist'),
'./src/index' publicPath: './dist/',
], filename: 'bundle.js'
output: { },
path: path.resolve(__dirname, './dist'), resolve: {
publicPath: './dist/', extensions: ['.js', '.jsx']
filename: 'bundle.js' },
}, plugins: [
resolve: { new SWPrecacheWebpackPlugin( {
extensions: ['.js', '.jsx'] cacheId: 'kana-quiz',
}, filename: 'sw.js',
plugins: [ stripPrefix: '/home/anzz/code/kanaquiz/',
new HtmlWebPackPlugin({ maximumFileSizeToCacheInBytes: 4194304,
template: 'src/index.html', minify: true,
filename: '../index.html' runtimeCaching: [{
}), handler: 'networkFirst',
new webpack.optimize.UglifyJsPlugin({ urlPattern: /\.(woff2|svg|ttf|eot|woff|html)$/,
sourceMap: true, }],
compress:{ })
warnings: false ],
}, module: {
}), rules: [
new webpack.NoEmitOnErrorsPlugin(), {
new webpack.LoaderOptionsPlugin({ test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: { options: {
postcss: function() { importLoaders: 1
return [autoprefixer, precss];
}
}
}),
new SWPrecacheWebpackPlugin( {
cacheId: 'kana-quiz',
filename: 'sw.js',
stripPrefix: '/home/anzz/Code/kanaquiz/',
maximumFileSizeToCacheInBytes: 4194304,
minify: true,
runtimeCaching: [{
handler: 'networkFirst',
urlPattern: /\.(woff2|svg|ttf|eot|woff|html)$/,
}],
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel-loader']
}, {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
}, {
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
}, {
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=8192'
}, {
test: /\.(eot|ttf)$/,
loader: 'file-loader'
} }
},
{
loader: 'postcss-loader'
}
] ]
} },
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=25000'
},
{
test: /\.(eot|ttf)$/,
loader: 'file-loader'
}
]
}
}; };