Skip to content

Commit f2dafa4

Browse files
committed
add the productCard compo
1 parent b6adcc0 commit f2dafa4

File tree

7 files changed

+127
-3
lines changed

7 files changed

+127
-3
lines changed

examples/ecommerce-jewellery-store/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import "@progress/kendo-theme-default/dist/all.css";
1111
import "@progress/kendo-theme-utils/dist/all.scss";
1212
import { SizedParent } from "./components/SizedParent";
1313
import { DetailedCategory } from './pages/DetailedCategory';
14+
import { ProductDetails } from './pages/ProductsDetails';
1415

1516
function App() {
1617
return (
@@ -25,6 +26,7 @@ function App() {
2526
<Route path="/contacts" element={<Contacts />} />
2627
<Route path="/products" element={<AllProductsListView />} />
2728
<Route path="/category" element={<DetailedCategory />} />
29+
<Route path="/product/:id" element={<ProductDetails />} />
2830
</Routes>
2931
<Footer />
3032
</SizedParent>

examples/ecommerce-jewellery-store/src/components/CardsList.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ import { Badge, BadgeContainer } from "@progress/kendo-react-indicators";
22
import { Button } from "@progress/kendo-react-buttons";
33
import { cartIcon } from "@progress/kendo-svg-icons"
44
import { CardListProps } from "../data/types";
5+
import { useNavigate } from "react-router-dom";
56

67
export const CardsList = (props: CardListProps) => {
8+
const navigate = useNavigate();
9+
10+
11+
const onButtonClick = (index: number) => {
12+
navigate(`/product/${index + 1}`);
13+
}
14+
715
return (
816
<section className="k-d-grid k-grid-cols-12 k-col-span-12 k-justify-content-center k-align-items-center k-gap-3">
917
{props.data.map((item, index) => {
@@ -67,7 +75,7 @@ export const CardsList = (props: CardListProps) => {
6775
>{`$${item.newPrice}`}</span>
6876
</span>
6977
<span>
70-
<Button fillMode={"outline"} svgIcon={cartIcon}>
78+
<Button fillMode={"outline"} svgIcon={cartIcon} onClick={() => onButtonClick(index)}>
7179
Buy
7280
</Button>
7381
</span>

examples/ecommerce-jewellery-store/src/components/CategoryList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { CardDescriptor } from "../data/types";
77
export const CategoryList = (props: CategoryListProps) => {
88
const navigate = useNavigate();
99
const onNavigate = (card: CardDescriptor) => {
10-
if(card.collectionText === "AURELIA"){
10+
if (card.collectionText === "AURELIA") {
1111
navigate("/category")
1212
}
1313
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Breadcrumb } from "@progress/kendo-react-layout";
2+
import { ProductCardProps } from "../data/types";
3+
import { NumericTextBox, Rating } from "@progress/kendo-react-inputs";
4+
import { Button } from "@progress/kendo-react-buttons";
5+
6+
export const ProductCard = (props: ProductCardProps) => {
7+
8+
9+
return (
10+
<>
11+
<section
12+
className="k-d-grid k-grid-cols-12 k-justify-content-center k-align-items-center k-col-span-12 k-gap-2"
13+
style={{
14+
paddingTop: "60px",
15+
}}
16+
>
17+
<div className="k-rounded-lg k-col-span-5" style={{
18+
backgroundImage: `url(${props.image})`,
19+
backgroundSize: "cover",
20+
height: "385px",
21+
width: "476px"
22+
}}></div>
23+
24+
<div className="k-col-span-7 k-h-full">
25+
<Breadcrumb data={props.breadCrumbItem}></Breadcrumb>
26+
27+
<div className="k-d-grid k-gap-6">
28+
<span className="k-h2 k-text-black k-font-bold">
29+
{props.title}
30+
</span>
31+
<div className="k-font-size-xl">
32+
{props.subtitle}
33+
</div>
34+
<span className="k-d-flex k-align-items-center">
35+
<Rating value={props.rating}></Rating>
36+
<span style={{
37+
color: "red"
38+
}}>
39+
{props.reviews}
40+
</span>
41+
</span>
42+
43+
<div className="k-font-size-xl" style={{
44+
color: "red"
45+
}}>
46+
{`$${props.price}`}
47+
</div>
48+
</div>
49+
50+
<div className="k-font-size-sm k-pt-6">
51+
{props.description}
52+
</div>
53+
<div className="k-d-flex k-gap-3 k-pt-6">
54+
<NumericTextBox spinners={true} style={{
55+
width: "84px"
56+
}} value={1}></NumericTextBox>
57+
<Button themeColor={"primary"}>Add to Cart</Button>
58+
</div>
59+
60+
</div>
61+
</section>
62+
</>
63+
);
64+
}

examples/ecommerce-jewellery-store/src/data/listData.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import stainlessSteelWatch from "../assets/listViewImages/stainlessSteelWatch.pn
2020
import goldEarringsGarnet from "../assets/listViewImages/goldEarringsGarnet.png";
2121

2222
type ListDataDescriptor = {
23+
id: number;
2324
img: string | null;
2425
status: string | null;
2526
title: string;
2627
category: "Bracelets" | "Earrings" | "Rings" | "Watches" | "Necklaces";
2728
material: "Silver" | "Gold";
2829
oldPrice: number | null;
2930
newPrice: number;
31+
rating: number;
3032
};
3133

3234
export const listData: ListDataDescriptor[] = [{
@@ -190,4 +192,4 @@ export const listData: ListDataDescriptor[] = [{
190192
title: "Gold Earrings with Garnet",
191193
oldPrice: null,
192194
newPrice: 270
193-
},]
195+
},].map((item, index) => ({ ...item, id: index + 1, rating: Math.floor(Math.random() * 5) + 1 }));

examples/ecommerce-jewellery-store/src/data/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,15 @@ export type SizedParentProps = {
5050

5151
export type CategoryListProps = {
5252
data: any[];
53+
}
54+
55+
export type ProductCardProps = {
56+
breadCrumbItem: DataModel[];
57+
title: string | undefined;
58+
image: string | null | undefined;
59+
subtitle: string | undefined;
60+
rating: number | undefined;
61+
reviews: string | undefined;
62+
price: number | undefined;
63+
description: string | undefined;
5364
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { useParams } from "react-router-dom"
2+
import { ProductCard } from "../components/ProductCard";
3+
import { listData } from "../data/listData";
4+
import { DataModel } from "../data/types";
5+
import { Layout } from "../components/Layout";
6+
7+
export const ProductDetails = () => {
8+
const { id } = useParams();
9+
const productId = parseInt(id, 10);
10+
const descriptionText = "Elegant wedding bands featuring lustrous pearls, beautifully set in sleek, timeless bands. These rings offer a unique blend of classic charm and modern sophistication, making them a perfect symbol of everlasting love. The delicate pearls add a touch of grace, creating a refined and distinctive look that’s perfect for a memorable occasion."
11+
12+
const product = listData.find(item => item.id === productId);
13+
14+
const BreakcrumbData: DataModel[] = [{
15+
text: "Home"
16+
},
17+
{
18+
text: "Jewelry"
19+
}, {
20+
text: product?.category
21+
}]
22+
return (
23+
<>
24+
<Layout>
25+
<ProductCard title={product?.title}
26+
image={product?.img}
27+
subtitle="In Platinum with Natural Diamond"
28+
breadCrumbItem={BreakcrumbData}
29+
rating={product?.rating}
30+
reviews="208 reviews"
31+
price={product?.newPrice}
32+
description={descriptionText}>
33+
</ProductCard>
34+
</Layout>
35+
</>
36+
);
37+
}

0 commit comments

Comments
 (0)