-
Notifications
You must be signed in to change notification settings - Fork 151
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
Tab
component abstraction
#1882
Conversation
How about also add the runtime tab, and indicate "to be continued" explicitly 🤔? |
I don't think there's a lot of value in that, but if you want, feel free to add it. The point that I was trying to make is to do small PRs that are easy to review, while still keeping the code working in the meantime :) |
663186d
to
175f1b0
Compare
@Kobzol I personally find abstracting |
I agree that it could be unwieldy to generalize the tab component, but I like the current state of the PR - CSS styling and switching of tabs can be kept in the So 👍 from me. |
Challenge accepted 🫠🫠 |
@Kobzol Basically, the I was thinking a better way to handle those calculation rather than put them all in the If you have any opinion please let me know 🙏. |
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.
Oh, you also made the tab switcher generic 😅 I liked that you made the single tab to be a separate component, to avoid duplicating its DOM and CSS. I pretty much wanted to stay at that, and merge the PR once it was cleaned up.
Having the "tab switcher" generic is even better, but it should be really a generic component. Currently, you hardcode the Tab
type in the tab switcher, and also compileTimeSummary
, runtimeSummary
etc. These types shouldn't be known to a generic tab switcher component. The tab switcher should just receive N tabs (Vue components), handle click events on each tab, and then somehow mark the selected tab. I think that a reasonable API for that would be to use something like React render props (maybe there's some equivalent in Vue?), so that the switcher uses a function to render each tab, and passes the function an index that states which tab is selected. Something like this:
<TabSwitcher tabCount="3" :renderTab="(index: number) => renderTabWithIndex(index)" />
The above interface example uses integer indices, to make the tab switcher generic. Maybe there is some TypeScript type-level magic that would allow passing in an iterable type (generic enum?) that would allow selecting the individual tabs using a proper type, rather than just indices, but it could be quite ugly.
If you want to, you can try to see if you can get something done with TypeScript so that we can pass arbitrary types to the tab switcher, but if it doesn't work out, I think that just using indices would be good enough.
Lol For challenging of generalizing But really thank you for the advice and code review |
@Kobzol If everything's fine, we can merge this PR. I'll open a new one to create tabs for the graph page. |
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.
One final nit, otherwise LGTM.
If you don't use : before the name of the attribute, it will be evaluated as a string Ref: rust-lang#1882 (comment)
If you don't use : before the name of the attribute, it will be evaluated as a string Ref: rust-lang#1882 (comment)
Thanks! :) |
For #1817