A design decision has created a bug

Cosmetic look of components or your whole site
User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

A design decision has created a bug

Post by burt »

A design decision I took when updating to Bootstrap 5 was to have the "cart icon" showing at all times in the Navbar regardless of whether the Navbar is "expanded" (ie large screens) or "collapsed" (ie small screens such as mobile phone), as so;

Expanded

navbar-cart-lg.png

Collapsed

navbar-cart-sm.png

I think this looks ideal.
I think it is good UI to always have that cart icon showing.
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.



Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: A design decision has created a bug

Post by burt »

The problem

In the Content Module for the Navbar, shopowner can select to ALWAYS have the Navbar Expanded, put another way it will never Collapse on small screens. This would be ideal for Navbars that maybe only have 2 or 3 items (eg Search, Account, Cart or whatever).

Your Admin > Modules > Content > {select Navigation Bar} > Edit

Here you will see a number of options, the one that matters is "Collapse", which is the breakpoint at which the Navbar, guess what, collapses;

navbar-admin.png

Choosing "navbar-expand" keeps the Navbar expanded.
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: A design decision has created a bug

Post by burt »

Choosing this "navbar-expand" option, results in strange effects on the shop side, as so (note that I have removed a few of the Navbar Items (brand, specials, currencies) so that you can more clearly see the effect.

Expanded
This is perfectly fine and looks as expected.

navbar-expand-1.png

Collapsed
This is not. It has a strange effect of moving the Cart to the left, and being slightly off center.

navbar-expand-2.png
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: A design decision has created a bug

Post by burt »

Noting that this solution is only for those shopowners who want to use Navbar set to `navbar-expand`, which is likely very very few shopowners!

The Solution

Change the pseudo-code that creates the icons;
  1. Copy \includes\modules\content\navigation\templates\tpl_cm_navbar.php
    to
    \templates\{your template name}\includes\modules\content\navigation\tpl_cm_navbar.php
    and remove (or comment out) this block of code:

    Code: Select all

    echo '<a class="nav-link d-block d-sm-none me-2" data-bs-toggle="offcanvas" href="#offcanvasCart" role="button" aria-controls="offcanvasCart">';
      echo sprintf(NAVBAR_ICON_CART_CONTENTS, $_SESSION['cart']->count_contents(), '');
    echo '</a>';
    
  2. Copy \includes\modules\navbar\templates\tpl_nb_shopping_cart.php
    to
    \templates\{your template name}\includes\modules\navbar\tpl_nb_shopping_cart.php
    and remove this piece of code:

    Code: Select all

     d-none d-sm-inline
    


After doing this, the Navbar should look correct both;

Expanded

fix-expand-1.png

Collapsed

fix-expand-2.png
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: A design decision has created a bug

Post by burt »

TY to @randers for finding this esoteric bug and reporting it to me. :+1: :+1: :+1:

I will address the bug in a more permanent fashion at some point in the future, but as it will affect hardly any shopowners it can go at the bottom of the list. Attached .zip of the two files above (using `override` template), with cart icon fixed for those of you wanting to use `navbar-expand` on the Navbar.
You do not have the required permissions to view the files attached to this post.
I am not here to build for you.
I am here to build with you. Let's help each other.



Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply