-
Notifications
You must be signed in to change notification settings - Fork 1
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 MagicSelect #4
Merged
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3002d4a
version 1.3.1
05e46b6
require react-autocomplete #1
5577685
start working on implimenting auto-select
d6b879e
get MagicSelect roughly working #1
5b53a72
#1 handle open/close and update of magic select #1
75bec8b
impliment MagicItem list component in magic select
7eb3133
#1 split value and label in MagicItem
09903bd
#1 allow for render MagicItem wrapped in span
8d23e9e
#1 re-impliment magic item so that it doesn't make errors for passing…
4877dd6
additional test coverage #1
69d9d7d
Allow switching inner input type
06e0c31
accidently add a button group component #1
13e685a
allow icon buttons #1
e01c83a
Get magic select list type switching working #1
1e9c184
only show the magic select buttons when the magic selec tis open #1
3c8c353
rewire MagicSelect as a group and inner component
cb9a5ca
handle magic select value so it works with updates #1
39117a8
Use consistent classes and propTypes for magic group #1
0cb13b4
use a consitent label in magic group #1
0e63574
test for MagicSelect.onChange() #1
53c3522
Using magic tags in render groups #1
410d17b
clean up the message component in magic field gorup #1
fc5b44c
#1 refresh snapshots and docs
35e6ab1
#1 increase coverage for magic tag selectors
31ad27d
#1 additonal tests for magic groups
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"http://localhost:3000/main.js": "http://localhost:3000/static/js/bundle.js", | ||
"http://localhost:3000/main.js.map": "http://localhost:3000/static/js/bundle.js.map", | ||
"http://localhost:3000/static/media/logo.svg": "http://localhost:3000/static/media/logo.83748054.svg" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,80 @@ | ||
import React from 'react'; | ||
import { | ||
optionShape | ||
} from '../propTypes'; | ||
import classNames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* Create magic item for option of magic selects | ||
* | ||
* This can not be a functional component | ||
* https://github.com/reactjs/react-autocomplete/pull/293#issuecomment-371617758 | ||
* | ||
* | ||
* @param {Object} props | ||
* @return {*} | ||
* @constructor | ||
*/ | ||
export class MagicItem extends React.PureComponent { | ||
|
||
render() { | ||
return React.createElement( | ||
this.props.elementType, | ||
{ | ||
style: {background: this.props.isHighlighted ? this.props.highlightColor : this.props.notHighlighterColor}, | ||
className: classNames(this.props.className, 'magic-input-option'), | ||
|
||
}, | ||
( | ||
<React.Fragment> | ||
<span | ||
className={classNames('magic-item-label', 'magic-item-left')} | ||
|
||
> | ||
{this.props.item.value} | ||
</span> | ||
|
||
<span | ||
className={classNames('magic-item-value', 'magic-item-right')} | ||
> | ||
{this.props.item.label} | ||
</span> | ||
</React.Fragment> | ||
) | ||
); | ||
} | ||
}; | ||
|
||
/** | ||
* Prop definition for allowed element types | ||
* @type {shim} | ||
*/ | ||
const elemenetTypesProp = PropTypes.oneOf(['div', 'span']); | ||
/** | ||
* Prop definitions for MagicItem component | ||
* | ||
* @type {{item: shim, isHighlighted: shim, className: shim, highlightColor: shim, notHighlighterColor: shim}} | ||
*/ | ||
MagicItem.propTypes = { | ||
elementType: elemenetTypesProp, | ||
innerElementType: elemenetTypesProp, | ||
item: PropTypes.shape(optionShape), | ||
isHighlighted: PropTypes.bool, | ||
className: PropTypes.string, | ||
highlightColor: PropTypes.string, | ||
notHighlighterColor: PropTypes.string | ||
}; | ||
|
||
/** | ||
* Default props for the MagicItem component | ||
* | ||
* @type {{isHighlighted: boolean, highlightColor: string, notHighlightedColor: string}} | ||
*/ | ||
MagicItem.defaultProps = { | ||
elementType: 'div', | ||
innerElementType: 'div', | ||
isHighlighted: false, | ||
highlightColor: 'lightgray', | ||
notHighlightedColor: 'white', | ||
}; |
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,38 @@ | ||
import renderer from 'react-test-renderer'; | ||
import React from 'react'; | ||
import {MagicItem} from './MagicItem'; | ||
|
||
|
||
describe('MagicSelect component', () => { | ||
|
||
it('Matches snapshot', () => { | ||
const component = renderer.create( | ||
<MagicItem | ||
item={{ | ||
label: 'HTML', | ||
value: 'html' | ||
}} | ||
highlightColor={'#fff00'} | ||
notHighlighterColor={'white'} | ||
isHighlighted={true} | ||
/> | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('Can render as span', () => { | ||
const component = renderer.create( | ||
<MagicItem | ||
item={{ | ||
label: 'HTML', | ||
value: 'html' | ||
}} | ||
highlightColor={'#fff00'} | ||
notHighlighterColor={'white'} | ||
isHighlighted={true} | ||
elementType={'span'} | ||
/> | ||
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
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.
reactjs/react-autocomplete#293 (comment)