generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
171 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { | ||
div, p, button, img, | ||
} from './dom-builder.js'; | ||
|
||
// Showing products that has been added to the cart from json | ||
function jsonIterate(json, slideout) { | ||
json.forEach((item) => { | ||
const contentBox = div({ class: 'flex pb-6 mb-6 border-b pb-4' }); | ||
contentBox.append( | ||
div( | ||
{ class: 'w-1/6' }, | ||
img({ class: 'productImageStyle', src: item.img, alt: 'productImg' }), | ||
), | ||
div( | ||
{ class: 'w-1/2' }, | ||
div({ class: 'font-bold ml-2' }, item.description), | ||
div({ class: 'text-xs ml-2' }, 'SKU: dm750-educational-microscope-with-integrated-wireless-camera'), | ||
), | ||
div({ class: 'w-1/12 text-center' }, item.qty), | ||
div({ class: 'w-1/4 text-center font-bold' }, item.unitprice), | ||
); | ||
slideout.appendChild(contentBox); | ||
}); | ||
} | ||
function toggleClass() { | ||
document.querySelector('.slideout').classList.toggle('on'); | ||
} | ||
|
||
export default function addtoCartSlideout(main, json) { | ||
// creating structure of slideout | ||
const slideout = div({ class: 'slideout p-4' }); | ||
const slideoutHeading = div( | ||
{ class: '' }, | ||
div( | ||
{ class: 'flex justify-between pb-4' }, | ||
p({ class: 'text-lg font-bold' }, 'Item added to your cart'), | ||
// close Icon | ||
img({ class: 'closeIconStyle', src: '/icons/close.svg', alt: 'closeIcon' }), | ||
), | ||
// Heading | ||
div( | ||
{ class: 'flex' }, | ||
div({ class: 'w-1/6' }, ''), | ||
div({ class: 'text-xs w-1/2 ml-2' }, 'Description'), | ||
div({ class: 'text-xs w-1/12 text-center' }, 'QTY'), | ||
div({ class: 'text-xs w-1/4 text-center' }, 'Unit Price'), | ||
), | ||
); | ||
slideout.append(slideoutHeading); | ||
|
||
jsonIterate(json, slideout); | ||
|
||
// Checkout Button | ||
const checkoutButton = button({ class: 'btn-primary-purple rounded-full px-6 btn btn-lg font-medium w-full mt-5' }, 'Checkout'); | ||
slideout.appendChild(checkoutButton); | ||
main.append(slideout); | ||
|
||
// Dismiss slideout with close Icon | ||
const imgElement = document.querySelector('.closeIconStyle'); | ||
imgElement.addEventListener('click', toggleClass); | ||
toggleClass(); | ||
} |
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