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

Build: Available Meals Section #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"endOfLine": "lf"
"endOfLine": "auto"
}
235 changes: 234 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^4.6.0",
Copy link
Owner

Choose a reason for hiding this comment

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

add the library for rendering so the test doesn't fail

"react": "^17.0.1",
"react-bootstrap": "^1.5.2",
"react-dom": "^17.0.1",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
Expand Down
Binary file added public/donut.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pantry.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/rice.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/tomato.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 5 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import logo from './logo.svg';
import './App.css';
import './components/MealCard/mealcard.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import Meals from './components/Meals/Meals';
import './components/Meals/meals.css';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<Meals />
Copy link
Owner

Choose a reason for hiding this comment

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

this should be removed since in future references this will cause merge conflicts

</div>
);
}
Expand Down
18 changes: 18 additions & 0 deletions src/components/MealCard/MealCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable react/prop-types */
import React, { Component } from 'react';
import { Button } from 'react-bootstrap';

export default class MealCard extends Component {
render() {
return (
<div className="card">
<img src={this.props.img} className="card-img" alt="food" />
<div className="card-body">
<h5 className="card-title">{this.props.title}</h5>
<span className="card-text">{this.props.organization}</span>
<Button className="Button">Get This Meal</Button>
</div>
</div>
);
}
}
7 changes: 7 additions & 0 deletions src/components/MealCard/__tests__/MealCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from 'react';
import * as renderer from 'react-test-renderer';
Copy link
Owner

Choose a reason for hiding this comment

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

test error here

import MealCard from '../MealCard';
it('renders apply now correctly', () => {
const tree = renderer.create(<MealCard />).toJSON();
expect(tree).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders apply now correctly 1`] = `
<div
className="card"
>
<img
alt="food"
class="card-img"
/>
<div
class="card-body"
>
<h5
class="card-title"
/>
<span
class="card-text"
/>
<button
className="Button btn btn-primary"
disabled={false}
type="button"
>
Get This Meal
</button>
</div>
</div>
`;
47 changes: 47 additions & 0 deletions src/components/MealCard/mealcard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.card{
height: 436px;
width: 270px;
top: 247px;
left: 135px;
}

.card-body{
position: relative;
}

.Button{
background-color: #E5E5E5;
height: 60px;
width: 100%;
border: 0;
border: none;
color: black;
position: absolute;
bottom: 0;
left: 0;
}

.Button:hover {
color: #fff;
background-color: #03B664;
border-color: #0062cc;
}

.card-img {
width: 270px;
height: 270px;
object-fit: cover;
}

.card-title{
position: absolute;

}

.card-text{
position: absolute;
bottom: 80px;
left: 18px;
color: gray;
}

70 changes: 70 additions & 0 deletions src/components/Meals/Meals.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { Component } from 'react';
import { Carousel, CarouselItem } from 'react-bootstrap';
import MealCard from '../MealCard/MealCard';
import '../Meals/meals.css';

export default class Meals extends Component {
render() {
return (
<div>
<div className="available-meals">
<h1 className="meals-title">Available Meals Right Now</h1>
<p className="meals-quote">
`If you dont try this app, you wont become the hero you were meant
to be`
</p>
<Carousel>
<CarouselItem>
<div className="items">
<MealCard
Copy link
Owner

Choose a reason for hiding this comment

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

i want this to me map array / object so we map it this will help when we reach the back end

img="tomato.jpg"
title="Canned Tomato Soup"
organization="Family Market"
/>
<MealCard
img="donut.jpg"
title="Pastry Box"
organization="Chocolate Bar"
/>
<MealCard
img="pantry.jpg"
title="Two days worth of pantry"
organization="7eleven"
/>
<MealCard
img="rice.jpg"
title="Rice bags"
organization="Sprout Warehouse"
/>
</div>
</CarouselItem>
<CarouselItem>
<div className="items">
<MealCard
img="tomato.jpg"
title="Canned Tomato Soup"
organization="Family Market"
/>
<MealCard
img="donut.jpg"
title="Pastry Box"
organization="Chocolate Bar"
/>
<MealCard
img="pantry.jpg"
title="Two days worth of pantry"
organization="7eleven"
/>
<MealCard
img="rice.jpg"
title="Rice bags"
organization="Sprout Warehouse"
/>
</div>
</CarouselItem>
</Carousel>
</div>
</div>
);
}
}
7 changes: 7 additions & 0 deletions src/components/Meals/__tests__/Meals.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import Meals from '../Meals';
it('renders apply now correctly', () => {
const tree = renderer.create(<Meals />).toJSON();
expect(tree).toMatchSnapshot();
});
Loading