From 80ca442377827fff26552efe47a4637bac170165 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 11 Aug 2017 10:20:04 +0800 Subject: [PATCH] =?UTF-8?q?[improve]:=20=E7=A7=BB=E9=99=A4react-impression?= =?UTF-8?q?=E5=8C=85=E7=9A=84=E4=B8=8D=E5=BF=85=E8=A6=81=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 3 - gulpfile.js | 1 - index.html | 1 - package.json | 7 +- src/scripts/components/Breadcrumb.js | 4 +- src/scripts/components/CommenTable.js | 4 +- .../components/impression/components/Alert.js | 22 +- .../impression/components/ButtonGroup.js | 6 +- .../impression/components/Calendar.js | 19 +- .../impression/components/Checkbox.js | 18 +- .../impression/components/CheckboxGroup.js | 2 +- .../impression/components/Collapse.js | 2 +- .../impression/components/Confirm.js | 2 +- .../impression/components/Content.js | 2 +- .../impression/components/DatePicker.js | 47 +- .../impression/components/Dropdown.js | 4 +- .../impression/components/DropdownMenu.js | 2 +- .../impression/components/InlineSelect.js | 2 +- .../components/impression/components/Input.js | 23 +- .../impression/components/InputGroupInput.js | 6 +- .../impression/components/Loading.js | 4 +- .../impression/components/Message.js | 4 +- .../impression/components/MessageItem.js | 6 - .../components/impression/components/Nav.js | 27 +- .../impression/components/NavTitle.js | 11 +- .../impression/components/Notification.js | 12 +- .../impression/components/Pagination.js | 6 +- .../impression/components/Popover.js | 6 +- .../components/impression/components/Radio.js | 10 +- .../impression/components/RadioGroup.js | 2 +- .../components/impression/components/Row.js | 2 +- .../impression/components/Select.js | 6 +- .../impression/components/SidebarFooter.js | 2 +- .../impression/components/Switch.js | 4 +- .../impression/components/Tooltip.js | 6 +- .../impression/components/Upload.js | 8 +- .../components/impression/utils/system.js | 8 +- src/scripts/utils/system.js | 8 +- src/scripts/views/AttentionView.js | 8 +- src/scripts/views/CalendarView.js | 3 +- src/scripts/views/CardView.js | 22 +- src/scripts/views/DatePickerView.js | 2 +- src/scripts/views/DropdownView.js | 506 +++++++++--------- src/scripts/views/FormView.js | 8 +- src/scripts/views/MessageView.js | 180 ++++--- src/scripts/views/NotificationView.js | 180 ++++--- src/scripts/views/RadioView.js | 12 +- yarn.lock | 105 ++-- 48 files changed, 673 insertions(+), 662 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 598b09c13..46bf9e429 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,3 @@ module.exports = { "extends": "react-impression", - rules: { - "import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": true, "peerDependencies": true}] - }, }; diff --git a/gulpfile.js b/gulpfile.js index 900b9aa8f..5d8e6152a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -95,7 +95,6 @@ gulp.task('edit:package.json', function() { delete json.devDependencies; delete json.dependencies['highlight.js']; - delete json.dependencies['perfect-scrollbar']; delete json.dependencies['react-router']; return json; diff --git a/index.html b/index.html index 2044064d2..82203dd77 100755 --- a/index.html +++ b/index.html @@ -1,4 +1,3 @@ - diff --git a/package.json b/package.json index fd081df2b..4322d9f86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-impression", - "version": "1.2.21", + "version": "1.3.1", "author": "NewDadaFE", "description": "UI Components with React.", "main": "./dist/scripts/index.js", @@ -34,7 +34,7 @@ "perfect-scrollbar": "^0.6.12", "prop-types": "^15.5.10", "react": "^15.4.1", - "react-addons-css-transition-group": "^15.4.1", + "react-addons-css-transition-group": "^15.6.0", "react-dom": "^15.4.1", "react-router": "3.0.5" }, @@ -53,7 +53,8 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.5.0", "babel-runtime": "^6.11.6", - "eslint-config-react-impression": "^1.1.4", + "eslint-config-react-impression": "^1.2.0", + "eslint-loader": "^1.9.0", "file-loader": "^0.8.5", "gulp": "^3.9.1", "gulp-autoprefixer": "^3.1.1", diff --git a/src/scripts/components/Breadcrumb.js b/src/scripts/components/Breadcrumb.js index 49822f035..74ff62176 100644 --- a/src/scripts/components/Breadcrumb.js +++ b/src/scripts/components/Breadcrumb.js @@ -12,13 +12,13 @@ const WrapBreadcrumb = ({ routes }) => { { routes.map((route, index) => { if(index < length - 1) { return ( - + {route.path === 'app' ? 'home' : route.path} ); } - return {route.path}; + return {route.path}; })} ); diff --git a/src/scripts/components/CommenTable.js b/src/scripts/components/CommenTable.js index 2a8638775..a9e65feae 100644 --- a/src/scripts/components/CommenTable.js +++ b/src/scripts/components/CommenTable.js @@ -4,9 +4,9 @@ import PropTypes from 'prop-types'; * React组件 */ const CommenTable = ({ data }) => { - let rows = data.map((item, index) => { + let rows = data.map(item => { return ( - + {item[0]} {item[1]} {item[2]} diff --git a/src/scripts/components/impression/components/Alert.js b/src/scripts/components/impression/components/Alert.js index 21c6483a4..0a15acacd 100644 --- a/src/scripts/components/impression/components/Alert.js +++ b/src/scripts/components/impression/components/Alert.js @@ -1,6 +1,17 @@ import classnames from 'classnames'; import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; + +// 获取小图标 +const getAddonByType = type => { + switch(type) { + case 'danger': + return 'fa-exclamation-circle text-danger'; + default: + return 'fa-exclamation-triangle text-warning'; + } +}; + /** * Alert 组件 */ @@ -22,18 +33,9 @@ export default class Alert extends PureComponent { type: 'info', btnText: '确定', } - // 获取小图标 - getAddonByType(type) { - switch(type) { - case 'danger': - return 'fa-exclamation-circle text-danger'; - default: - return 'fa-exclamation-triangle text-warning'; - } - } render() { let { type, btnText, onClick, className, children, ...others } = this.props, - iconTypeClass = this.getAddonByType(type); + iconTypeClass = getAddonByType(type); return(
diff --git a/src/scripts/components/impression/components/ButtonGroup.js b/src/scripts/components/impression/components/ButtonGroup.js index a3b8c4176..de8fde39a 100644 --- a/src/scripts/components/impression/components/ButtonGroup.js +++ b/src/scripts/components/impression/components/ButtonGroup.js @@ -37,15 +37,15 @@ export default class ButtonGroup extends PureComponent { btnGroupSize = size ? `btn-group-${size}` : null; delete others.activeKey; - children = children.map((child, index) => { + children = children.map(child => { let { eventKey, onClick } = child.props; return React.cloneElement(child, { - key: index, + key: child, outline: theme !== 'default' && (!onSelect || activeKey !== eventKey), theme: theme === 'default' && onSelect && activeKey === eventKey ? 'primary' : theme, - onClick: onSelect ? (event) => { + onClick: onSelect ? event => { this.setState({ activeKey: eventKey, }); diff --git a/src/scripts/components/impression/components/Calendar.js b/src/scripts/components/impression/components/Calendar.js index 0db3efb10..0d03b0682 100644 --- a/src/scripts/components/impression/components/Calendar.js +++ b/src/scripts/components/impression/components/Calendar.js @@ -44,8 +44,6 @@ export default class Calendar extends Component { firstDayOfWeek: PropTypes.number, // 周几 weekdays: PropTypes.arrayOf(PropTypes.string), - // 月份 - months: PropTypes.arrayOf(PropTypes.string), // 是否显示工具栏 showToolbar: PropTypes.bool, // 是否显示头部 @@ -65,7 +63,6 @@ export default class Calendar extends Component { showHeader: true, firstDayOfWeek: 1, weekdays: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], - months: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], } /** * 获取排序后的星期. @@ -75,9 +72,9 @@ export default class Calendar extends Component { let { firstDayOfWeek, weekdays } = this.props; return firstDayOfWeek === 0 ? - weekdays : - [...weekdays.slice(firstDayOfWeek, weekdays.length), - ...weekdays.slice(0, firstDayOfWeek)]; + weekdays : + [...weekdays.slice(firstDayOfWeek, weekdays.length), + ...weekdays.slice(0, firstDayOfWeek)]; } /** * 前一个月. @@ -220,15 +217,15 @@ export default class Calendar extends Component { }
- { weekdays.map((weekday, index) => -
{weekday}
+ { weekdays.map(weekday => +
{weekday}
)}
{ days.map((day, index) => -
onCellClick && onCellClick({ day: day.text, year: day.date.format(FORMAT.YEAR), @@ -261,7 +258,7 @@ export default class Calendar extends Component { isToday: day.isToday, })}
-
+
) )}
diff --git a/src/scripts/components/impression/components/Checkbox.js b/src/scripts/components/impression/components/Checkbox.js index a055750ac..2273a6964 100644 --- a/src/scripts/components/impression/components/Checkbox.js +++ b/src/scripts/components/impression/components/Checkbox.js @@ -42,15 +42,15 @@ export default class Checkbox extends PureComponent { // 渲染 render() { let { - value, - checked, - defaultChecked, - disabled, - className, - onChange, - children, - ...others - } = this.props; + value, + checked, + defaultChecked, + disabled, + className, + onChange, + children, + ...others + } = this.props; return(