Remove not allowed cursor from Contributors and BranchSelector

Adds also HoverPopover tooltips, with some hints
This commit is contained in:
Sebastian Martinez
2023-11-17 10:19:57 +01:00
parent 709450cbac
commit b331f446ee
10 changed files with 111 additions and 69 deletions
+56 -28
View File
@@ -11,6 +11,7 @@
import IconSmall from "@app/components/IconSmall.svelte";
import Link from "@app/components/Link.svelte";
import Button from "@app/components/Button.svelte";
import HoverPopover from "@app/components/HoverPopover.svelte";
export let branches: Array<{ name: string; route: Route }>;
export let node: BaseUrl;
@@ -35,39 +36,66 @@
}
</style>
<div class="branch" title="Current branch">
<div class="branch">
{#if selectedBranch}
<Popover
popoverPadding="0"
popoverPositionTop="2.5rem"
popoverBorderRadius="var(--border-radius-small)">
<Button
variant="outline"
let:expanded
let:toggle
on:click={toggle}
slot="toggle"
styleBorderRadius="var(--border-radius-tiny) 0 0 var(--border-radius-tiny)"
title="Change branch"
disabled={hideDropdown}>
<IconSmall name="branch" />
<div class="identifier">{selectedBranch}</div>
<IconSmall name={expanded ? "chevron-up" : "chevron-down"} />
</Button>
{#if hideDropdown}
<HoverPopover popoverPositionLeft="0" popoverPositionTop="0.5rem">
<Button
ariaLabel="canonical-branch"
variant="outline"
styleBorderRadius="var(--border-radius-tiny) 0 0 var(--border-radius-tiny)"
slot="toggle"
disabled
notAllowed={false}>
<IconSmall name="branch" />
<div class="identifier">{project.defaultBranch}</div>
</Button>
<div
class="txt-small"
style:padding="0.5rem 0.5rem 0.5rem 0.75rem"
slot="popover">
<div style:margin-bottom="1rem">
You are currently browsing the canonical branch.
</div>
<div>If you want to browse a specific branch,</div>
<div>you need to select the desired remote first.</div>
</div>
</HoverPopover>
{:else}
<Popover
popoverPadding="0"
popoverPositionTop="2.5rem"
popoverBorderRadius="var(--border-radius-small)">
<Button
variant="outline"
let:expanded
let:toggle
on:click={toggle}
slot="toggle"
styleBorderRadius="var(--border-radius-tiny) 0 0 var(--border-radius-tiny)"
title="Change branch"
disabled={hideDropdown}>
<IconSmall name="branch" />
<div class="identifier">{selectedBranch}</div>
<IconSmall
name={hideDropdown && expanded ? "chevron-up" : "chevron-down"} />
</Button>
<DropdownList slot="popover" items={branches}>
<svelte:fragment slot="item" let:item>
<Link route={item.route} on:afterNavigate={() => closeFocused()}>
<DropdownListItem selected={item.name === selectedBranch}>
<div class="identifier">{item.name}</div>
</DropdownListItem>
</Link>
</svelte:fragment>
</DropdownList>
</Popover>
<DropdownList slot="popover" items={branches}>
<svelte:fragment slot="item" let:item>
<Link route={item.route} on:afterNavigate={() => closeFocused()}>
<DropdownListItem selected={item.name === selectedBranch}>
<div class="identifier">{item.name}</div>
</DropdownListItem>
</Link>
</svelte:fragment>
</DropdownList>
</Popover>
{/if}
{/if}
<Button
title="Current HEAD"
variant={selectedBranch ? "gray" : "outline"}
styleBorderRadius={selectedBranch
? "0 var(--border-radius-tiny) var(--border-radius-tiny) 0"
+16 -6
View File
@@ -11,6 +11,7 @@
import Link from "@app/components/Link.svelte";
import Button from "@app/components/Button.svelte";
import Radio from "@app/components/Radio.svelte";
import HoverPopover from "@app/components/HoverPopover.svelte";
export let node: BaseUrl;
export let branches: Array<{ name: string; route: Route }>;
@@ -100,11 +101,20 @@
</Link>
</Radio>
<Button disabled variant="outline">
<IconSmall name="user" />
<div>
{tree.stats.contributors}
{pluralize("contributor", tree.stats.contributors)}
<HoverPopover popoverPositionLeft="0" popoverPositionTop="0.5rem">
<Button disabled notAllowed={false} variant="outline" slot="toggle">
<IconSmall name="user" />
<div>
{tree.stats.contributors}
{pluralize("contributor", tree.stats.contributors)}
</div>
</Button>
<div
class="txt-small"
style:padding="0.5rem 0.5rem 0.5rem 0.75rem"
slot="popover">
<div style:margin-bottom="1rem">Coming soon.</div>
<div>Listing all contributors is not yet implemented.</div>
</div>
</Button>
</HoverPopover>
</div>