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

Create component for Ingredient Search Box #28

Merged
merged 6 commits into from
Jun 2, 2018

Conversation

vreddi
Copy link
Member

@vreddi vreddi commented Jun 1, 2018

No description provided.

@vreddi vreddi added the task Booked work for the product label Jun 1, 2018
src/base.scss Outdated
@@ -7,8 +7,6 @@ html {
width: 100%;
height: 100%;
margin: 0;
font-family: 'Source Sans Pro', sans-serif;

This comment was marked as resolved.

import './SearchBox.scss';

class SearchBox extends Component {
constructor(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can lose the constructor here and just assign state like this:

class SearchBox extends Component {
    state = {
        value: '',
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll still keep the constructor for clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by clarity? Your constructor is literally doing nothing that can't be done without the constructor! It's just bloat at this point...

If there's something that cant be done without the constructor then it makes sense to use the constructor

Copy link
Member Author

Choose a reason for hiding this comment

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

Babel adds the constructor in the end after the transpile and injects super with all the properties (including props). For that explicit clarity I mentioned constructor to avoid confusions but I am fine with removing it.

value: '',
};

this.onInputChange = this.onInputChange.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we lose the constructor this function will automatically be bound to the context of the class and this manual bind will become unnecessary.

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

onInputChange(event) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep function definitions consistent, I think it makes sense to keep things consistent and use the es6 function definition format here. Will also save us 3-4 lines of code.

onInputChange = ({ target: { value } }) => this.setState({ value })

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure - in that case the above comment is not needed.

const { value } = this.state;

return (
<div className="searchbox">
Copy link
Contributor

@sukritchhabra sukritchhabra Jun 1, 2018

Choose a reason for hiding this comment

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

Inconsistent class naming. I think you use hyphenated classNames everywhere, why use camel case here?

Update: Sorry i meant why use lower case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I probably missed that

$font-family: Roboto Slab, sans-serif;

position: relative;
width: 500px;

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

#29


position: relative;
width: 500px;
margin: 50px auto;

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

#29


&:focus {
+ .input-highlight {
border-top: 3px solid #8162FF;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets make the color here also a variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

same reason as above

value={value}
spellCheck={false}
/>
<span className="input-highlight">
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this but why do we need this? It would make sense if there was a character limit and work as a visual aid but right now its nothing but a glorified cursor

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose is aesthetics and design to shape the character of the ui. Anyways its not the final design. The project this is a part of is just a first pass at components. Other projects will cover the next phases

Copy link
Contributor

Choose a reason for hiding this comment

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

Im fine with this for now, but I don't think it serves any additional purpose. It may even be confusing as to what this is and what it's trying to tell a user.

Also there's a bug with this. The color doesn't persist onBlur.
bug

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

font-family: $font-family;
overflow: hidden;
}
}

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. @sukritchhabra need to fix the linter for scss files.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been looking into it and I don't think we need linting cause our webpack build takes care of breaking builds... Also css is very specific in terms of the key value pairs it requires and anything out of that scope causes the element to not be styled properly, so dont think a linter will serve any additional purpose... As far as the indentation is concerned, use the same as the rest of the project...

@@ -0,0 +1,50 @@
import React, { Component } from 'react';

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

pass

@@ -9,6 +9,8 @@
"airbnb"
],

"parser": "babel-eslint",

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

To make class member functions es6 style.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not needed... You can do it without it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sukritchhabra It is. ES6 Class functions are not in the rules of basic es-lint. Need a babel wrapper for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, you're right! I uninstalled it locally not globally while checking...

$colors-purple: #44318D;
$colors-light-purple: #8162FF;
$colors-light-gray-0: #757575;
$colors-light-gray-1: #999;
Copy link
Contributor

Choose a reason for hiding this comment

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

Incorrect line ending

this.state = {
value: '',
};
onInputChange = ({ target: { value } }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary parenthesis around this.setState, can all be condensed to one line.

$colors-purple: #44318D;
$colors-light-purple: #8162FF;
$colors-light-gray-0: #757575;
$colors-light-gray-1: #999;
Copy link
Contributor

@sukritchhabra sukritchhabra Jun 2, 2018

Choose a reason for hiding this comment

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

Lets follow this pattern for partials defined by scss and name the file _colors.scss

@@ -70,7 +70,7 @@ module.exports = {
alias: {
components: path.resolve(__dirname, 'src/components'),
state: path.resolve(__dirname, 'src/state'),
styles: path.resolve(__dirname, 'src/components/styles'),
styles: path.resolve(__dirname, 'src/assets/styles'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize we don't have a components/styles folder anymore but I think naming this folder styles is confusing... Technically assets should never hold any styles... Can we rename this to something more specific like variables / global-styles

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd still rather keep them under assets to avoid more root nodes. Also would like to treat assets more than just a dir for images. Common styles and colors can be treated as an asset.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh we should def keep it under assets but just rename it to something other than styles

Copy link
Member Author

@vreddi vreddi Jun 2, 2018

Choose a reason for hiding this comment

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

If its global-styles in assets I feel it is redundant. A dir called styles in assets is by default for a global need - to be used across the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah good point, lets name it something else then

Copy link
Member Author

Choose a reason for hiding this comment

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

styles make sense, why would you name it something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

because it's not holding styles! What makes it more confusing is that you also call the alias styles which you use within our actual styles!

@vreddi vreddi merged commit 5f3c60d into develop Jun 2, 2018
@vreddi vreddi deleted the vreddi/AutoCompleteSearchBox branch June 2, 2018 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Booked work for the product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants