Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Dropdown and Checkbox component #49

Merged
merged 34 commits into from Apr 4, 2017

Conversation

AlleeX
Copy link
Contributor

@AlleeX AlleeX commented Mar 24, 2017

WHAT DOES THIS PR DO:

Adds the DropDown and Checkbox component to Travix UI Kit.

selection_232

selection_233

WHERE SHOULD THE REVIEWER START:

Diffs

UNIT AND/OR FUNCTIONAL TESTS:

Adds Unit tests for DropDown and Checkbox component

@AlleeX AlleeX changed the title Dropdown Dropdown and Checkbox component Mar 24, 2017
Checkbox.defaultProps = {
checked: false,
disabled: false,
inputAttr: {},
Copy link
Contributor

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)

checked,
children,
disabled,
inputAttr,
Copy link
Contributor

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?

@AlleeX AlleeX self-assigned this Apr 3, 2017
@AlleeX AlleeX added the patch label Apr 3, 2017
color: $tx-dropdown-filter-select-placeholder-color;
font-size: 13px;
font-weight: bold;
line-height: 28px; // should equal to .Select-control, .Select-input height
Copy link
Contributor

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?

}
}

&.cars-dropdown .Select-arrow-zone {
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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,
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be isRequired

background-color: *blank
border-color: *secondary
hover:
color: *twitter
Copy link
Contributor

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?

display: inline-block;
font-family: inherit;
font-size: inherit;
// height: $select-input-internal-height;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@@ -0,0 +1,5 @@
@import "control";
Copy link
Contributor

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?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling c006d59 on AlleeX:dropdown into 3428b75 on Travix-International:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b38a9f6 on AlleeX:dropdown into 3428b75 on Travix-International:master.

/**
* Represents the callback for onChange event.
*/
onChange: PropTypes.func.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it required?

Copy link
Contributor

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');
Copy link
Contributor

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)} />

Copy link
Contributor Author

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

const isFiltermode = this.props.filterMode;
const mods = [];
isFiltermode && mods.push('filter');
isFiltermode && this.props.options.some(option => option.checked) && mods.push('state-active');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

/**
* Initial field value
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array, PropTypes.object]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropTypes.any?

padding: 10px 22px;

&:first-child {
&:after, &:before {
Copy link
Contributor

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";
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need for !default;

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 55a458b on AlleeX:dropdown into 3428b75 on Travix-International:master.

return (
<label className={className} htmlFor={name}>
<input
aria-checked={checked}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely ❤️

role="radio"
type="checkbox"
/>
<span className="ui-checkbox__text" />
Copy link
Contributor

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}?

/**
* Represents the callback for onChange event.
*/
onChange: PropTypes.func.isRequired,
Copy link
Contributor

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).

this.menuRenderer = this.menuRenderer.bind(this);
}

optionRef = (onOptionRef, isSelected) => ref => onOptionRef(ref, isSelected);
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling d68bebf on AlleeX:dropdown into 3428b75 on Travix-International:master.

@mAiNiNfEcTiOn mAiNiNfEcTiOn merged commit 8c5f72c into Travix-International:master Apr 4, 2017
@mAiNiNfEcTiOn mAiNiNfEcTiOn added this to Done in Components Sep 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants