Skip to content

Commit d49fb9d

Browse files
implementing cart component and adding dropdown option
1 parent 2f3b1a0 commit d49fb9d

File tree

6 files changed

+125
-2
lines changed

6 files changed

+125
-2
lines changed

src/assets/shopping-bag.svg

Lines changed: 53 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import CustomButton from '../custom-button/custom-button.component'
3+
import './cart-dropdown.styles.scss'
4+
export default function CartDropdown() {
5+
return (
6+
<div className="cart-dropdown">
7+
<div className="cart-item">
8+
<CustomButton>GO TO CHECKOUT</CustomButton>
9+
</div>
10+
</div>
11+
)
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.cart-dropdown {
2+
position: absolute;
3+
width: 240px;
4+
height: 340px;
5+
display: flex;
6+
flex-direction: column;
7+
padding: 20px;
8+
border: 1px solid black;
9+
background-color: white;
10+
top: 90px;
11+
right: 40px;
12+
z-index: 5;
13+
14+
.cart-items {
15+
height: 240px;
16+
display: flex;
17+
flex-direction: column;
18+
overflow: scroll;
19+
}
20+
21+
button {
22+
margin-top: auto;
23+
}
24+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import './cart-icon.styles.scss'
3+
import { ReactComponent as ShoppingIcon } from '../../assets/shopping-bag.svg'
4+
export default function CartIcon() {
5+
return (
6+
<div className="cart-icon">
7+
<ShoppingIcon className="shopping-icon" />
8+
<span className="item-count">0</span>
9+
</div>
10+
)
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.cart-icon {
2+
width: 45px;
3+
height: 45px;
4+
position: relative;
5+
display: flex;
6+
align-items: center;
7+
justify-content: center;
8+
cursor: pointer;
9+
10+
.shopping-icon {
11+
width: 24px;
12+
height: 24px;
13+
}
14+
15+
.item-count {
16+
position: absolute;
17+
font-size: 10px;
18+
font-weight: bold;
19+
bottom: 12px;
20+
}
21+
}

src/components/header/header.component.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import './header.styles.scss'
44
import { ReactComponent as Logo } from '../../assets/newLogo.svg'
55
import { Link } from 'react-router-dom'
66
import { auth } from '../../firebase/firebase.utils'
7-
7+
import CartIcon from '../cart-icon/Cart-icon'
8+
import CartDropdown from '../cart-dropdown/cart-dropdown.component'
89
function Header({ currentUser }) {
910
return (
1011
<div className="header">
@@ -28,8 +29,9 @@ function Header({ currentUser }) {
2829
SIGN IN
2930
</Link>
3031
}
31-
32+
<CartIcon />
3233
</div>
34+
<CartDropdown />
3335
</div>
3436
)
3537
}

0 commit comments

Comments
 (0)