Skip to content
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

refactor ButtonWIthIcon to replace ButtonSearch #81

Merged
merged 12 commits into from
Aug 7, 2018

Conversation

clairesunstudio
Copy link
Contributor

@clairesunstudio clairesunstudio commented Jul 19, 2018

This PR refactors ButtonWithIcon to replace and archive the ButtonSearch component. It's a step towards creating a fully configurable button pattern.
It also fixes the spacing between the text and the icon in the search button in the Search UI. See the visual differences in Search:
before:
screen shot 2018-07-19 at 7 22 40 pm
after:
screen shot 2018-07-19 at 7 30 47 pm

@clairesunstudio clairesunstudio changed the title extend ButtonWIthIcon to replace ButtonSearch refactor ButtonWIthIcon to replace ButtonSearch Jul 20, 2018
if (icon.type.name === 'SvgSearch') {
classNames += ' ma__button-search';
}
console.log(type.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be removed.

let classNames = this.props.classes.join(' ');
if (this.props.canExpand) {
const { classes, canExpand, expanded, capitalized, iconSize, iconColor, icon, type } = this.props
let classNames = classes.join(' ');
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of joining this at this line, why not join after all the logic for classNames is done? That way you can just push new items onto the classes array instead of appending potentially empty strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure will update

@@ -21,28 +21,33 @@ class ButtonWithIcon extends React.Component {
}
}
render() {
let classNames = this.props.classes.join(' ');
if (this.props.canExpand) {
const { classes, canExpand, expanded, capitalized, iconSize, iconColor, icon, type } = this.props
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a semicolon here.

const buttonProps = {
type: 'submit',
type: type,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should just be the type variable (object property shorthand).

/** The aria-label property is used to provide the label to any assistive
* technologies. This is useful if the text value is not descriptive of the
* button's functionality. */
ariaLabel: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove trailing comma.

@@ -62,7 +62,7 @@ HeaderSearch.propTypes = {
/** The placeholder text for the input */
placeholder: PropTypes.string,
/** The Search button */
buttonSearch: PropTypes.shape(ButtonSearch.propTypes),
buttonSearch: PropTypes.shape(ButtonWithIcon.propTypes),
Copy link
Contributor

Choose a reason for hiding this comment

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

This prop is no longer being used in render. I don't believe that's intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

buttonSearch is accessed on line 49

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 forgot to add the props before...

pmallett-mc
pmallett-mc previously approved these changes Jul 25, 2018
Copy link
Contributor

@pmallett-mc pmallett-mc left a comment

Choose a reason for hiding this comment

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

Curious why the changes to className handling were reverted to all strings, but otherwise this seems good to go.

@clairesunstudio
Copy link
Contributor Author

clairesunstudio commented Jul 25, 2018

@petermallett @smurrayatwork the reason i reverted the className handling change because for some reason the component rendered more than 1 time and each time the array gets more pushes and results in the following:
screen shot 2018-07-24 at 10 24 16 am
Not sure when it was doing that...

@pmallett-mc pmallett-mc dismissed their stale review July 25, 2018 19:14

something weird happened to this PR just now...

@clairesunstudio clairesunstudio force-pushed the react/buttonSearch-refactoring branch from 3382338 to 58be836 Compare July 25, 2018 19:49
@clairesunstudio
Copy link
Contributor Author

@petermallett i did something to it by mistake... it's reverted

.add(
'ButtonSearch',
withInfo(`<div>${buttonWithIconReadme}</div>`)(() => {
const props = {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want all these available as knobs for buttonsearch - i would assume search icon etc should not be an option to play with in knobs cause this is a specific variant that needs that icon type

Copy link
Contributor

@avrilpearl avrilpearl left a comment

Choose a reason for hiding this comment

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

one minor change on the search button story - but otherwise this looks good and does not cause any issues/follow up work on the search side so +++

@avrilpearl avrilpearl self-requested a review August 6, 2018 15:23
Copy link
Contributor

@avrilpearl avrilpearl left a comment

Choose a reason for hiding this comment

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

see comment above

@avrilpearl avrilpearl merged commit 4a1afa0 into develop Aug 7, 2018
@avrilpearl avrilpearl deleted the react/buttonSearch-refactoring branch August 7, 2018 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants