diff --git a/public/js_original/cart-view.js b/public/js_original/cart-view.js index 1b1eb18..66ad5d7 100644 --- a/public/js_original/cart-view.js +++ b/public/js_original/cart-view.js @@ -46,6 +46,11 @@ function updateCart(e) { currentCartItem.quantity = newQuantity; currentCart.addItem(currentCartItem); } + + const itemCount = Cart().getCartSize(); + + // update cart item count in header + document.querySelector("#mini-cart-count").textContent = `(${itemCount})`; } async function checkout() { @@ -102,6 +107,11 @@ function initCartPage() { input.addEventListener("change", updateCart); input.addEventListener("keydown", preventKeyboardInput); }); + + const itemCount = Cart().getCartSize(); + + // update cart item count in header + document.querySelector("#mini-cart-count").textContent = `(${itemCount})`; } async function uploadCart() { diff --git a/public/js_original/global-view.js b/public/js_original/global-view.js index 61274b1..2ad4560 100644 --- a/public/js_original/global-view.js +++ b/public/js_original/global-view.js @@ -2,5 +2,15 @@ import "@picocss/pico/css/pico.min.css"; import "../styles/global.css"; import "../styles/theme.css"; import themeSwitcher from "./theme-switcher"; +import Aos from "aos/src/js/aos"; +import Splide from "@splidejs/splide"; +import Cart from "./models/Cart"; themeSwitcher.init(); + +document.addEventListener("DOMContentLoaded", function () { + const itemCount = Cart().getCartSize(); + + // update cart item count in header + document.querySelector("#mini-cart-count").textContent = `(${itemCount})`; +}); diff --git a/public/js_original/product-view.js b/public/js_original/product-view.js index b941563..45b2e1e 100644 --- a/public/js_original/product-view.js +++ b/public/js_original/product-view.js @@ -27,6 +27,11 @@ function handleAddToCart(e) { // open modal to display success successAddToCartModal.openModal(); + + const itemCount = Cart().getCartSize(); + + // update cart item count in header + document.querySelector("#mini-cart-count").textContent = `(${itemCount})`; } function createRatingChart() { diff --git a/public/styles/global.css b/public/styles/global.css index 90f311a..910e5b1 100644 --- a/public/styles/global.css +++ b/public/styles/global.css @@ -5,11 +5,27 @@ body > nav { background-color: var(--background-color); } -body > nav .icon { +nav a { + color: var(--contrast); +} + +/*logo in nav*/ +body > nav > ul:nth-child(1) .icon { height: 40px; width: 40px; } +/*other icons in nav*/ +body > nav > ul:nth-child(2) .icon { + height: 28px; + width: 28px; +} + +body > nav .icon { + height: 20px; + width: 20px; +} + /*style logo on left hand side of navbar*/ body > nav > ul li:nth-child(1) > a { display: flex; diff --git a/src/core/Controller.php b/src/core/Controller.php index f3e0a55..f2117a1 100644 --- a/src/core/Controller.php +++ b/src/core/Controller.php @@ -107,6 +107,8 @@ public function view( $template_content = ob_get_contents(); ob_end_clean(); + $is_user_signed_in = $this->getSignedInClient() !== null; + // display global view template require_once __DIR__ . "/../views/Template.php"; } diff --git a/src/views/Template.php b/src/views/Template.php index 5b57535..87d3456 100644 --- a/src/views/Template.php +++ b/src/views/Template.php @@ -7,8 +7,8 @@ * @var string $template_content HTML of the main content of page * @var string $template_meta_description Meta description of page * @var string $template_tags Additional tags (script, link, ...) for page + * @var bool $is_user_signed_in Whether user is signed in or not */ - ?> @@ -31,13 +31,13 @@ <?= $template_title ?> - +