From 2f2e3e8153f1ce6a2822412914c74aff44ad27ac Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:26:42 +0400 Subject: [PATCH] update header style --- public/js_original/cart-view.js | 10 +++++++ public/js_original/global-view.js | 10 +++++++ public/js_original/product-view.js | 5 ++++ public/styles/global.css | 18 ++++++++++- src/core/Controller.php | 2 ++ src/views/Template.php | 48 ++++++++++++++---------------- 6 files changed, 66 insertions(+), 27 deletions(-) diff --git a/public/js_original/cart-view.js b/public/js_original/cart-view.js index 1b1eb18f..66ad5d77 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 61274b18..2ad45606 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 b9415635..45b2e1e1 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 90f311ac..910e5b1b 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 f3e0a550..f2117a1f 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 5b575354..87d34565 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 ?> - +