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

Add href prop to Combobox to get reactive hrefs working correctly #2428

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/lib/components/top-nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import DataEncoderStatus from '$lib/components/data-encoder-status.svelte';
import TimezoneSelect from '$lib/components/timezone-select.svelte';
import Button from '$lib/holocene/button.svelte';
import Combobox from '$lib/holocene/combobox/combobox.svelte';
import { translate } from '$lib/i18n/translate';
import { lastUsedNamespace } from '$lib/stores/namespaces';
Expand Down Expand Up @@ -48,16 +47,9 @@
on:change={handleNamespaceSelect}
minSize={32}
actionTooltip={translate('namespaces.go-to-namespace')}
>
<Button
slot="action"
variant="ghost"
size="xs"
{href}
disabled={!namespaceExists}
leadingIcon="external-link"
/>
</Combobox>
{href}
hrefDisabled={!namespaceExists}
/>
</div>
<div class="flex items-center gap-2">
<TimezoneSelect position={screenWidth < 768 ? 'left' : 'right'} />
Expand Down
27 changes: 27 additions & 0 deletions src/lib/holocene/combobox/combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import Menu from '$lib/holocene/menu/menu.svelte';

import Badge from '../badge.svelte';
import Button from '../button.svelte';
import Chip from '../chip.svelte';
import type { IconName } from '../icon';
import Icon from '../icon/icon.svelte';
Expand Down Expand Up @@ -45,6 +46,8 @@
error?: string;
valid?: boolean;
actionTooltip?: string;
href?: string;
hrefDisabled?: boolean;
}

type MultiSelectProps = {
Expand Down Expand Up @@ -109,6 +112,8 @@
export let deselectAllLabel = 'Deselect All';
export let removeChipLabel = 'Remove Option';
export let actionTooltip = '';
export let href = '';
export let hrefDisabled = false;

export let numberOfItemsSelectedLabel = (count: number) =>
`${count} option${count > 1 ? 's' : ''} selected`;
Expand Down Expand Up @@ -402,6 +407,28 @@
<slot name="action" />
{/if}
</div>
{:else if href}
<div class="ml-1 flex h-full items-center border-l-2 border-subtle p-0.5">
{#if actionTooltip}
<Tooltip text={actionTooltip} right>
<Button
variant="ghost"
size="xs"
{href}
disabled={hrefDisabled}
leadingIcon="external-link"
/>
</Tooltip>
{:else}
<Button
variant="ghost"
size="xs"
{href}
disabled={hrefDisabled}
leadingIcon="external-link"
/>
{/if}
</div>
{/if}
</div>

Expand Down
Loading