mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Introduce a peer/branch/tag selector in the repository source and commits views, letting you browse the canonical refs or any peer's namespace.
72 lines
1.6 KiB
Svelte
72 lines
1.6 KiB
Svelte
<script lang="ts">
|
|
import type { ComponentProps } from "svelte";
|
|
|
|
import Button from "@app/components/Button.svelte";
|
|
import Icon from "@app/components/Icon.svelte";
|
|
import TextInput from "@app/components/TextInput.svelte";
|
|
|
|
interface Props {
|
|
hasItems?: boolean;
|
|
placeholder: string;
|
|
icon?: ComponentProps<typeof Icon>["name"];
|
|
show: boolean;
|
|
value: string;
|
|
onFocus?: () => void;
|
|
onSubmit?: () => void;
|
|
styleHeight?: "1.75rem" | "2rem" | "2.5rem";
|
|
}
|
|
|
|
/* eslint-disable prefer-const */
|
|
let {
|
|
hasItems = true,
|
|
placeholder,
|
|
icon = "filter",
|
|
show = $bindable(),
|
|
value = $bindable(),
|
|
onFocus,
|
|
onSubmit,
|
|
styleHeight = "2rem",
|
|
}: Props = $props();
|
|
/* eslint-enable prefer-const */
|
|
</script>
|
|
|
|
{#if hasItems}
|
|
{#if show}
|
|
<TextInput
|
|
autofocus
|
|
{onFocus}
|
|
{onSubmit}
|
|
onBlur={() => {
|
|
if (value === "") {
|
|
show = false;
|
|
}
|
|
}}
|
|
onDismiss={() => {
|
|
value = "";
|
|
show = false;
|
|
}}
|
|
{placeholder}
|
|
{styleHeight}
|
|
keyShortcuts="ctrl+f"
|
|
bind:value>
|
|
{#snippet left()}
|
|
<div
|
|
style:color="var(--color-text-secondary)"
|
|
style:padding-left="0.5rem">
|
|
<Icon name={icon} />
|
|
</div>
|
|
{/snippet}
|
|
</TextInput>
|
|
{:else}
|
|
<div style:display="flex" style:padding="0 1px">
|
|
<Button
|
|
variant="naked"
|
|
{styleHeight}
|
|
keyShortcuts="ctrl+f"
|
|
onclick={() => (show = true)}>
|
|
<Icon name="filter" />
|
|
</Button>
|
|
</div>
|
|
{/if}
|
|
{/if}
|