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

Tab component abstraction #1882

Merged
merged 8 commits into from
Apr 2, 2024
Merged

Tab component abstraction #1882

merged 8 commits into from
Apr 2, 2024

Conversation

chengr4
Copy link
Contributor

@chengr4 chengr4 commented Mar 26, 2024

For #1817

@chengr4
Copy link
Contributor Author

chengr4 commented Mar 26, 2024

Tab UI Added

Screenshot 2024-03-26 at 4 50 54 PM

@Kobzol
Copy link
Contributor

Kobzol commented Mar 26, 2024

Hi, thanks for the PR. I think that we can do this in parts, i.e. in the first PR, just introduce tabs, and add more stuff in later PRs.

I'm not sure how should the tabs work though. Compile-time vs benchmarks optimized for size are completely separate "axes", and it doesn't really make sense to treat them as being on the same level.

I think that we could do sort of two level grouping. On the top level, there could be two tabs (compile-time vs runtime benchmarks), and then inside each tab, there could be several subsets of the data, and some of them could be collapsed. Something like this:
image

Again, I would start by just adding the tabs, maybe with first just adding a single tab for compile-time benchmarks, and not modifying anything else. It would also be nice to reuse the tab component from the compare page, if it could be done without complicating its code too much.

@chengr4
Copy link
Contributor Author

chengr4 commented Mar 27, 2024

How about also add the runtime tab, and indicate "to be continued" explicitly 🤔?

@chengr4 chengr4 changed the title Enhance user experience of graphs page Introduce tabs to graphs page Mar 27, 2024
@Kobzol
Copy link
Contributor

Kobzol commented Mar 27, 2024

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 :)

@chengr4 chengr4 force-pushed the graphs-category branch 2 times, most recently from 663186d to 175f1b0 Compare March 28, 2024 07:24
@chengr4
Copy link
Contributor Author

chengr4 commented Mar 28, 2024

@Kobzol
I basically just abstracted Tab component.
I will pause here until you agree to proceed. When you have time, please chech it out. Thank you.

I personally find abstracting Tabs to be quite challenging. However, if you believe it's necessary, please instruct me. Alternatively, my next step could be to add tabs on the graph page.

@Kobzol
Copy link
Contributor

Kobzol commented Mar 28, 2024

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 Tab component, and just the inner content is replaced with the slot. That seems straightforward enough. And since we will probably use tabs on more places, I think that it's nice to encapsulate it like this, to avoid repeating the styling and selection logic of the tabs.

So 👍 from me.

@chengr4
Copy link
Contributor Author

chengr4 commented Mar 28, 2024

And since we will probably use tabs on more places, I think that it's nice to encapsulate it like this, to avoid repeating the styling and selection logic of the tabs.

Challenge accepted 🫠🫠

@chengr4
Copy link
Contributor Author

chengr4 commented Apr 1, 2024

@Kobzol
I feel before I keep going, I should share the current state with you.

Basically, the Tabs was abstracted. I created an array for creating TabComponent and passed it into Tabs.
Moreover, all calculation and SummaryTable were lifted to compare/page.vue. I wish I am on the right path.

I was thinking a better way to handle those calculation rather than put them all in the compare/page.vue. I also found out we got another SummaryTable. Maybe it is another refactoring issue.

If you have any opinion please let me know 🙏.

Copy link
Contributor

@Kobzol Kobzol left a 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.

@chengr4
Copy link
Contributor Author

chengr4 commented Apr 2, 2024

Lol
I misunderstood you earlier. Actually, I also preferred the state before I abstracted TabSwitcher.

For challenging of generalizing TabSwitcher, we can leave it for next time.
I will revert commits and clean up.

But really thank you for the advice and code review

@chengr4
Copy link
Contributor Author

chengr4 commented Apr 2, 2024

@Kobzol
I reverted commits, please take a look to see if there are any other modifications needed,
when you are available.

If everything's fine, we can merge this PR. I'll open a new one to create tabs for the graph page.

@chengr4 chengr4 changed the title Introduce tabs to graphs page Tab component abstraction Apr 2, 2024
@chengr4 chengr4 marked this pull request as ready for review April 2, 2024 11:44
Copy link
Contributor

@Kobzol Kobzol left a 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.

site/frontend/src/pages/compare/tabs.vue Outdated Show resolved Hide resolved
chengr4 added a commit to chengr4/rustc-perf that referenced this pull request Apr 2, 2024
	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)
@Kobzol
Copy link
Contributor

Kobzol commented Apr 2, 2024

Thanks! :)

@Kobzol Kobzol enabled auto-merge April 2, 2024 12:51
@Kobzol Kobzol disabled auto-merge April 2, 2024 12:51
@Kobzol Kobzol enabled auto-merge (squash) April 2, 2024 12:52
@Kobzol Kobzol merged commit 39bfe5c into rust-lang:master Apr 2, 2024
11 checks passed
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.

2 participants