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

cards displaying, but not centered #1

Merged
merged 1 commit into from
Apr 8, 2023
Merged
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
45 changes: 15 additions & 30 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
.App {
text-align: center;
* {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
.cardContainer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;

;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.priceFormat {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 2rem;
align-content: center;
}
48 changes: 27 additions & 21 deletions src/Components/ProductCards.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import Button from 'react-bootstrap/Button';
import Card from 'react-bootstrap/Card';
import Button from "react-bootstrap/Button";
import Card from "react-bootstrap/Card";

function ProductCards({ products }) {


return (
<div>
{products.map((products) => (
<Card style={{ width: '18rem' }} className='g-2' key={products.id}>
<Card.Img variant="top" src={products.image} />
<Card.Body>
<Card.Title>{products.prodname}</Card.Title>
<Card.Text>
{products.description}
</Card.Text>
<Button variant="primary">Buy Me</Button>
</Card.Body>
</Card>

))}
</div>
);
return (
<>
{products.map((products) => (
<div className="col p-3" key={products.key}>
<Card
style={{ width: "18rem" }}
className="shadow"
key={products.key}
>
<Card.Img variant="top" src={products.image} />
<Card.Body>
<Card.Title>{products.prodname}</Card.Title>
<Card.Text>
{products.description}
<br />
<br />
<span className="priceFormat">${products.price}</span>
</Card.Text>
<Button variant="primary">Buy Me</Button>
</Card.Body>
</Card>
</div>
))}
</>
);
}

export default ProductCards;
59 changes: 28 additions & 31 deletions src/Components/StoreFront.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import {useState, useEffect} from 'react';
import { API } from '../API/Api';
import ProductCards from './ProductCards'
import '../../node_modules/bootstrap/dist/css/bootstrap.css'


export default function StoreFront(){
const [products, setProducts] = useState([]);



useEffect(() => {
fetchProducts();
}, []);



const fetchProducts = async () => {const addProduct = await API.getProducts();
console.log(addProduct);
setProducts(addProduct);
console.log(addProduct);
};

console.log(products);
return(
<div className='container'>
<ProductCards products={products} />
</div>
)

}
import { useState, useEffect } from "react";
import { API } from "../API/Api";
import ProductCards from "./ProductCards";
import "../../node_modules/bootstrap/dist/css/bootstrap.css";

export default function StoreFront() {
const [products, setProducts] = useState([]);

useEffect(() => {
fetchProducts();
}, []);

const fetchProducts = async () => {
const addProduct = await API.getProducts();
console.log(addProduct);
setProducts(addProduct);
console.log(addProduct);
};

console.log(products);
return (
<div className="container-fluid cardContainer">
<div className="row">
<ProductCards products={products} />
</div>
</div>
);
}