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 Recipe card, Add storybook support #41

Merged
merged 11 commits into from
Jul 10, 2018

Conversation

vreddi
Copy link
Member

@vreddi vreddi commented Jul 4, 2018

resolves #16

@vreddi vreddi added the task Booked work for the product label Jul 4, 2018
};

describe('ReactElementType', () => {
it('map contains alltest types', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

space between alltest

font-size: 1em;
color: #7c8a94;

&:focus {outline:0;}
Copy link
Member Author

Choose a reason for hiding this comment

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

&:focus {
  outline: 0;
}

package.json Outdated
@@ -7,6 +7,8 @@
"start": "webpack-dev-server --open",
"build": "webpack",
"test": "jest",
"clean": "rm -rf node_modules",
"reinstall": "npm run clean && npm install",
Copy link
Contributor

Choose a reason for hiding this comment

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

should also probably add npm cache clean here so we dont have any persisting modules from cache

@@ -0,0 +1,13 @@
const ReactElementType = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably have .test in the file name to be consistent.

.add('Calcium', () => (
<Chip name="calcium" />
))
.add('Vitamin B2', () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary stories here, one should be enough.

Any time we're just showing different text for a component, we should reconsider the use of storybook. It a good indication that we're using storybook incorrectly. It's meant to show different states and not different text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Talked offline and agreed with the point made.

import Yogurt from 'images/ingredients/yogurt.png';

storiesOf('IngredientCard', module)
.add('Milk', () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, will we do this for every ingredient? This is not what storybook is meant to do... We're literally changing just text.

If you want to show the theme differences, I think it would make more sense for us to use One ingredient with all the different themes.

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.

@keyframes heart-burst {
from {background-position:left;}
to { background-position:right;}
}
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

<div
className="recipe-card-image"
alt={title}
style={{ backgroundImage: `linear-gradient(to bottom, rgba(255,255,255,0) 20%, rgba(245, 242, 242, 1)), url(${image})` }}
Copy link
Contributor

Choose a reason for hiding this comment

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

What are your thoughts on using StyledComponents to do this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not a great idea to use a lib for such a small thing but might be cleaner...

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 Because I need to edit a style and not an html element attribute. The style needed here is background-image. Any better suggestions IYO?

Copy link
Member Author

Choose a reason for hiding this comment

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

What lib are you talking about? font-awesome?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah its a neat library that would make the code a bit cleaner but I'm not sure about adding a lib for this too..
@sukritchhabra how about we keep this in the back-pockets and file a backlog task. And if we have a lot of style injections like we are doing above then we can utilize the library for a cleaner way?

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

import RecipeCard from 'components/RecipeCard/RecipeCard';

storiesOf('RecipeCard', module)
.add('Lemon Grass Chicken', () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, all these stories are unnecessary, they're literally just showing different text...

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

@@ -0,0 +1,7 @@
import 'components/Chip/Chip.stories';
import 'components/CardContainer/CardContainer.stories';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move the stories out of src

Copy link
Member Author

Choose a reason for hiding this comment

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

resolved.

@@ -1,7 +1,7 @@
import { configure } from '@storybook/react';

function loadStories() {
require('../src/stories');
require('../src/storybook');
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't mean we should just scope the folders. I mean't to decouple storybook from src completely. So the stories should live in the stories folder as a sibling to src.

- package.json
- src/
- stories/
- .storybook/

This repo is a good example. https://github.com/airbnb/react-dates

Copy link
Member Author

@vreddi vreddi Jul 9, 2018

Choose a reason for hiding this comment

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

That might not be the move. I have seen plenty of repos that keep the stories in the src. Following our existing convention of __test__ being in src which utilizes the components, stories should also be in src as they too utilize components.

Further-more:
Here is what the official doc says:

"There’s no hard and fast rule for this. But, keeping stories close to your components is a good idea.

For example, let’s say your UI components live in a directory called: src/components. Then you can write stories inside the src/stories directory.

This is just one way to do that. You can always edit your storybook config file and ask it to load stories from anywhere you want."

https://storybook.js.org/basics/writing-stories/

Copy link
Contributor

Choose a reason for hiding this comment

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

Our tests aren't in src. And I personally prefer things to be decoupled as much as possible. In fact, since our tests are decoupled outside of src, it would make more sense to decouple the stories too.

Copy link
Member Author

Choose a reason for hiding this comment

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

#47

@vreddi vreddi merged commit e044714 into develop Jul 10, 2018
@vreddi vreddi deleted the vreddi/AddRecipeCard branch July 10, 2018 04:25
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.

Create component for Recipe Card
2 participants