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

[Feature, Refactor]Order shopping list items by time frame + Code Organization #41

Merged
merged 10 commits into from
Apr 21, 2020

Conversation

jendevelops
Copy link
Contributor

@jendevelops jendevelops commented Apr 15, 2020

Description

  • Abstract out shoppingListInput as it's own separate component called ShoppingListItem for better clarity and modularity
  • Change ShoppingList html elements from unordered list to a table, so users can better utilize all the information stored in firebase in an easy to read format
  • Abstracted the normalizeString function from AddItemForm into /lib/normalizeString.js as a helper function that is available app-wide
  • Create helper function filterShoppingListByTimeframe that prefilters the shopping list (utilizes normalizeString previously added to /lib/) taken from firebase before setting to local shoppingListItems state

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

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
💯 Add tests
🔗 Update dependencies
📜 Docs

@jendevelops jendevelops changed the title Jvb dk sort by timeframe [Feature, Refactor]Order shopping list items by time frame + Code Organization Apr 15, 2020
//does not consider a case where timeFrame is none of these

return seven.concat(fourteen).concat(thirty);
};
Copy link
Contributor

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

dkimlim added 2 commits April 15, 2020 19:20
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) => {
Copy link
Contributor

@laurenmbeatty laurenmbeatty Apr 18, 2020

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';

Copy link
Contributor

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';

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

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

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.

Copy link
Contributor Author

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.

@laurenmbeatty
Copy link
Contributor

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}

Copy link
Contributor

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!

Copy link
Contributor

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

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!

Copy link
Contributor

@AshlingH AshlingH left a 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!

Copy link
Contributor

@jonbascos jonbascos left a 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}
Copy link
Contributor

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

Copy link
Contributor

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.

@laurenmbeatty
Copy link
Contributor

Screen reader info is perfect. nice work.

@laurenmbeatty
Copy link
Contributor

image

Copy link
Contributor

@laurenmbeatty laurenmbeatty left a comment

Choose a reason for hiding this comment

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

This looks amazing. 💖

@dkimlim dkimlim merged commit efaaec5 into master Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants