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

feat(shoppingcard component): create a reusable card component #10

Merged
merged 1 commit into from
Sep 28, 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
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions src/components/ShoppingCard/ShoppingCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Link from "next/link"
import StarRating from "../Rating/StarRating"

export default function ShoppingCard({ product }) {
return (
<Link href={`/products/${product.id}`}>
<div
className="card w-90 bg-white glass border-gold-g "
style={{ minHeight: "450px" }}
key={product.id}
>
<figure>
<img
src={product.image}
alt={product.title}
style={{ width: "60%", height: "250px", padding: "1rem" }}
/>
</figure>
<div className="card-body text-center">
<h2 className="card-title text-text-brown mb-2 ">
{product.title.length > 25
? `${product.title.slice(0, 25)}...`
: product.title}
</h2>
<StarRating rating={product.rating.rate} />

<div className="flex flex-wrap items-start gap-16 ">
<button className="btn bg-buttongold text-brown-text-brown px-4 py-2 hover:bg-buttongoldhov border border-brown-100 btn-xs sm:btn-sm md:btn-sm lg:btn-sm">
add to cart
</button>
<p className="font-bold text-xl">{product.price}$</p>
</div>
</div>
</div>
</Link>
)
}
9 changes: 8 additions & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import Filter from "@/components/Filter/Filter"
import Image from "next/image"
import AllProducts from "./products"

export default function Home() {
return <h1>hi</h1>
return (
<>
{/* <Filter /> */}
<AllProducts />
</>
)
}
4 changes: 2 additions & 2 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@tailwind components;
@tailwind utilities;

:root {
/* :root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
Expand All @@ -24,4 +24,4 @@ body {
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
} */
Empty file added src/util/API.js
Empty file.