diff --git a/.babelrc b/.babelrc index c7d5a8c41..54a08e7c7 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,5 @@ { "presets": ["stage-0", "es2015", "react"], - "plugins": ["react-hot-loader/babel", "transform-runtime", "transform-class-properties", "transform-decorators-legacy"] + "plugins": ["transform-runtime", "transform-class-properties", "transform-decorators-legacy"] -} \ No newline at end of file +} diff --git a/.gitignore b/.gitignore index 399ebca63..92970d0cd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,16 +3,16 @@ /site/node_modules /site/.sass-cache /site/Makefile -/site/scripts/components/base/components -/bower_components -/local +/site/scripts/components/base +/site/styles/*.scss +/site/styles/mixins +/site/styles/modules +/site/styles/utilities /build /cache /app *.log /.idea /.sass-cache -/bower_components -Makefile scss-lint-report.xml /lib diff --git a/package.json b/package.json index aca149ffa..84c449ba1 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,10 @@ "description": "An enterprise-class UI design language and React-based implementation.", "main": "./lib/index.js", "license": "MIT", - "repository": "https://github.com/shenlq/impression.git", + "repository": { + "type": "git", + "url": "git://github.com/shenlq/impression.git" + }, "scripts": { "eslint": "eslint ./src/scripts/", "scsslint": "scss-lint src/styles/**/*.scss", @@ -16,15 +19,10 @@ "compileminscss": "sass --style compressed src/styles/index.scss lib/index.min.css", "deploy": "npm run eslint && npm run scsslint && npm run clean && npm run compilejs && npm run compilescss && npm run compileminscss && npm run copy && npm publish" }, - "repository": { - "type": "git", - "url": "git://github.com/shenlq/impression.git" - }, "homepage": "https://github.com/shenlq/impression", "dependencies": { - "classnames": ">=2.2.0", - "moment": ">=2.0.0", - "react-addons-css-transition-group": ">=15.0.0" + "classnames": "^2.2.0", + "moment": "^2.14.1" }, "devDependencies": { "babel": "^6.5.2", @@ -32,6 +30,7 @@ "babel-core": "^6.7.7", "babel-eslint": "^6.0.4", "babel-plugin-transform-class-properties": "^6.8.0", + "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-runtime": "^6.8.0", "babel-preset-es2015": "^6.6.0", "babel-preset-react": "^6.5.0", @@ -42,3 +41,4 @@ "eslint-plugin-react": "^5.0.1" } } + diff --git a/site/.babelrc b/site/.babelrc index c7d5a8c41..19fc3b0f1 100644 --- a/site/.babelrc +++ b/site/.babelrc @@ -2,4 +2,4 @@ "presets": ["stage-0", "es2015", "react"], "plugins": ["react-hot-loader/babel", "transform-runtime", "transform-class-properties", "transform-decorators-legacy"] -} \ No newline at end of file +} diff --git a/site/.eslintrc.js b/site/.eslintrc.js index 9dc1267b5..efbf30892 100644 --- a/site/.eslintrc.js +++ b/site/.eslintrc.js @@ -62,6 +62,40 @@ module.exports = { ], "no-mixed-spaces-and-tabs": [ "off" - ] + ], + "no-console": 2, + "no-alert": 2, + "no-array-constructor": 2, + "no-cond-assign": 2, + "no-const-assign": 2, + "no-constant-condition": 2, + "no-delete-var": 2, + "eqeqeq": 1, + "use-isnan": 2, + "space-in-parens": 0, + "space-before-function-paren": 0, + "space-before-blocks": 0, + "padded-blocks": 0, + "one-var": 1, + "newline-after-var": 2, + "curly": [2, "all"], + "camelcase": 2, + "block-scoped-var": 0, + "arrow-spacing": 0, + "no-with": 2, + "no-unused-expressions": 0, + "no-unreachable": 2, + "no-unneeded-ternary": 2, + "no-trailing-spaces": 1, + "no-sparse-arrays": 2, + "no-spaced-func": 2, + "no-multi-spaces": 1, + "no-fallthrough": 1, + "no-empty": 2, + "no-else-return": 2, + "no-duplicate-case": 2, + "no-dupe-keys": 2, + "no-dupe-args": 2, + "no-delete-var": 2 } -}; \ No newline at end of file +}; diff --git a/site/Gruntfile.js b/site/Gruntfile.js deleted file mode 100644 index abcdd9736..000000000 --- a/site/Gruntfile.js +++ /dev/null @@ -1,166 +0,0 @@ -module.exports = function(grunt) { - 'use strict'; - var path, webpack; - require('load-grunt-tasks')(grunt); - path = require('path'); - webpack = require('webpack'); - - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - execute: { - target: { - src: ['server.js'] - } - }, - clean: { - all: { - src: ["build/**/*"] - } - }, - copy: { - impression: { - files: [{ - expand: true, - cwd: '../src/scripts', - src: ['**/*'], - dest: 'scripts/components/base/' - }] - }, - img: { - files: [{ - expand: true, - cwd: 'images', - src: ['**/*'], - dest: 'build/images/' - }] - }, - font: { - files: [{ - expand: true, - cwd: '../src/styles/font-awesome', - src: ['fonts/*'], - dest: 'build/styles/' - }] - }, - html: { - files: [{ - expand: true, - cwd: './', - src: ['*.html'], - dest: 'build/' - }], - options: { - process: function(content, srcpath) { - return content.replace(/<\/body>/, ""); - } - } - }, - animate: { - files: [{ - expand: true, - cwd: '../src/styles/animate', - src: ['*.css'], - dest: 'build/styles/animate' - }] - } - }, - sass: { - dist: { - options: { - sourcemap: 'auto', - trace: false, - quiet: false, - debugInfo: false, - lineNumbers: false, - update: true - }, - files: [{ - expand: true, - cwd: '../src/styles/', - src: 'index.scss', - dest: 'build/styles/', - ext: '.css' - }, { - expand: true, - cwd: '../src/styles', - src: 'font-awesome/index.scss', - dest: 'build/styles/', - ext: '.css' - }] - } - }, - autoprefixer: { - options: { - browsers: ['last 100 version', '> 99%'] - }, - auto: { - expand: true, - flatten: true, - src: 'build/styles/*.css', - dest: 'build/styles/' - } - }, - cssmin: { - core: { - options: { - keepSpecialComments: 0, - report: "gzip" - }, - files: [{ - expand: true, - cwd: 'build/styles', - src: ['**/*.css'], - dest: 'build/styles/' - }] - } - }, - watch: { - sass: { - files: '../src/styles/**/*.scss', - tasks: ['sass', 'autoprefixer'] - }, - impression: { - files: '../src/scripts/**/*.js', - tasks: ['copy:impression'] - } - }, - uglify: { - options: { - mangle: { - except: ['$super', '$', 'exports', 'require', 'module'] - }, - report: 'gzip', - preserveComments: false - }, - js: { - files: [{ - expand: true, - cwd: "build/", - src: ["scripts/*.js"], - dest: "build/" - }] - } - }, - eslint: { - target: ['../src/scripts/**/*.js', 'scripts/**/*.js'] - }, - scsslint: { - allFiles: [ - '../src/styles/**/*.scss', - 'styles/**/*.scss', - ], - options: { - exclude: ['../src/styles/font-awesome/**'], - // bundleExec: true, - config: '.scss-lint.yml', - reporterOutput: 'scss-lint-report.xml', - colorizeOutput: true - } - }, - }); - - grunt.registerTask('default', ['eslint', 'clean', 'copy:img', 'copy:impression', 'sass', 'copy:font', 'autoprefixer','execute']); - - grunt.registerTask('ready', ['eslint', 'clean']); - grunt.registerTask('deploy', ['copy:html', 'copy:img', 'sass', 'copy:font','autoprefixer','cssmin','uglify']); -}; diff --git a/site/gulpfile.js b/site/gulpfile.js new file mode 100644 index 000000000..e96dd3cf6 --- /dev/null +++ b/site/gulpfile.js @@ -0,0 +1,63 @@ +var gulp = require('gulp'), + clean = require('gulp-clean'), + sass = require('gulp-sass'), + watch = require('gulp-watch'), + imagemin = require('gulp-imagemin'), + cssmin = require('gulp-minify-css'), + sequence = require('gulp-run-sequence'), + autoprefixer = require('gulp-autoprefixer'); + + +//清空 +gulp.task('clean', function(){ + return gulp.src('build', {read: false}) + .pipe(clean({force: true})); +}); + +//复制图片 +gulp.task('copy-image', function(){ + return gulp.src('images/*.*') + .pipe(imagemin({verbose: true})) + .pipe(gulp.dest('build/images')); +}); + +//复制字体 +gulp.task('copy-font', function(){ + return gulp.src('styles/font-awesome/fonts/**') + .pipe(gulp.dest('build/styles/fonts')); +}); + +//复制HTML +gulp.task('copy-html', function(){ + return gulp.src('index.html') + .pipe(gulp.dest('build')); +}); + +//编译impress +gulp.task('sass-index', function(){ + return gulp.src('styles/index.scss') + .pipe(sass().on('error', sass.logError)) + .pipe(autoprefixer({browsers: ['last 30 version', '> 90%']})) + .pipe(cssmin()) + .pipe(gulp.dest('build/styles')); +}); + +//编译font-awesome +gulp.task('sass-fontawesome', function(){ + return gulp.src('styles/font-awesome/index.scss') + .pipe(sass().on('error', sass.logError)) + .pipe(autoprefixer({browsers: ['last 30 version', '> 90%']})) + .pipe(cssmin()) + .pipe(gulp.dest('build/styles/font-awesome')); +}); + +//监听 +gulp.task('watch', function(){ + gulp.watch('styles/**/*.scss', ['sass-index']); +}); + + +//本地启动 +gulp.task('build', function(cb) { + sequence('clean', ['copy-html', 'copy-image', 'copy-font'], ['sass-index', 'sass-fontawesome'], cb); +}); diff --git a/site/package.json b/site/package.json index 5324a8c48..989d442b1 100644 --- a/site/package.json +++ b/site/package.json @@ -1,10 +1,22 @@ { "name": "impression-react-site", "version": "0.1.14", + "license": "MIT", "description": "An enterprise-class UI design language and React-based implementation.", "main": "./lib/index.js", "scripts": { - "start": "node server.js" + "eslint": "eslint ./scripts/", + "start": "npm run eslint && gulp build && node server.js", + "watch": "gulp watch", + "copy-impression-css": "cp -R ../src/styles/** styles", + "copy-impression-js": "cp -R ../src/scripts/** scripts/components/base", + "cover-impression": "npm run cover-impression-css && npm run cover-impression-js", + "cover-impression-css": "cp -R styles/** ../src/styles", + "cover-impression-js": "cp -R scripts/components/base/** ../src/scripts", + "copy-impression": "npm run copy-impression-css && npm run copy-impression-js", + "prebuild": "npm run eslint", + "build": "webpack -p --config webpack.prod.config.js", + "postbuild": "qrsboxcli init yZmkBSuvBPOa95u3k0gk2370mIFScnM2OD1ZiR9Y WXoHzZJA973FpOPPm0h1uRqn66ppXqWfP36ANF41 ./build dada-crm impression/0.1.16/ && qrsboxcli sync &" }, "repository": { "type": "git", @@ -15,8 +27,8 @@ "classnames": "^2.2.5", "react": "^15.2.0", "react-addons-css-transition-group": "^15.2.0", - "react-dom": "^15.2.0", - "react-router": "^2.5.0" + "react-dom": "^15.3.0", + "react-router": "^2.6.1" }, "devDependencies": { "babel": "^6.5.2", @@ -37,37 +49,19 @@ "eslint-plugin-flow-vars": "^0.3.0", "eslint-plugin-react": "^5.0.1", "file-loader": "^0.8.5", - "grunt": "^1.0.1", - "grunt-autoprefixer": "^3.0.4", - "grunt-contrib-clean": "^1.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-cssmin": "^1.0.1", - "grunt-contrib-sass": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-contrib-watch": "^1.0.0", - "grunt-eslint": "^18.1.0", - "grunt-execute": "^0.2.2", - "grunt-scss-lint": "^0.3.8", "gulp": "^3.9.1", "gulp-autoprefixer": "^3.1.1", "gulp-clean": "^0.3.2", - "gulp-copy": "0.0.2", "gulp-imagemin": "^3.0.3", "gulp-minify-css": "^1.2.4", + "gulp-run-sequence": "^0.3.2", "gulp-sass": "^2.3.2", - "gulp-uglify": "^2.0.0", "gulp-watch": "^4.3.9", "html-webpack-plugin": "^2.16.0", "json-loader": "^0.5.4", - "load-grunt-tasks": "^3.5.0", "node-libs-browser": "^1.0.0", "node-sass": "^3.6.0", - "react-hot-loader": "^3.0.0-beta.1", - "redux-devtools": "^3.2.0", - "redux-devtools-dock-monitor": "^1.1.1", - "redux-devtools-log-monitor": "^1.0.11", - "redux-logger": "^2.6.1", - "sass-loader": "^3.2.0", + "react-hot-loader": "^3.0.0-beta.2", "url-loader": "^0.5.7", "webpack": "^1.13.0", "webpack-dev-server": "^1.14.1" diff --git a/site/scripts/components/base.js b/site/scripts/components/base.js deleted file mode 100644 index e74a31ae8..000000000 --- a/site/scripts/components/base.js +++ /dev/null @@ -1,48 +0,0 @@ -export { - Flex, - Row, - Col, - Card, - Square, - Content, - Icon, - Button, - ButtonGroup, - ButtonToolbar, - Image, - Attention, - Tag, - Badge, - Pagination, - Checkbox, - CheckboxGroup, - Radio, - RadioGroup, - Switch, - Select, - Input, - InputGroup, - Form, - Nav, - Navbar, - Sidebar, - ListGroup, - Breadcrumb, - Progress, - Modal, - Confirm, - Tooltip, - Popover, - Dropdown, - Message, - Notification, - DatePicker, - Timeline, - Loading, - Calendar, - InlineSelect, - Alert, - Split, - Container, - Upload -} from '../../../src/scripts'; diff --git a/site/scripts/containers/Layout.js b/site/scripts/containers/Layout.js index c0ecfe03c..6d7311484 100644 --- a/site/scripts/containers/Layout.js +++ b/site/scripts/containers/Layout.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import Header from './Header'; import Sidebar from './Sidebar'; import { Flex, Square, Content } from '../components/base'; @@ -34,4 +34,4 @@ export default class Layout extends Component { } } -Layout.title = 'Home'; \ No newline at end of file +Layout.title = 'Home'; diff --git a/site/scripts/index.js b/site/scripts/index.js index 3e97a248f..9b05fcee4 100755 --- a/site/scripts/index.js +++ b/site/scripts/index.js @@ -2,11 +2,12 @@ import React from 'react'; import { render } from 'react-dom'; import App from './containers/App'; -const root = document.getElementById('root'); +const root = document.getElementById('root'); //Hot loader if (module.hot){ let AppContainer = require('react-hot-loader').AppContainer; + render( @@ -17,6 +18,7 @@ if (module.hot){ //v3.0.0起支持组件热加载 module.hot.accept('./containers/App', () => { let App = require('./containers/App').default; + render( diff --git a/site/scripts/views/CalendarView.js b/site/scripts/views/CalendarView.js index ee0c11396..cba549114 100644 --- a/site/scripts/views/CalendarView.js +++ b/site/scripts/views/CalendarView.js @@ -61,6 +61,7 @@ export default class CalendarView extends Component{ } checkDateClickHandle(date){ let { days } = this.state; + if(!date.inMonth){ return false; } @@ -108,4 +109,4 @@ export default class CalendarView extends Component{ } } -CalendarView.title = 'Calendar'; \ No newline at end of file +CalendarView.title = 'Calendar'; diff --git a/site/scripts/views/CardView.js b/site/scripts/views/CardView.js index 350826cdd..e46a1326d 100644 --- a/site/scripts/views/CardView.js +++ b/site/scripts/views/CardView.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Card, Row, Col, Button, Image, Breadcrumb } from '../components/base'; +import { Card, Row, Col, Button, Image, Breadcrumb } from '../components/base'; import { CommenTable } from '../components'; export default class CardView extends Component{ @@ -172,4 +172,4 @@ export default class CardView extends Component{ } } -CardView.title = 'Card'; \ No newline at end of file +CardView.title = 'Card'; diff --git a/site/scripts/views/DropdownView.js b/site/scripts/views/DropdownView.js index 3bda4dc95..a85305e3a 100644 --- a/site/scripts/views/DropdownView.js +++ b/site/scripts/views/DropdownView.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Card, Button, Dropdown, Breadcrumb } from '../components/base'; +import { Card, Button, Dropdown, Breadcrumb } from '../components/base'; import { CommenTable } from '../components'; export default class DropdownView extends Component{ @@ -43,4 +43,4 @@ export default class DropdownView extends Component{ } } -DropdownView.title = 'Dropdown'; \ No newline at end of file +DropdownView.title = 'Dropdown'; diff --git a/site/scripts/views/InputView.js b/site/scripts/views/InputView.js index c7fa9b553..bad6ac7eb 100644 --- a/site/scripts/views/InputView.js +++ b/site/scripts/views/InputView.js @@ -22,6 +22,7 @@ export default class InputView extends Component{ */ toggleModalHandle(){ let { show } = this.state; + this.setState({ show: !show }); diff --git a/site/scripts/views/LoadingView.js b/site/scripts/views/LoadingView.js index 301bbe3fe..b71c5abf9 100644 --- a/site/scripts/views/LoadingView.js +++ b/site/scripts/views/LoadingView.js @@ -54,7 +54,7 @@ export default class LoadingView extends Component{