From 8768c69a75270218e91fe56fb19b5c74b0f3aa72 Mon Sep 17 00:00:00 2001
From: nikogu <644506165@qq.com>
Date: Wed, 6 Sep 2017 16:34:37 +0800
Subject: [PATCH] update searchinput
---
src/components/SearchInput/index.js | 50 +++++++++++++++++++++------
src/components/SearchInput/index.less | 21 -----------
2 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/src/components/SearchInput/index.js b/src/components/SearchInput/index.js
index e5e4403c..36bb90ff 100644
--- a/src/components/SearchInput/index.js
+++ b/src/components/SearchInput/index.js
@@ -3,13 +3,43 @@ import { Button, Input } from 'antd';
import styles from './index.less';
-export default ({ onSearch = () => ({}), text = '搜索', ...reset }) => (
-
- {text}}
- />
-
-);
+export default class SearchInput extends React.Component {
+ state = {
+ value: this.props.defaultValue,
+ }
+
+ handleOnChange = (e) => {
+ this.setState({
+ value: e.target.value,
+ });
+ }
+
+ handleOnSearch = () => {
+ if (this.props.onSearch) {
+ this.props.onSearch(this.state.value);
+ }
+ }
+
+ handleOnKey = (e) => {
+ if (e.keyCode === 13) {
+ this.handleOnSearch();
+ }
+ }
+
+ render() {
+ const { text = '搜索', reset } = this.props;
+ return (
+
+ {text}}
+ />
+
+ );
+ }
+}
diff --git a/src/components/SearchInput/index.less b/src/components/SearchInput/index.less
index 7d00f448..2e8ab24b 100644
--- a/src/components/SearchInput/index.less
+++ b/src/components/SearchInput/index.less
@@ -1,5 +1,4 @@
@import "~antd/lib/style/themes/default.less";
-@import "../../utils/utils.less";
.search {
display: inline-block;
@@ -23,23 +22,3 @@
height: 40px;
}
}
-
-@media screen and (max-width: @screen-sm) {
- .search {
- :global {
- .ant-input-group .ant-input {
- width: 300px;
- }
- }
- }
-}
-
-@media screen and (max-width: @screen-xs) {
- .search {
- :global {
- .ant-input-group .ant-input {
- width: 200px;
- }
- }
- }
-}
--
GitLab