-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feature, Refactor]Order shopping list items by time frame + Code Organization #41
Conversation
Create helper function in lib called normalizeString,removing it from AddItemForm. Now function is available app wide. Then, it was utilized in alphabeticalSort function to filter shoppinglist items by name.
//does not consider a case where timeFrame is none of these | ||
|
||
return seven.concat(fourteen).concat(thirty); | ||
}; |
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.
V. cool!!!! I think you could also do return [...seven, ...fourteen, ...thirty]
. Just an alternative, though.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
created aria-label for accessibility screenreaders that will read a string with the item's name and timeframe.
Updated the local shopping item list to remove the inactive items before filtering them by timeframe. Added css for each timeframe in the UI of shopping list.
return "None"; | ||
} | ||
} | ||
// const getStringValue = (numberValue) => { |
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.
Maybe can rid of this? Leave it if you think you will need it, but otherwise you can remove.
@@ -3,6 +3,7 @@ import { Redirect } from 'react-router-dom'; | |||
import fb from '../lib/firebase'; | |||
import '../css/AddItemForm.css'; | |||
import moment from 'moment'; | |||
import normalizeString from '../lib/normalizeString'; | |||
|
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.
Yes!!!!! Love it.
@@ -0,0 +1,68 @@ | |||
import React from 'react'; | |||
import * as timeframeConstants from '../lib/timeframeConstants'; | |||
|
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.
Are you using timeFrameConstants
anymore?
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 plan on utilizing the constants throughout the app once fully implemented.
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.
Sounds good. If you're not using it in this file right now, though, you can remove line 2.
|
||
|
||
const ShoppingListItem = ({item,handleCheck}) => { | ||
const ariaString = `${item.itemName} to be bought in ${timeFrameString(item.timeFrame)}`; |
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.
Nice. Love that you separated this out into its own file.
import * as timeframeConstants from '../lib/timeframeConstants'; | ||
|
||
const timeFrameString = number => | ||
{ |
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.
This is not a blocker at all, but maybe these 2 functions could be combined into one since they both do essentially the same thing? The case could return an object that has both the css class and the label in it? idk.
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.
Yes, I was thinking the same thing. I was thinking of dropping the values in 2 dictionaries with the numbers as the keys, and having a 2nd argument to determine what you want returned.
Great commit messages!!!!!!! |
const KIND_OF_SOON = {stringValue: "between 7 and 30 days", integerValue: 14} | ||
const NOT_SOON = {stringValue: "more than 30 days", integerValue: 30} | ||
const INACTIVE = {stringValue: "inactive", integerValue: 0} | ||
|
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.
Brings a full circle feel to an earlier issue for Diane and I, thank you!
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.
Awesome. Great idea.
} | ||
.inactive { | ||
background-color: grey; | ||
} |
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.
From a user perspective, this is soooo helpful well done!
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.
Really good jobs guys, looking forward to hearing about your process on Sunday. As the app develops issues and items from earlier in the cohort are coming together for me. Nice approach!
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.
Excellent work you two. Love the new filterShoppingListByTimeframe function. Looks pretty clean. Can't wait to hear about it from you on Sunday.
<tr className={generateClass(item.timeFrame)}> | ||
<td> | ||
<input | ||
aria-label= {ariaString} |
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.
Great!
const fourteen = shoppingListArray.filter(item => item.timeFrame === 14).sort(alphabeticalSort); | ||
const thirty = shoppingListArray.filter(item => item.timeFrame === 30).sort(alphabeticalSort); | ||
const inactive = shoppingListArray.filter(item => item.timeFrame === 0).sort(alphabeticalSort); | ||
|
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.
Love these one-liners. Very nice.
Screen reader info is perfect. nice work. |
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.
This looks amazing. 💖
…t-shopping-list into jvb-dk-sort-by-timeframe
Description
Related Issue
Closes issue #13
Acceptance Criteria
Items in the list are shown visually grouped in the following order: Soon, Kind of soon, Not soon, Inactive (Still needs to consider inactive shopping list items)
Within each grouping, items should be sorted by the estimated number of days until next purchase
Items with the same number of estimated days until next purchase should be sorted alphabetically
Items in the different states should be visually distinct
Items in the different states should be described distinctly when read by a screen reader
Type of Changes