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

Admin-side navbar collapse #3166

Closed
wants to merge 13 commits into from
Closed

Conversation

seand7565
Copy link
Contributor

@seand7565 seand7565 commented Apr 9, 2019

Description
Makes the admin-side navbar collapsible by clicking a collapse icon at the top of the page.

navbar-collapse

Additional functionality:

  • The navbar defaults to closed on iPad sized screens or smaller.
  • When the navbar is collapsed or opened, a cookie is stored that remembers your preference - on the next page load, the navbar will be in the same state as it was on the previous page.
  • When the navbar is closed, a tooltip is set for the navbar icons which - on hover- displays the name of the button you have selected. If you prefer a closed navbar, but don't know what the icons mean, you can still find your way around.

image

@jacobherrington and @tvdeyen did most of the heavy lifting here, I just cleaned it up and added a few things.

ref #2961 - should close this issue if everything looks good!

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

@seand7565
Copy link
Contributor Author

Got some tests to fix here - capybara is trying to click on nested navbar links, but those are hidden when the navbar is collapsed. The navbar defaults to closed on small screens, which is the problem for these tests.

The two solutions I have are to increase capybaras window size, or just click the navbar-toggle button to open the navbar before running the tests. I'll pop something in soon to get the tests to pass.

@tvdeyen
Copy link
Member

tvdeyen commented Apr 10, 2019

Thanks, this looks great! Regarding the specs: My vote is to raise the capybara window size.

@aitbw
Copy link
Contributor

aitbw commented Apr 11, 2019

My vote too goes to raise Capybara window size. This looks very good, @seand7565! Thanks a lot 🙌

One small thing: is it possible you could rebase this PR? That'd would help us avoid the merge commit in here

@aitbw aitbw mentioned this pull request Apr 11, 2019
4 tasks
Copy link
Contributor

@vzqzac vzqzac left a comment

Choose a reason for hiding this comment

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

I like this feature, just that the commits need some love 😅

@seand7565
Copy link
Contributor Author

(Mostly) passing now! @aitbw The screen size actually wasn't the issue here like I thought, I used the wrong operator in the javascript file determining the default screen size (greater than rather than less than). D'oh!

Not sure why the mysql rails 5.1 tests failed - and on the flash too, which wasn't touched in this commit. I'll see if I can find out why it failed!

Thanks all for the feedback! ❤️ I rebased and squashed some of the smaller changes - not sure how far you folks like PRs squashed. Should this all be one commit?

@seand7565
Copy link
Contributor Author

The test that was previously failing here appears to be passing now after a rebase 🤷‍♂

@spaghetticode
Copy link
Member

@seand7565 Thanks for the PR 👏

I see it now needs some rebasing, some asset files are out-of-sync, can you please update them? Thank you!

@seand7565
Copy link
Contributor Author

This doesn't play well with the new admin styling - will have to make some changes to get it back in line. Give me a few days and I'll have it done!

@seand7565
Copy link
Contributor Author

Should be good to go now!

image

image

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

Copy link
Contributor

@jacobherrington jacobherrington left a comment

Choose a reason for hiding this comment

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

Thanks for carrying this one to the finish line @seand7565! 🏃

if (window.screen.width <= 1024 && !document.cookie.includes("admin_nav_hidden")) {
// Set default nav to collapse on small screens - but don't override user preference
document.body.classList.add("admin-nav-hidden");
document.cookie = "admin_nav_hidden=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to use LocalStorage instead?
Browser support is pretty wide https://caniuse.com/#feat=namevalue-storage
I would also suggest namespacing the key with solidus. or solidus/, e.g. window.localStorage.get('solidus.minimize-admin-nav')

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe I was initially using LocalStorage, but there was some feedback on that decision from either @tvdeyen or @seand7565. I do not remember it 🤦‍♂

@kennyadsl
Copy link
Member

I'm ok with this but I think it will need some extra design iterations after the merge. If you agree I'd merge it after v2.9 release which already contains a lot of backend changes.

@mfrecchiami
Copy link
Contributor

mfrecchiami commented Jul 19, 2019

Hi @seand7565 and everyone!

I tried to improve a little bit more this new feature, moving the collapse icon and leaving the Solidus mark always visible.

This is the first version 👇
minimize-menu

minimize-menu-closed

Then I tried to move to the below the collapse button 👇

minimize-menu-bottom

minimize-menu-bottom-closed

Which one do you think that could be the best solution?

Note: when you log in with a user whit role of Admin, there is a select for change the language, at the bottom of the sidebar; as you can see by the screenshots above, I choose to hide it when the navbar is collapsed

@seand7565
Copy link
Contributor Author

That looks fantastic - thanks @mfrecchiami ! I like the button being inside the collapsible panel, so it doesn't affect the layout of the rest of the page.

@mfrecchiami
Copy link
Contributor

Hi @seand7565 !

I did my job starting from your repo 💪
I've made my branch, did the rebase with master and added my commits
I believed to find your repo in the compare step, but it wasn't 😞 (still don't know why)
So I made another PR related to yours: #3322

Do you want to do it in a different way? Let me know!

@seand7565
Copy link
Contributor Author

@mfrecchiami No, that's perfect - thanks! I'll close this PR in favor of yours.

@seand7565 seand7565 closed this Sep 6, 2019
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.

10 participants