Skip to content

Commit 2f9e97e

Browse files
committed
Redux 対応及び Material-UI 切り替え fix #14
1 parent 78ae170 commit 2f9e97e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7002
-1104
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"presets": ["es2015", "react"],
2+
"presets": ["es2015", "stage-0", "react"],
33
"plugins": [
44
["transform-runtime", {"polyfill": true, "regenerator": true}]
55
]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
bower_components
33
public
44
npm-debug.log
5+
/.vscode

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ sample-ui-react
33

44
### はじめに
55

6-
[BootStrap](http://getbootstrap.com/) / [React.js](https://facebook.github.io/react/) を元にしたプロジェクト Web リソース ( HTML / CSS / JS ) です。 SPA ( Single Page Application ) モデルを前提としています。
6+
[Material-UI](http://www.material-ui.com) / [React.js](https://facebook.github.io/react/) / [Redux](https://github.com/reactjs/redux) を元にしたプロジェクト Web リソース ( HTML / CSS / JS ) です。 SPA ( Single Page Application ) モデルを前提としています。
77

88
サンプル確認用の API サーバとして [sample-boot-hibernate](https://github.com/jkazama/sample-boot-hibernate) を期待します。
99

1010
`※ライブラリではなく上記ライブラリを用いた単純な実装サンプルです。`
1111

12+
> Flux 風な Redux を利用していますが、純粋な Flux サンプルとは異なる点に注意してください
13+
1214
#### ビルド/テスト稼働環境構築
1315

14-
ビルドは [Node.js](http://nodejs.jp/) + [Webpack](https://webpack.github.io/) + [Gulp](http://gulpjs.com/) で行います。以下の手順でインストールしてください。
16+
ビルドは [Node.js](http://nodejs.jp/) + [Webpack](https://webpack.github.io/) + [Gulp](http://gulpjs.com/) + [Yarn](https://yarnpkg.com/) or [npm](https://www.npmjs.com/) で行います。以下の手順でインストールしてください。
1517

1618
1. Node.js の[公式サイト](http://nodejs.jp/)からインストーラをダウンロードしてインストール。
1719
1.`npm install -g gulp` 」 を実行して Gulp をインストール。
1820
- Mac ユーザは 「 `sudo npm install -g gulp` 」 で。
19-
1. コンソールで本ディレクトリ直下へ移動後、 「 `npm install` 」 を実行して Gulp ライブラリをインストール。
21+
1.`npm install -g yarn` 」を実行して Yarn をインストール。
22+
- Mac ユーザは 「 `sudo npm install -g yarn` 」 で。
23+
- インストール作業を npm 経由で直接実行する場合は不要です
24+
1. コンソールで本ディレクトリ直下へ移動後、「 `yarn` 」を実行して `package.json` 内のライブラリをインストール
25+
- Yarn を利用しない時は 「 `npm install` 」 を実行。
2026
- node-sass あたりでビルドに失敗した場合は、 「 `npm uninstall node-sass` 」 を実行してから再度試してみてください。
2127

2228
### 動作確認
@@ -31,7 +37,7 @@ sample-ui-react
3137

3238
### 開発の流れ
3339

34-
基本的にテンプレート ( .pug / .scss / .js ( ES6 ) ) を Web リソース ( .html / .css / .js ) へ Gulp / Webpack でリアルタイム変換させながら開発をしていきます。
40+
基本的にテンプレート ( .pug / .scss / .js ( Babel ) ) を Web リソース ( .html / .css / .js ) へ Gulp / Webpack でリアルタイム変換させながら開発をしていきます。
3541
動作確認は Gulp で独自に Web サーバを立ち上げた後、ブラウザ上で行います。
3642

3743
#### 各種テンプレートファイルの解説
@@ -40,8 +46,8 @@ sample-ui-react
4046
- HTML を生成するテンプレートツール。公式サイト TOP にある簡素な記法が特徴。
4147
- [Sass (SCSS)](http://sass-lang.com/)
4248
- CSS 表記を拡張するツール。変数や mixin 、ネスト表記などが利用可能。
43-
- [ES6 with Babel](https://babeljs.io/)
44-
- ES6 用の Polyfill 。 ES5 でも ES6 風に記述が可能。
49+
- [Babel](https://babeljs.io/)
50+
- ES201x 用の Polyfill 。 ES5 でも ES201x 風に記述が可能。
4551

4652
#### 各種テンプレートファイルの変更監視 / Web サーバ起動
4753

@@ -59,15 +65,18 @@ sample-ui-react
5965
### ポリシー
6066

6167
- JS / CSS の外部ライブラリは npm で管理する
62-
- jQuery や Bootstrap 等、グローバルスコープの汚染を許容するものはビルド済みリソースをそのまま流用する
68+
- ビルド時は vendor.bundle.js へ分割
6369
- プロジェクト固有の JS は Webpack を利用して生成する
64-
- グローバルスコープの汚染を許容せずにモジュールベースで開発する
65-
- React は Flux のアーキテクチャを参考に実装する
66-
- ページ遷移周りは react-router を利用
67-
- React コンポーネントは ES6 のクラスベースで実装 ( see /js/platform/react.js )
68-
- Flux は Facebook のサンプルを参考にしつつ実装 ( see /js/platform/react-flux.js )
69-
- いくつか代表的な UI パーツは準備 ( see /js/platform/react-ui.js )
70-
- Flux の良い実装が出てきたら自作せずにそちらを利用する
70+
- React / Redux はとりあえず以下の方針で
71+
- ページ遷移周りは react-router / react-router-redux を利用
72+
- React / Redux の Component 向けにサポートクラスを用意 ( see /js/platform/redux-support.js )
73+
- Redux Actions 概念をサポートクラスで簡易に ( see /js/platform/redux-action-support.js )
74+
- グローバルなステートで管理するのは横断的に保持したいもののみに限定
75+
- 入力や検索結果などの揮発性高いものはローカルなステートで
76+
- ページルートは container 配下へ配置
77+
- コンポーネントを進めていく時は component or container のサブディレクトリを掘る感じで
78+
- スタイル指定は theme.js へ集約
79+
- material-ui だとクラスベースの指定が負けそうなのでベタに指定
7180

7281
#### ディレクトリ構成
7382

@@ -76,6 +85,7 @@ sample-ui-react
7685
```
7786
gulpfile.babel.js … gulp configuration
7887
package.json … npm dependency
88+
yarn.lock … yarn semantic versioning
7989
public … deploy resources (auto generate)
8090
css
8191
- style.css … from source/css
@@ -86,21 +96,21 @@ public … deploy resources (auto generate)
8696
index.html … from source/html
8797
source
8898
css … css template files [SCSS]
89-
html … html template files [Jade]
99+
html … html template files [Pug]
90100
js
91-
actions … flux actionCreators
92-
components … react component
101+
actions … redux actions
102+
api … server acccess api
93103
constants
94-
dispatcher … flux dispatcher
104+
container … redux container component
95105
platform
96106
- plain.js … simple js library
97-
- react-flux.js … react flux implementation (simple)
98-
- react-ui.js … react ui parts
99-
- react.js … project react extension
100-
stores … flux store
101-
- app.js … root page
107+
- react-support.js … project react support
108+
- redux-support.js … project redux support
109+
- redux-action-support.js … project redux actions support
110+
reducer … redux reducer
102111
- main.js … SPA entry
103112
- routes.js … SPA routing
113+
- theme.js … material ui style
104114
static … static resources (.png/.ico/robots.txt etc)
105115
```
106116

@@ -110,18 +120,16 @@ source
110120

111121
| ライブラリ | バージョン | 用途/追加理由 |
112122
| ----------------------- | -------- | ------------- |
113-
| `superagent` | 2.3.+ | HTTP 連携ライブラリ |
114123
| `react`          | 15.4.+ | アプリケーションの UI 機能を提供 |
115124
| `react-dom`        | 15.4.+ | アプリケーションの UI 機能 ( DOM ) を提供 |
116125
| `react-router` | 3.0.+ | React.js の SPA ルーティングサポート |
117-
| `react-mixin` | 3.0.+ | Reactクラス利用時のMixin拡張 |
118-
| `wolfy87-eventemitter` | 5.1.+ | イベント連携ライブラリ |
119-
| `flux` | 3.1.+ | Facebook Flux ライブラリ |
126+
| `react-tap-event-plugin` | 2.0.+ | タップ操作のサポート |
127+
| `redux` | 3.6.+ | Flux 風な状態/イベント概念をサポート |
128+
| `react-router-redux` | 4.0.+ | Redux の状態モデルに対応した react-router |
129+
| `material-ui` | 0.17.+ | マテリアルデザインな UI ライブラリ |
120130
| `lodash`          | 4.17.+ | 汎用ユーティリティライブラリ |
121131
| `dateformat`       | 2.0.+ | 日時ライブラリ |
122-
| `jquery` | 3.1.+ | DOM 操作サポート |
123-
| `bootstrap-sass` | 3.3.+ | CSS フレームワーク |
124-
| `fontawesome` | 4.6.+ | フォントアイコンライブラリ |
132+
| `superagent` | 2.3.+ | HTTP 連携ライブラリ |
125133

126134
### License
127135

gulpfile.babel.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const paths = {
1515
dist: {
1616
root: `${root.dist}`,
1717
js: `${root.dist}/js`,
18-
css: `${root.dist}/css`,
19-
font: `${root.dist}/fonts`
18+
css: `${root.dist}/css`
2019
},
2120
node: {
2221
modules: `${__dirname}/node_modules`
@@ -32,8 +31,7 @@ const resource = {
3231
static: `${paths.src.static}/**/*`
3332
},
3433
vendor: {
35-
js: ['jquery', 'lodash', 'dateformat', "wolfy87-eventemitter", 'react', 'react-dom', "react-router", 'bootstrap-sass'],
36-
fontawesome: `${paths.node.modules}/font-awesome/fonts/**/*`
34+
js: ['lodash', 'dateformat', 'react', 'react-dom', 'react-redux', 'redux', 'react-router', 'react-router-redux', 'react-tap-event-plugin', 'material-ui']
3735
}
3836
}
3937

@@ -84,7 +82,6 @@ gulp.task('build:webpack', () => {
8482
let plugins = [
8583
new webpack.optimize.DedupePlugin(),
8684
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js"),
87-
new webpack.ProvidePlugin({jQuery: "jquery", $: "jquery"})
8885
]
8986
if (production) plugins.push(new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }, sourceMap: false }))
9087
return gulp.src(resource.src.webpack.babel)
@@ -99,7 +96,7 @@ gulp.task('build:webpack', () => {
9996
watch: !production,
10097
module: {
10198
loaders: [
102-
{test: /\.(js|jsx)$/, loader: 'babel', exclude: /node_modules/}
99+
{ test: /\.(js|jsx)$/, loader: 'babel', exclude: /node_modules/ }
103100
]
104101
},
105102
resolve: {
@@ -136,8 +133,6 @@ gulp.task('build:sass', () => {
136133

137134
// copy Static Resource
138135
gulp.task('build:static', () => {
139-
gulp.src(resource.vendor.fontawesome)
140-
.pipe(gulp.dest(paths.dist.font))
141136
return gulp.src(resource.src.static)
142137
.pipe(gulp.dest(paths.dist.root))
143138
})
@@ -149,7 +144,7 @@ gulp.task('server', () => {
149144
notify: false
150145
})
151146
// watch for source
152-
gulp.watch(resource.src.jade, ['build:jade'])
147+
gulp.watch(resource.src.pug, ['build:pug'])
153148
gulp.watch(resource.src.sass, ['build:sass'])
154149
gulp.watch(resource.src.static, ['build:static'])
155150
})

package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sample-ui-react",
3-
"version": "0.19.1",
3+
"version": "0.3.1",
44
"description": "React.js Boilerplate",
55
"main": "source/js/main.js",
66
"scripts": {
@@ -14,25 +14,27 @@
1414
"url": "https://github.com/jkazama/sample-ui-react.git"
1515
},
1616
"dependencies": {
17-
"bootstrap-sass": "~3.3.0",
18-
"co": "~4.6.0",
1917
"dateformat": "~2.0.0",
20-
"font-awesome": "~4.6.0",
21-
"jquery": "~3.1.0",
2218
"lodash": "~4.17.0",
2319
"react": "~15.4.0",
2420
"react-dom": "~15.4.0",
25-
"react-redux": "^5.0.0",
26-
"redux": "^3.6.0",
21+
"react-redux": "~5.0.0",
22+
"redux": "~3.6.0",
23+
"react-router": "~3.0.0",
24+
"react-router-redux": "~4.0.0",
25+
"material-ui": "~0.17.0",
26+
"react-tap-event-plugin": "~2.0.0",
2727
"superagent": "~2.3.0"
2828
},
2929
"devDependencies": {
30-
"babel-core": "~6.18.0",
31-
"babel-loader": "~6.2.0",
32-
"babel-plugin-transform-runtime": "~6.15.0",
33-
"babel-preset-es2015": "~6.14.0",
30+
"babel-core": "~6.23.0",
31+
"babel-loader": "~6.3.0",
32+
"babel-plugin-transform-runtime": "~6.23.0",
33+
"babel-preset-stage-0": "~6.22.0",
34+
"babel-preset-es2015": "~6.22.0",
3435
"babel-preset-react ": "~6.23.0",
35-
"babel-runtime": "~6.18.0",
36+
"babel-register": "~6.23.0",
37+
"babel-runtime": "~6.23.0",
3638
"browser-sync": "~2.17.0",
3739
"css-loader": "~0.25.0",
3840
"del": "~2.2.0",
@@ -55,6 +57,7 @@
5557
"node-sass": "~3.13.0",
5658
"pug": "~2.0.0-beta11",
5759
"pug-loader": "~2.3.0",
60+
"redux-devtools": "~3.3.2",
5861
"run-sequence": "~1.2.0",
5962
"sass-loader": "~4.0.0",
6063
"style-loader": "~0.13.0",

source/css/bootstrap.scss

Lines changed: 0 additions & 68 deletions
This file was deleted.

source/css/fontawesome.scss

Lines changed: 0 additions & 6 deletions
This file was deleted.

source/css/page-asset.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)