1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-10 14:54:19 +00:00

feat: add required indicator for required inputs (#993)

This commit is contained in:
Elias Schneider
2025-10-01 13:44:17 +02:00
committed by GitHub
parent 69e2083722
commit 043cce615d
12 changed files with 66 additions and 25 deletions

View File

@@ -36,7 +36,7 @@
<div {...restProps}>
{#if label}
<Label class="mb-0" for={id}>{label}</Label>
<Label required={input?.required} class="mb-0" for={id}>{label}</Label>
{/if}
{#if description}
<p class="text-muted-foreground mt-1 text-xs">

View File

@@ -26,8 +26,7 @@
<DropdownMenu.Label class="font-normal">
<div class="flex flex-col space-y-1">
<p class="text-sm leading-none font-medium">
{$userStore?.firstName}
{$userStore?.lastName}
{$userStore?.displayName}
</p>
<p class="text-muted-foreground text-xs leading-none">{$userStore?.email}</p>
</div>

View File

@@ -5,16 +5,25 @@
let {
ref = $bindable(null),
class: className,
required = false,
children,
...restProps
}: LabelPrimitive.RootProps = $props();
}: LabelPrimitive.RootProps & {
required?: boolean;
} = $props();
</script>
<LabelPrimitive.Root
bind:ref
data-slot="label"
class={cn(
'mb-3 flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
'mb-3 flex items-center gap-1.5 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
required && "after:text-[14px] after:text-red-500 after:content-['*']",
className
)}
{...restProps}
/>
>
{#if children}
{@render children()}
{/if}
</LabelPrimitive.Root>