@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
5
5
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter' ;
6
6
import js from 'react-syntax-highlighter/dist/languages/hljs/javascript' ;
7
- import railscasts from 'react-syntax-highlighter/dist/styles/hljs/railscasts ' ;
7
+ import style from 'react-syntax-highlighter/dist/styles/hljs/atom-one-dark ' ;
8
8
9
9
SyntaxHighlighter . registerLanguage ( 'javascript' , js ) ;
10
10
@@ -18,55 +18,56 @@ const Title = styled.h1`
18
18
margin: 0;
19
19
` ;
20
20
21
- const codeString = `
22
- module.exports = {
23
- devtool: 'inline-source-map',
24
- entry: './src/index.js',
25
- output: {
26
- path: path.join(__dirname, '/build'),
27
- publicPath: '/',
28
- filename: 'bundle.js'
29
- },
30
- optimization: {
31
- splitChunks: {
32
- chunks: 'all'
33
- }
34
- },
35
- devServer: {
36
- contentBase: './build'
37
- },
38
- module: {
39
- rules: [
40
- {
41
- test: /\.(js|jsx)$/,
42
- exclude: /node_modules/,
43
- use: ['babel-loader', 'eslint-loader']
44
- }
45
- ]
21
+ const codeES6 = `
22
+ class Pattern {
23
+ constructor(el) {
24
+ this.index = 0;
25
+ this.elements = el;
26
+ }
27
+
28
+ next() {
29
+ return this.elements[this.index++];
30
+ }
31
+
32
+ hasNext() {
33
+ return this.index < this.elements.length;
34
+ }
35
+ }
36
+
37
+ export default Pattern;
38
+
39
+ ` ;
40
+
41
+ const code = `
42
+ function Pattern(el) {
43
+ this.index = 0;
44
+ this.elements = el;
45
+ }
46
+
47
+ Pattern.prototype = {
48
+ next: function() {
49
+ return this.elements[this.index++];
46
50
},
47
- plugins: [
48
- new HtmlWebpackPlugin({
49
- template: path.resolve('./index.html')
50
- }),
51
- new BundleAnalyzerPlugin({
52
- analyzerMode: 'disabled',
53
- generateStatsFile: true,
54
- statsOptions: { source: false },
55
- statsFilename: path.join(__dirname, 'stats/stats.json')
56
- })
57
- ],
58
- performance: { hints: false }
51
+ hasNext: function() {
52
+ return this.index < this.elements.length;
53
+ }
59
54
};
60
55
56
+ module.exports = Pattern;
57
+
61
58
` ;
62
59
63
60
class Welcome extends React . Component {
64
61
render ( ) {
65
62
return (
66
63
< React . Fragment >
67
64
< Title > JavaScript</ Title >
68
- < SyntaxHighlighter language = "javascript" style = { railscasts } customStyle = { { fontSize : '1.25rem' } } >
69
- { codeString }
65
+ < SyntaxHighlighter language = "javascript" style = { style } customStyle = { { fontSize : '1.25rem' } } >
66
+ { code }
67
+ </ SyntaxHighlighter >
68
+ ES6
69
+ < SyntaxHighlighter language = "javascript" style = { style } customStyle = { { fontSize : '1.25rem' } } >
70
+ { codeES6 }
70
71
</ SyntaxHighlighter >
71
72
</ React . Fragment >
72
73
) ;
0 commit comments