-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 adding the next.js frontend app to the code base
- Loading branch information
Showing
57 changed files
with
1,094 additions
and
354 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 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,56 @@ | ||
import styled from 'styled-components'; | ||
import Button from '../Button'; | ||
|
||
export const Banner = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
flex-direction: row-reverse; | ||
padding-bottom: 38px; | ||
background: ${({ theme }) => theme.colors.backgroundGray}; | ||
} | ||
`; | ||
|
||
export const BannerImg = styled.img.attrs({ | ||
src: '/images/Banner.png', | ||
})` | ||
width: 100%; | ||
height: auto; | ||
`; | ||
|
||
export const ImageContainer = styled.div` | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
min-width: 50%; | ||
} | ||
`; | ||
|
||
export const TextContainer = styled.div` | ||
padding: 20px; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: start; | ||
width: 50%; | ||
padding: 100px 160px 100px 100px; | ||
} | ||
`; | ||
|
||
export const Title = styled.h1` | ||
font-size: ${({ theme }) => theme.sizes.mxLarge}; | ||
font-weight: ${({ theme }) => theme.fonts.bold}; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
font-size: ${({ theme }) => theme.sizes.dxLarge}; | ||
} | ||
`; | ||
|
||
export const GoShoppingButton = styled(Button)` | ||
width: 100%; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
width: auto; | ||
} | ||
`; |
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,17 @@ | ||
import * as S from './Banner.styled'; | ||
|
||
const Banner = () => { | ||
return ( | ||
<S.Banner> | ||
<S.ImageContainer> | ||
<S.BannerImg /> | ||
</S.ImageContainer> | ||
<S.TextContainer> | ||
<S.Title>The best telescopes to see the world closer</S.Title> | ||
<S.GoShoppingButton>Go Shopping</S.GoShoppingButton> | ||
</S.TextContainer> | ||
</S.Banner> | ||
); | ||
}; | ||
|
||
export default Banner; |
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 @@ | ||
export { default } from './Banner'; |
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,91 @@ | ||
import Image from 'next/image'; | ||
import styled from 'styled-components'; | ||
import Button from '../Button'; | ||
|
||
export const CartDropdown = styled.div` | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
width: 100%; | ||
height: 100%; | ||
max-height: 100%; | ||
overflow-y: scroll; | ||
padding: 25px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
gap: 24px; | ||
background: ${({ theme }) => theme.colors.white}; | ||
z-index: 1000; | ||
border-radius: 5px; | ||
box-shadow: 0 2px 2px 0 rgb(0 0 0 / 14%), 0 3px 1px -2px rgb(0 0 0 / 12%), 0 1px 5px 0 rgb(0 0 0 / 20%); | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
position: absolute; | ||
width: 400px; | ||
top: 95px; | ||
right: 17px; | ||
max-height: 650px; | ||
} | ||
`; | ||
|
||
export const Title = styled.h5` | ||
margin: 0px; | ||
font-size: ${({ theme }) => theme.sizes.mxLarge}; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
font-size: ${({ theme }) => theme.sizes.dLarge}; | ||
} | ||
`; | ||
|
||
export const ItemList = styled.div` | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
max-height: 450px; | ||
overflow-y: scroll; | ||
} | ||
`; | ||
|
||
export const Item = styled.div` | ||
display: grid; | ||
grid-template-columns: 29% 59%; | ||
gap: 2%; | ||
padding: 25px 0; | ||
border-bottom: 1px solid ${({ theme }) => theme.colors.textLightGray}; | ||
`; | ||
|
||
export const ItemImage = styled(Image).attrs({ | ||
width: '80px', | ||
height: '80px', | ||
})` | ||
border-radius: 5px; | ||
`; | ||
|
||
export const ItemName = styled.p` | ||
margin: 0px; | ||
font-size: ${({ theme }) => theme.sizes.mLarge}; | ||
font-weight: ${({ theme }) => theme.fonts.regular}; | ||
`; | ||
|
||
export const ItemDetails = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
`; | ||
|
||
export const ItemQuantity = styled(ItemName)` | ||
font-size: ${({ theme }) => theme.sizes.mMedium}; | ||
`; | ||
|
||
export const CartButton = styled(Button)``; | ||
|
||
export const Header = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
${({ theme }) => theme.breakpoints.desktop} { | ||
span { | ||
display: none; | ||
} | ||
} | ||
`; |
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,60 @@ | ||
import Link from 'next/link'; | ||
import { useEffect, useRef } from 'react'; | ||
import { IProductCartItem } from '../../types/Cart'; | ||
import ProductPrice from '../ProductPrice'; | ||
import * as S from './CartDropdown.styled'; | ||
|
||
interface IProps { | ||
isOpen: boolean; | ||
onClose(): void; | ||
productList: IProductCartItem[]; | ||
} | ||
|
||
const CartDropdown = ({ productList, isOpen, onClose }: IProps) => { | ||
const ref = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const handleClickOutside = (event: Event) => { | ||
if (ref.current && !ref.current.contains(event.target as Node)) { | ||
onClose(); | ||
} | ||
} | ||
// Bind the event listener | ||
document.addEventListener('mousedown', handleClickOutside); | ||
|
||
return () => { | ||
// Unbind the event listener on clean up | ||
document.removeEventListener('mousedown', handleClickOutside); | ||
}; | ||
}, [ref]); | ||
|
||
return isOpen ? ( | ||
<S.CartDropdown ref={ref}> | ||
<div> | ||
<S.Header> | ||
<S.Title>Shopping Cart</S.Title> | ||
<span onClick={onClose}>Close</span> | ||
</S.Header> | ||
<S.ItemList> | ||
{productList.map( | ||
({ quantity, product: { name, picture, id, priceUsd = { nanos: 0, currencyCode: 'USD', units: 0 } } }) => ( | ||
<S.Item key={id}> | ||
<S.ItemImage src={picture} alt={name} /> | ||
<S.ItemDetails> | ||
<S.ItemName>{name}</S.ItemName> | ||
<ProductPrice price={priceUsd} /> | ||
<S.ItemQuantity>Quantity: {quantity}</S.ItemQuantity> | ||
</S.ItemDetails> | ||
</S.Item> | ||
) | ||
)} | ||
</S.ItemList> | ||
</div> | ||
<Link href="/cart"> | ||
<S.CartButton>Go to Shipping Data</S.CartButton> | ||
</Link> | ||
</S.CartDropdown> | ||
) : null; | ||
}; | ||
|
||
export default CartDropdown; |
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 @@ | ||
export { default } from './CartDropdown'; |
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
Oops, something went wrong.