-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidied up home styling and add product detail page
- Loading branch information
1 parent
70c05ee
commit d8ede44
Showing
14 changed files
with
12,075 additions
and
62 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.product-listing .images img { | ||
object-fit: cover; | ||
border-radius: 0.5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { IonCard, IonCol, IonGrid, IonRow } from "@ionic/react"; | ||
import "./ProductListing.css"; | ||
|
||
interface ProductListingProps { | ||
product: any; | ||
} | ||
|
||
const ProductListing: React.FC<ProductListingProps> = ({ product }) => { | ||
// console.log(product); | ||
const { variants, assets, meta, related_products } = product; | ||
const images = assets.filter(({ is_image }) => is_image); | ||
// console.log(images); | ||
return ( | ||
<IonGrid className="product-listing"> | ||
<IonRow> | ||
<IonCol className="ion-hide-md-down" size="5"> | ||
Content | ||
</IonCol> | ||
<IonCol> | ||
<IonGrid> | ||
<IonRow className="images"> | ||
{images.map(({ id, url }) => { | ||
return ( | ||
<IonCol | ||
size="12" | ||
sizeSm="12" | ||
sizeMd="12" | ||
sizeLg="12" | ||
sizeXl="12" | ||
key={id} | ||
> | ||
<img src={url} /> | ||
</IonCol> | ||
); | ||
})} | ||
</IonRow> | ||
</IonGrid> | ||
</IonCol> | ||
</IonRow> | ||
<IonRow className="ion-hide-md-up"> | ||
<IonCol>Content</IonCol> | ||
</IonRow> | ||
</IonGrid> | ||
); | ||
}; | ||
|
||
export default ProductListing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.product-card img { | ||
height: 300px; | ||
width: 100%; | ||
object-fit: cover; | ||
border-radius: 0.5rem; | ||
} | ||
|
||
.product-card ion-card { | ||
min-height: 200px; | ||
box-shadow: none; | ||
border-radius: 0; | ||
} | ||
|
||
.product-card ion-card-header { | ||
padding: 6px 0 10px 0; | ||
font-size: 1em; | ||
} | ||
|
||
.product-card ion-card-title { | ||
font-size: 20px; | ||
font-weight: 400; | ||
font-family: "Inter"; | ||
} | ||
|
||
.product-card .price { | ||
font-size: 16px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
IonCard, | ||
IonCardContent, | ||
IonCardHeader, | ||
IonCardTitle, | ||
IonCol, | ||
IonGrid, | ||
IonRow, | ||
} from "@ionic/react"; | ||
import { useHistory } from "react-router"; | ||
import "./ProductCard.css"; | ||
|
||
interface ProductCardProps { | ||
product: object; | ||
} | ||
|
||
const ProductCard: React.FC<ProductCardProps> = ({ product }) => { | ||
const history = useHistory(); | ||
return ( | ||
<div className="product-card"> | ||
<IonCard | ||
className="ion-no-margin ion-no-padding" | ||
onClick={(e) => { | ||
history.push(`/product/${product["id"]}`, { | ||
product, | ||
}); | ||
}} | ||
> | ||
{product["media"] != null && ( | ||
<img src={product["media"]["source"]} className="product-image" /> | ||
)} | ||
<IonCardHeader> | ||
<IonCardTitle> | ||
<IonGrid> | ||
<IonRow> | ||
<IonCol>{product["name"]}</IonCol> | ||
<IonCol className="ion-text-end price" size="4"> | ||
{product["price"]["formatted_with_symbol"]} | ||
</IonCol> | ||
</IonRow> | ||
</IonGrid> | ||
</IonCardTitle> | ||
</IonCardHeader> | ||
</IonCard> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProductCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap"); | ||
@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:wght@500&display=swap"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
IonCol, | ||
IonContent, | ||
IonFooter, | ||
IonGrid, | ||
IonHeader, | ||
IonPage, | ||
IonRow, | ||
IonTitle, | ||
IonToolbar, | ||
} from "@ionic/react"; | ||
import "./Product.css"; | ||
import Commerce from "@chec/commerce.js"; | ||
import { useEffect, useState } from "react"; | ||
import { RouteComponentProps } from "react-router"; | ||
import ProductCard from "../../components/product/listing/ProductListing"; | ||
import ProductListing from "../../components/product/listing/ProductListing"; | ||
|
||
interface ProductDetailPageProps | ||
extends RouteComponentProps<{ | ||
id: string; | ||
}> {} | ||
|
||
const ProductDetail: React.FC<ProductDetailPageProps> = ({ | ||
match, | ||
location: { state }, | ||
}) => { | ||
const [product, setProduct] = useState((state && state["product"]) || null); | ||
|
||
useEffect(() => { | ||
const commerce = new Commerce(process.env.REACT_APP_CHEC_PUBLIC_KEY); | ||
commerce.products | ||
.retrieve(match.params.id) | ||
.then((product) => setProduct(product)) | ||
.catch((e) => console.error(e)); | ||
}, []); | ||
|
||
return ( | ||
<IonPage> | ||
<IonHeader> | ||
<IonToolbar> | ||
<IonTitle> | ||
<img src="assets/chopchop.svg" height="28px" width="144px" /> | ||
</IonTitle> | ||
</IonToolbar> | ||
</IonHeader> | ||
<IonContent fullscreen> | ||
<IonHeader collapse="condense"> | ||
<IonToolbar> | ||
<IonTitle size="large"> | ||
<img src="assets/chopchop.svg" height="28px" /> | ||
</IonTitle> | ||
</IonToolbar> | ||
</IonHeader> | ||
{product && <ProductListing product={product} />} | ||
</IonContent> | ||
<IonFooter> | ||
<IonToolbar> | ||
<IonTitle>Powered By Commerce.JS</IonTitle> | ||
</IonToolbar> | ||
</IonFooter> | ||
</IonPage> | ||
); | ||
}; | ||
|
||
export default ProductDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.