-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Tabs Component #870
Add Tabs Component #870
Conversation
We're only using this one route, there's no need to generate routes that can't be used.
We want to eventually remove all of the right sidebars from pages but first we need the actual component that we'll be replacing it with.
That sounds good to me. |
Great work @graygilmore 👌🏻. Although I have to ask this question: Do we really, as an e-commerce framework, want to maintain a widget library? We discussed this a lot, but I have to raise this question again. Again. This is awesome work! No doubt, but do we want to hassle with "tabs not working in browser xyz" issues in an e-commerce framework? |
@tvdeyen that's a great question and I'm sure we'll have to draw a line somewhere. What I don't want this project to get in the habit of doing is adding X, Y and Z dependencies that end up causing headaches down the road. It's a valuable discussion to be had, though. |
When we run out of room to display the tabs we don't want them to start stacking on each other. Instead, this commit places them cleverly into a dropdown where users can still select them.
We don't want to end up hiding the active tab in the dropdown. This wouldn't give customers a clue as to what page they are on.
Developers shouldn't have to include this empty list in their code.
76d9709
to
2705a6e
Compare
This is the first step in getting rid of the sidebar in all of the templates.
0b52b74
to
3385cde
Compare
@cbrunsdon, @tvdeyen: your feedback has been addressed! |
👍 |
<li<%== ' class="active"' if current == 'Return Authorizations' %> data-hook='admin_order_tabs_return_authorizations'> | ||
<%= link_to_with_icon 'share', Spree::ReturnAuthorization.model_name.human(count: :other), admin_order_return_authorizations_url(@order) %> | ||
<li class="tab <%= "active" if current == "Return Authorizations" %>" data-hook='admin_order_tabs_return_authorizations'> | ||
<%= link_to_with_icon 'share', Spree.t(:rma), admin_order_return_authorizations_url(@order) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently do a bunch of work to use model_name.human
everywhere. So introducing a new rma
key is not preferred here. So we should change the translation of the mode name here. Although this will have wider consequences.
Using the admin.tab
scope would be ok for me.
This commit shortens the wording in the tab headers so that the default max container width will not force tabs to be in the dropdown. We can consider going back to the more verbose wording once the restrictive grid system is changed.
19d4aa8
to
8bb3090
Compare
We can safely assume that all `<li>` elements under the `.tabs` namespace should be tabs. Therefor we don't need to use a `.tab` class. This will allow other sidebars to be converted much easier because all we will need to do is add a single class name to the list.
81ed9e6
to
6706568
Compare
@tvdeyen once again, updated! 😄 |
I'm a bad person.
|
My view was that we are just temporarily using RMA instead of Return Authorizations until we change to a wider default content so to change the |
@tvdeyen the discussion is good! These are all long-term decisions and should be treated as such. The Bootstrap suggestion is good but it doesn't really encompass what we're trying to do here. I have, however, found a lightweight library that may be better than us rolling our own JS. I'm going to play around with it and see if it's worth our time including it instead of the custom implementation here. |
@tvdeyen I explored a library whose entire job was this functionality and it didn't do an important thing: don't collapse "active" elements. I'm happy with the solution I've provided here and until there is a concrete alternative available I believe we should proceed with this so we can start cleaning up some of those views. |
@graygilmore in #955 we start to introduce Bootstrap, which provides a Tabs component. Maybe we should have a look if this could work for us and either use your or their component. But having both is kind of silly. I'm in the don't reinvent the wheel club, as you already know ;) Again, your work is amazing, but I try to keep the maintenance burden we already have as low as possible. So, if you can invest some time to try the Bootstrap component, this would be very much appreciated. |
@tvdeyen, It came up that @graygilmore did check out the bootstrap tabs and it doesn't encompass what we're looking for during the meeting #870 (comment). Also the current plan is to add the bootstrap .js components on a need to have basis so the |
I gave this a look today. To clarify a few points: Bootstrap's tab.js doesn't help us here at all. tab.js adds the ability to hide and show a div for each tab on the same page, which we aren't doing. Our tabs are links to other pages. It doesn't provide the functionality this does of collapsing items into a dropdown if they are too large. (bootstrap does also have collapse.js, but that's slightly different, and not quite what we're looking for here) We could use bootstrap's css here, but that will either require changing markup (which this PR carefully avoided), or require additional complexity to use the same mixins in out |
Thanks John. 🚀 🚢 |
Thank you everyone |
Thank you, looks great! |
First step in #633
I would love some feedback on the JS. I liked bringing this in house. I know there's a library out there that probably does this plus a million things but that's a road I always try to avoid going down.
<nav>
element: fecc715#commitcomment-16168308.tab
class: fecc715#commitcomment-16168251Before
## After