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

Svelte: add repo popovers to repo name in header and in dynamic filters #62865

Merged
merged 6 commits into from
May 30, 2024

Conversation

camdencheek
Copy link
Member

This adds the RepoPopover hover info to the dynamic filters in the search sidebar (replacing the full repo name tooltip) and to the global header.

Test plan

screenshot-2024-05-22_14-30-16.mp4

@cla-bot cla-bot bot added the cla-signed label May 22, 2024
@camdencheek camdencheek force-pushed the cc/repo-popover-search-results branch from 5ed07ce to a22641e Compare May 22, 2024 19:00
Comment on lines 34 to 44
<slot name="item" {item}>
<SectionItem {item} {onFilterSelect}>
<slot name="label" slot="label" let:label let:value {label} {value} />
</SectionItem>
</slot>
Copy link
Member Author

Choose a reason for hiding this comment

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

Extracted this into a new component to make it easier to create a slot with a default, but overridable, value.

Comment on lines -48 to +52
type SectionItem,
type SectionItemData,
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed because I wanted a component named SectionItem now, so it makes sense to call this SectionItemData instead.

Comment on lines +127 to 145
<svelte:fragment slot="item" let:item>
<Popover showOnHover let:registerTrigger placement="right-start">
<div use:registerTrigger>
<SectionItem {item}>
<svelte:fragment slot="label" let:label>
<CodeHostIcon disableTooltip repository={label} />
<span>{displayRepoName(label)}</span>
</svelte:fragment>
</SectionItem>
</div>
<svelte:fragment slot="content">
{#await delay(fetchRepoPopoverData(getGraphQLClient(), item.label), 200) then data}
<RepoPopover {data} withHeader />
{:catch error}
<Alert size="slim" variant="danger">{error}</Alert>
{/await}
</svelte:fragment>
</Popover>
</svelte:fragment>
Copy link
Member Author

Choose a reason for hiding this comment

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

We want to wrap the whole item in the popover, not just the repo name, because otherwise the popover placement varies depending on the length of the repo name.

@camdencheek camdencheek requested review from a team and taiyab May 22, 2024 19:04
@taiyab
Copy link
Contributor

taiyab commented May 29, 2024

The one on the repo header on the repo pages needs to be offset a little on Y-axis (down a little).

@@ -35,23 +31,11 @@
<ul>
{#each limitedItems as item}
Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, do we need to specify a key properly in this loop here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so since the array is immutable. But we should probably be explicit about it

@@ -60,7 +64,16 @@

<GlobalHeaderPortal>
<nav aria-label="repository">
<h1><a href="/{repoName}">{displayRepoName}</a></h1>
<Popover showOnHover placement="bottom-start" let:registerTrigger>
<h1 use:registerTrigger><a href="/{repoName}">{displayRepoName}</a></h1>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a hover state here, it's been a case that people don't understand that this H1 element is clickable, since we are going to have a popover element to this hover state also makes sense here IMO

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, but I think we should save this for the planned header redesign

@camdencheek camdencheek marked this pull request as draft May 29, 2024 20:13
@camdencheek camdencheek marked this pull request as ready for review May 30, 2024 01:30
<SectionItem {item} {onFilterSelect}>
<slot name="label" slot="label" let:label let:value {label} {value} />
</SectionItem>
{#if $$slots.label}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this if statement live within SectionItems tags here? Or this would break the default slot as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, it seems there's an edge case where slot rendering cannot be conditional within a component. So I had to copy the fully component in the conditional. Another thing that gets much nicer in svelte 5

@camdencheek camdencheek merged commit 376cc7a into main May 30, 2024
9 checks passed
@camdencheek camdencheek deleted the cc/repo-popover-search-results branch May 30, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants