-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from TrumanH/category-page-and-routes
add specific category page and routes
- Loading branch information
Showing
26 changed files
with
621 additions
and
134 deletions.
There are no files selected for viewing
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 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.
24 changes: 24 additions & 0 deletions
24
src/components/category-preview/category-preview.component.jsx
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,24 @@ | ||
import { Link } from 'react-router-dom'; | ||
import ProductCard from '../product-card/product-card.component'; | ||
import './category-preview.styles.scss'; | ||
|
||
const CategoryPreview = ({ title, products }) => { | ||
return ( | ||
<div className='category-preview-container'> | ||
<h2> | ||
<Link className='title' to={title}> | ||
{title.toUpperCase()} | ||
</Link> | ||
</h2> | ||
<div className='preview'> | ||
{products | ||
.filter((_, idx) => idx < 4) | ||
.map((product) => ( | ||
<ProductCard key={product.id} product={product} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CategoryPreview; |
18 changes: 18 additions & 0 deletions
18
src/components/category-preview/category-preview.styles.scss
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,18 @@ | ||
.category-preview-container { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 30px; | ||
|
||
.title { | ||
font-size: 28px; | ||
margin-bottom: 25px; | ||
cursor: pointer; | ||
} | ||
|
||
.preview { | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
column-gap: 20px; | ||
} | ||
} |
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,28 @@ | ||
import { useContext } from 'react'; | ||
import { CartContext } from '../../context/cart.context'; | ||
import './checkout-item.styles.scss'; | ||
|
||
const CheckoutItem = ({item})=> { | ||
const { name, price, imageUrl, quantity } = item; | ||
const { addItem, decreaseItem, removeItem } = useContext(CartContext); | ||
const addItemHandler = ()=> addItem(item); | ||
const decreaseItemHandler = () => decreaseItem(item); | ||
const removeItemHandler = () => removeItem(item); | ||
return ( | ||
<div className='checkout-item-container'> | ||
<div className='image-container'> | ||
<img src={imageUrl} alt={`${name}`}/> | ||
</div> | ||
<span className='name'>{name}</span> | ||
<span className='quantity'> | ||
<div className='arrow' onClick={decreaseItemHandler}>❮</div> | ||
<span className='value'>{quantity}</span> | ||
<div className='arrow' onClick={addItemHandler}>❯</div> | ||
</span> | ||
<span className='price'>${price}</span> | ||
<div className='remove-button' onClick={removeItemHandler}>✕</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CheckoutItem; |
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,41 @@ | ||
.checkout-item-container { | ||
width: 100%; | ||
display: flex; | ||
min-height: 100px; | ||
border-bottom: 1px solid darkgrey; | ||
padding: 15px 0; | ||
font-size: 20px; | ||
align-items: center; | ||
|
||
.image-container { | ||
width: 23%; | ||
padding-right: 15px; | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
.name, | ||
.quantity, | ||
.price { | ||
width: 23%; | ||
} | ||
|
||
.quantity { | ||
display: flex; | ||
|
||
.arrow { | ||
cursor: pointer; | ||
} | ||
|
||
.value { | ||
margin: 0 10px; | ||
} | ||
} | ||
|
||
.remove-button { | ||
padding-left: 12px; | ||
cursor: pointer; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/components/directory-item/directory-item.component.jsx
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,19 @@ | ||
import { Link } from 'react-router-dom'; | ||
import './directory-item.styles.scss'; | ||
|
||
const DirectoryItem = ({category}) => { | ||
const { title, imgUrl} = category; | ||
return ( | ||
<div className='directory-item-container'> | ||
<div className='background-image' style={{backgroundImage: `url(${imgUrl})`}}/> | ||
<div className='body'> | ||
<Link className='title' to={`shop/${title.toLowerCase()}`}> | ||
<h2>{title}</h2> | ||
</Link> | ||
<p>shop now</p> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default DirectoryItem; |
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 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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import CategoryItem from '../category-item/category-item.component' | ||
import './directory.styles.scss' | ||
import DirectoryItem from '../directory-item/directory-item.component'; | ||
import './directory.styles.scss'; | ||
|
||
const Directory = ({categories}) => { | ||
return ( | ||
<div className='directory-container'> | ||
{categories.map((category) => ( | ||
<CategoryItem key={category.id} category={category}/> | ||
<DirectoryItem key={category.id} category={category}/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default Directory | ||
export default Directory; |
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 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,23 @@ | ||
import { useState, useEffect, createContext } from "react"; | ||
// import SHOP_DATA from '../shop-data.js'; | ||
import { getCollectionAndDocuments } from '../utils/firebase/firebase.utils'; | ||
|
||
export const CategoriesContext = createContext({ | ||
categories: {}, | ||
setCategories: ()=>null, | ||
}); | ||
|
||
export const CategoriesProvider = ({ children }) => { | ||
const [ categories, setCategories] = useState({}); | ||
const value = {categories}; | ||
useEffect(() => { | ||
const getCategoriesMap = async ()=> { | ||
const categoriesMap = await getCollectionAndDocuments(); | ||
setCategories(categoriesMap); | ||
console.log(categoriesMap); | ||
}; | ||
getCategoriesMap(); | ||
}, []); | ||
|
||
return (<CategoriesContext.Provider value={value}>{children}</CategoriesContext.Provider>); | ||
}; |
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
Oops, something went wrong.