Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the sidebar menu collapsible #5

Closed
wants to merge 13 commits into from
Closed

Conversation

davidedistefano
Copy link
Member

This PR makes the Solidus admin more usable at small screen sizes.

At medium size devices, like small desktops or big tablets, the sidebar will collapse, leaving visible only the menu icons.

schermata 2017-02-06 alle 18 52 43

At mobile screen sizes instead, the menu will only be visible by clicking on the top right hamburger menu.

schermata 2017-02-06 alle 18 52 59

To make this PR works also on devices like smartphone or tablet the following line of code should be added inside the app <head> element:

<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />

The admin layout needs some tweaks to work fine with new sidebar. I suggest to use a fluid layout instead of the old Skeleton grid.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small changes proposed but 👍

}
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidedistefano maybe we can nest the last 2 elements inside the &:checked ~ .admin-wrapper one, something like:

#menu-button {
  display: none;

  &:checked ~ .admin-wrapper  {
    overflow: hidden;
  
    .admin-nav { 
      // ...
    }
    
    .admin-content  {
      // ...    
    }
  }
}

}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidedistefano I find this part is a bit confusing (probably it already was) and I'd take advantage of this change to make a small refactor:

.admin-nav-menu {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li {
    background: $color-navbar-bg;

    &:hover {
      background: $color-navbar-active-bg;

      > a {
        color: $color-navbar-active;
      }
    }

    // flyout nav
    > ul {
      position: absolute;
      top: 0;
      left: 100%;
      width: $width-sidebar-flyout;
      margin-left: 0;
      border: $border-sidebar;
      background: $color-navbar-submenu-bg;
      box-shadow: $box-shadow;
      @include caret($direction: left, $color-caret: $color-navbar-submenu-bg);

      @include media($tablet) {
        position: relative;
        left: 0;
        width: $width-sidebar;
        border-top: 0;
        border-bottom: 0;
      }

      &:before {
        z-index: 1;
        top: 1.5em;
      }
    }

    &.selected {
      background: $color-navbar-active-bg;
      @include media($desktop) {
        position: relative;
      }

      &:not(:hover) > ul {
        @include media($desktop) {
          display: none;
        }
        @include media($tablet) {
          display: block;
        }
      }

      li {
        padding-left: 2em;
      }

      > a {
        color: $color-navbar-active;
      }
    }

    &:not(.selected) {
      position: relative;

      > ul {
        @include media($tablet) {
          display: none;
        }
      }

      &:not(:hover) > ul {
        display: none;
      }
    }
  }

Since the flyout stuff is used just once, we can remove the flyout mixin.

@@ -0,0 +1,16 @@
@mixin flyout {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as said above, I'd remove this mixin in favor of a better code organization.

<%= render "spree/admin/shared/spinner" %>
<input type="checkbox" id="menu-button" />

<div class="admin-wrapper">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the empty line under this div

@kennyadsl
Copy link
Member

kennyadsl commented Feb 6, 2017

@davidedistefano also, we can anticipate this PR removing all bourbon browser prefixer mixins from the new code we are writing

@@ -28,6 +28,12 @@
.flash-wrapper {
@include position(fixed, null 0 0 $width-sidebar);
z-index: 1000;
@include media($desktop) {
@include position(fixed, null 0 0 $width-sidebar-collapsed);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be left: $width-sidebar-collapsed.

@include position(fixed, null 0 0 $width-sidebar-collapsed);
}
@include media($desktop) {
@include position(fixed, null 0 0 0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly this can just be left: 0.

@include media($tablet) {
width: $width-sidebar;
position: fixed;
margin: 0 0 0 -200px;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be -$width-sidebar?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would prefer to use translateX() to move it over but not too concerned about the margin.

display: none;
}
@include media($tablet) {
display: inline-block;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's inline-block by default do we need this additional media query?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is not mobile first approach, we need to reset the display property.

$large-device: "only screen and (min-width: #{$tablet-width})";
$desktop: "only screen and (max-width: #{$desktop-width})";
$tablet: "only screen and (max-width: #{$tablet-width})";
$mobile: "only screen and (max-width: #{$mobile-width})";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer always going up for media queries (making sure to always use min-width). This helps create a mobile first approach:

$tablet: "screen and (min-width: 481px)";
$desktop: "screen and (min-width: 769px)";

.thing {
  // default styles + mobile
  style: style;

  @media $tablet {
    // more things
  }

  @media $desktop {
    // more things
  }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graygilmore for now we just converted the skeleton media queries set here. We internally discussed about changing them to a mobile first approach but it seemed like something not related to this PR and probably something that need a better testing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I also only just realized this wasn't a PR into Solidus itself. 🤦‍♂️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be soon so a review at this stage is very helpful, thanks @graygilmore

Copy link
Member

@mtylty mtylty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on stylesheets but the CoffeeScript code looks good to me 👍

@Mandily
Copy link

Mandily commented Feb 7, 2017

This looks great! I know it's not exactly part of this scope of work, but I was wondering if you could make the admin-nav-header class have a height of 47px? That should make the white solidus logo area the same height as the blue bar beside it so everything is aligned.
screen shot 2017-02-07 at 9 40 04 am

- reduce navigation width
- hide the subnav on smaller screens and make it appear only on link
  hover
- collapse the left menu only on mobile landscape
in order to avoid multiple lines and to fit right in the app header
this is needed to prevent scrolling or scrollbar to appear
when the mobile menu is open
while scrolling when window height is small
- prevent jquery Sticky-kit plugin to create unnecessary divs
- prevent admin nav content stick when scrolling on mobile
- disable Sticky-kit on mobile
- make admin nav scrollable on mobile
@davidedistefano
Copy link
Member Author

will be reopened on solidus repository

spaghetticode pushed a commit that referenced this pull request Mar 26, 2021
Add support for refunding payments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants