diff --git a/src/component/Select/index.js b/src/component/Select/index.js
index 02f3ecbb..4928daad 100644
--- a/src/component/Select/index.js
+++ b/src/component/Select/index.js
@@ -34,10 +34,26 @@ export default class Select extends Component {
option: value.length > 0 ? filterData : this.props.option,
});
}
+ renderItems(items, value) {
+ return items.map((item, idx) => {
+ return (
+
+ {item.label}
+
+ );
+ });
+ }
render() {
- const { showSearch, className, ...resetProps } = this.props;
+ const { showSearch, className, suggest, ...resetProps } = this.props;
const { visible, value, option } = this.state;
const title = this.props.option.filter(item => item.value === value);
+ const suggestItems = this.props.option.filter(item => suggest.includes(item.value));
delete resetProps.option;
delete resetProps.onSelect;
return (
@@ -57,19 +73,9 @@ export default class Select extends Component {
)}
- {option.map((item, idx) => {
- return (
-
- {item.label}
-
- );
- })}
+ {this.renderItems(suggestItems, value)}
+ {suggestItems.length > 0 &&
}
+ {this.renderItems(option, value)}
@@ -80,12 +86,14 @@ export default class Select extends Component {
Select.propsTypes = {
value: PropTypes.string,
option: PropTypes.array,
+ suggest: PropTypes.array,
showSearch: PropTypes.bool,
onSelect: PropTypes.func,
};
Select.defaultProps = {
option: [],
+ suggest: [],
value: '',
showSearch: false,
onSelect() {},
diff --git a/src/component/Select/index.less b/src/component/Select/index.less
index bcb16178..0b96bff5 100644
--- a/src/component/Select/index.less
+++ b/src/component/Select/index.less
@@ -105,6 +105,9 @@
border-radius: 3px;
box-shadow: 0 3px 12px rgba(27,31,35,0.15);
transition: all .3s;
+ .divider {
+ border-bottom: 1px solid #e4e4e4;
+ }
.optionList {
max-height: 230px;
overflow: auto;
diff --git a/src/pages/Github.js b/src/pages/Github.js
index ed773add..4df37f5b 100644
--- a/src/pages/Github.js
+++ b/src/pages/Github.js
@@ -28,6 +28,7 @@ export default class Github extends Component {
},
],
optionLang,
+ suggest: ['css', 'go', 'html', 'javascript', 'objective-c', 'python', 'swift'],
since: localStorage.getItem('github-since') || '',
lang: localStorage.getItem('github-lang') || '',
};
@@ -99,7 +100,7 @@ export default class Github extends Component {
-
+