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

feat: allow for default select icon to be hidden #817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
66 changes: 37 additions & 29 deletions apps/www/src/lib/registry/new-york/ui/select/select-item.svelte
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
<script lang="ts">
import { cn } from "$lib/utils";
import { Select as SelectPrimitive } from "bits-ui";
import Check from "svelte-radix/Check.svelte";
import { cn } from '$lib/utils'
import Check from 'lucide-svelte/icons/check'
import { Select as SelectPrimitive } from 'bits-ui'

type $$Props = SelectPrimitive.ItemProps;
type $$Events = Required<SelectPrimitive.ItemEvents>;
type $$Props = SelectPrimitive.ItemProps
type $$Events = SelectPrimitive.ItemEvents

let className: $$Props["class"] = undefined;
export let value: $$Props["value"];
export let label: $$Props["label"] = undefined;
export let disabled: $$Props["disabled"] = undefined;
export { className as class };
let className: $$Props['class'] = undefined
export let value: $$Props['value']
export let label: $$Props['label'] = undefined
export let disabled: $$Props['disabled'] = undefined
export let showSelectIcon: $$Props['customItem'] = true
export { className as class }
</script>

<SelectPrimitive.Item
{value}
{disabled}
{label}
class={cn(
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",
className
)}
{...$$restProps}
on:click
on:pointermove
on:focusin
{value}
{disabled}
{label}
class={cn(
`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 ${showSelectIcon ? 'pl-8' : 'py-1.5'} pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50`,
className
)}
{...$$restProps}
on:click
on:keydown
on:focusin
on:focusout
on:pointerleave
on:pointermove
>
<span class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<Check class="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<slot>
{label ? label : value}
</slot>
{#if showSelectIcon}
<span
class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
>
<SelectPrimitive.ItemIndicator>
<Check class="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
{/if}
<slot>
{label ? label : value}
</slot>
</SelectPrimitive.Item>
Loading