-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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.
This comment was marked as resolved.
Sorry, something went wrong.
import './SearchBox.scss'; | ||
|
||
class SearchBox extends Component { | ||
constructor(props) { |
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.
We can lose the constructor here and just assign state like this:
class SearchBox extends Component {
state = {
value: '',
}
}
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'll still keep the constructor for clarity.
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.
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
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.
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); |
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.
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) { |
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.
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 })
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.
Sure - in that case the above comment is not needed.
const { value } = this.state; | ||
|
||
return ( | ||
<div className="searchbox"> |
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.
Inconsistent class naming. I think you use hyphenated classNames everywhere, why use camel case here?
Update: Sorry i meant why use lower case?
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 probably missed that
$font-family: Roboto Slab, sans-serif; | ||
|
||
position: relative; | ||
width: 500px; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
|
||
position: relative; | ||
width: 500px; | ||
margin: 50px auto; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
|
||
&:focus { | ||
+ .input-highlight { | ||
border-top: 3px solid #8162FF; |
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.
lets make the color here also a variable?
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 reason as above
value={value} | ||
spellCheck={false} | ||
/> | ||
<span className="input-highlight"> |
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 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
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.
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
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.
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.
fixed.
font-family: $font-family; | ||
overflow: hidden; | ||
} | ||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Fixed. @sukritchhabra need to fix the linter for scss files.
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'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.
This comment was marked as resolved.
Sorry, something went wrong.
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.
pass
@@ -9,6 +9,8 @@ | |||
"airbnb" | |||
], | |||
|
|||
"parser": "babel-eslint", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
To make class member functions es6 style.
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.
It's not needed... You can do it without 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.
@sukritchhabra It is. ES6 Class functions are not in the rules of basic es-lint. Need a babel wrapper for that.
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.
Ah, yes, you're right! I uninstalled it locally not globally while checking...
src/assets/styles/colors.scss
Outdated
$colors-purple: #44318D; | ||
$colors-light-purple: #8162FF; | ||
$colors-light-gray-0: #757575; | ||
$colors-light-gray-1: #999; |
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.
Incorrect line ending
this.state = { | ||
value: '', | ||
}; | ||
onInputChange = ({ target: { value } }) => ( |
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.
Unnecessary parenthesis around this.setState, can all be condensed to one line.
src/assets/styles/colors.scss
Outdated
$colors-purple: #44318D; | ||
$colors-light-purple: #8162FF; | ||
$colors-light-gray-0: #757575; | ||
$colors-light-gray-1: #999; |
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.
Lets follow this pattern for partials defined by scss and name the file _colors.scss
webpack.config.js
Outdated
@@ -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'), |
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 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
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'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.
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.
Oh we should def keep it under assets but just rename it to something other than styles
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.
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.
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.
yeah good point, lets name it something else then
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.
styles
make sense, why would you name it something else?
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.
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!
No description provided.