-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a search bar to filter components #91
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
|
||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
|
||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
|
||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
|
||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
|
||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
|
||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
|
||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
|
||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
|
||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var TextFilter = function (_React$Component) { | ||
(0, _inherits3.default)(TextFilter, _React$Component); | ||
|
||
function TextFilter() { | ||
(0, _classCallCheck3.default)(this, TextFilter); | ||
return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(TextFilter).apply(this, arguments)); | ||
} | ||
|
||
(0, _createClass3.default)(TextFilter, [{ | ||
key: 'onChange', | ||
value: function onChange(event) { | ||
var filterText = event.target.value; | ||
this.props.onChange(filterText); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var mainStyle = { | ||
border: '1px solid #ECECEC', | ||
borderRadius: 2 | ||
}; | ||
|
||
var filterTextWrapStyle = { | ||
background: '#F7F7F7', | ||
paddingRight: 25 | ||
}; | ||
|
||
var filterTextStyle = { | ||
fontSize: 12, | ||
color: '#828282', | ||
border: 'none', | ||
padding: 5, | ||
display: 'block', | ||
width: '100%', | ||
boxSizing: 'border-box', | ||
outline: 'none' | ||
}; | ||
|
||
var clearButtonStyle = { | ||
position: 'absolute', | ||
color: '#B1B1B1', | ||
border: 'none', | ||
padding: 3, | ||
width: 25, | ||
right: 0, | ||
top: 0, | ||
textAlign: 'center', | ||
boxSizing: 'border-box', | ||
cursor: 'pointer' | ||
}; | ||
|
||
return _react2.default.createElement( | ||
'div', | ||
{ style: mainStyle }, | ||
_react2.default.createElement( | ||
'div', | ||
{ style: filterTextWrapStyle }, | ||
_react2.default.createElement('input', { | ||
style: filterTextStyle, | ||
type: 'text', | ||
placeholder: 'Filter', | ||
name: 'filter-text', | ||
value: this.props.filterText, | ||
onChange: this.onChange.bind(this) | ||
}) | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ | ||
style: clearButtonStyle, | ||
onClick: this.props.onClear | ||
}, | ||
'x' | ||
) | ||
); | ||
} | ||
}]); | ||
return TextFilter; | ||
}(_react2.default.Component); | ||
|
||
exports.default = TextFilter; | ||
|
||
|
||
TextFilter.propTypes = { | ||
filterText: _react2.default.PropTypes.string, | ||
onChange: _react2.default.PropTypes.func, | ||
onClear: _react2.default.PropTypes.func | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accept these events via props in the component you create as mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do
this.filterStoryList=this.filterStoryList.bind(this)
in the constructor . Here it will create a different listener on every re-render.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that's fine for specially this kind of apps since we won't render items in often. (Often means few times a sec)
And js.bind is pretty fast and React does a lot more costly stuff for virtual DOM diffing.