Conversation
components/checkbox/checkbox.js
Outdated
Checkbox.defaultProps = { | ||
checked: false, | ||
disabled: false, | ||
inputAttr: {}, |
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.
potential reference issue, see: #45 (comment)
components/checkbox/checkbox.js
Outdated
checked, | ||
children, | ||
disabled, | ||
inputAttr, |
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.
any use case for inputAttr
and labelAttr
?
components/dropDown/dropDown.scss
Outdated
color: $tx-dropdown-filter-select-placeholder-color; | ||
font-size: 13px; | ||
font-weight: bold; | ||
line-height: 28px; // should equal to .Select-control, .Select-input height |
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.
why not to use variable then?
components/dropDown/dropDown.scss
Outdated
} | ||
} | ||
|
||
&.cars-dropdown .Select-arrow-zone { |
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.
cars
this should not be here
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.
oops) Thanks for catch
import Checkbox from '../checkbox/checkbox'; | ||
|
||
/** | ||
* @property {Function} onSelect Passed by react-select internally |
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.
would be also nice to have some description what is this component about
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.
Will do
disabled: PropTypes.bool, | ||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
}), |
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.
should be isRequired
themes/_default.yaml
Outdated
background-color: *blank | ||
border-color: *secondary | ||
hover: | ||
color: *twitter |
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.
semantically it is not correct. did you check it against other brands?
vendors/react-select/control.scss
Outdated
display: inline-block; | ||
font-family: inherit; | ||
font-size: inherit; | ||
// height: $select-input-internal-height; |
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.
?
vendors/react-select/components.scss
Outdated
@@ -0,0 +1,5 @@ | |||
@import "control"; |
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.
is it possible to use react-select
as npm module?
components/checkbox/checkbox.js
Outdated
/** | ||
* Represents the callback for onChange event. | ||
*/ | ||
onChange: PropTypes.func.isRequired, |
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.
why is it required?
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.
@EduardTrutsyk good question. I am assuming it's because this component is a controlled component and therefore it requires an onChange
definition (more at: https://facebook.github.io/react/docs/forms.html )
However, I do agree that either we decide to not have a controlled component (therefore the style and value will come from the normal checked
attribute on the checkbox, or we go for this approach and then we'll need state, since you need to change the checked
attribute (since you can't mutate props nor change them from the inside).
|
||
optionClassName && classes.push(optionClassName); | ||
isSelected && classes.push('is-selected'); | ||
isFocused && classes.push('is-focused'); |
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.
now, you can use object instead of array, to apply classes based on props:
const mods = {
'is-focused': isFocused,
'is-selecte': isSelected
};
<Option classNames={getClassNamesWithMods('Select-option', mods)} />
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.
I need class names without concatenation
components/dropDown/dropDown.js
Outdated
const isFiltermode = this.props.filterMode; | ||
const mods = []; | ||
isFiltermode && mods.push('filter'); | ||
isFiltermode && this.props.options.some(option => option.checked) && mods.push('state-active'); |
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.
same here
components/dropDown/dropDown.js
Outdated
/** | ||
* Initial field value | ||
*/ | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array, PropTypes.object]), |
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.
PropTypes.any
?
components/dropDown/dropDown.scss
Outdated
padding: 10px 22px; | ||
|
||
&:first-child { | ||
&:after, &:before { |
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.
Better to use new line
&:after,
&:before {
@import "./global/global.scss"; | ||
@import "./collapse/collapseItem.scss"; | ||
@import "./list/list.scss"; | ||
@import "./modal/modal.scss"; | ||
@import "./price/price.scss"; | ||
@import "./radioButton/radioButton.scss"; | ||
@import "./spinner/spinner.scss"; | ||
@import "~react-select/scss/default.scss"; |
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.
I guess, external styles better to include in the top of file, isn't it?
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.
Need for !default;
return ( | ||
<label className={className} htmlFor={name}> | ||
<input | ||
aria-checked={checked} |
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.
lovely ❤️
components/checkbox/checkbox.js
Outdated
role="radio" | ||
type="checkbox" | ||
/> | ||
<span className="ui-checkbox__text" /> |
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.
Why do you have a closed <span>
? Shouldn't it wrap the {children}
?
components/checkbox/checkbox.js
Outdated
/** | ||
* Represents the callback for onChange event. | ||
*/ | ||
onChange: PropTypes.func.isRequired, |
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.
@EduardTrutsyk good question. I am assuming it's because this component is a controlled component and therefore it requires an onChange
definition (more at: https://facebook.github.io/react/docs/forms.html )
However, I do agree that either we decide to not have a controlled component (therefore the style and value will come from the normal checked
attribute on the checkbox, or we go for this approach and then we'll need state, since you need to change the checked
attribute (since you can't mutate props nor change them from the inside).
components/dropDown/dropDown.js
Outdated
this.menuRenderer = this.menuRenderer.bind(this); | ||
} | ||
|
||
optionRef = (onOptionRef, isSelected) => ref => onOptionRef(ref, isSelected); |
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.
Can you change it to a simple method instead of an arrow function? You're returning another function it gets complicated to read:
static optionRef(onOptionRef, isSelected) {
return ref => onOptionRef(ref, isSelected);
},
And then change its usage to: Dropdown.optionRef()
, since it doesn't require to be bound to this
.
WHAT DOES THIS PR DO:
Adds the DropDown and Checkbox component to Travix UI Kit.
WHERE SHOULD THE REVIEWER START:
Diffs
UNIT AND/OR FUNCTIONAL TESTS:
Adds Unit tests for DropDown and Checkbox component