Skip to content

Commit

Permalink
refactor label
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Aug 2, 2023
1 parent cccd69d commit c3b2ea3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 12 additions & 8 deletions apps/www/src/lib/components/ui/label/Label.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<script lang="ts">
import { cva } from "class-variance-authority";
import { Label as LabelPrimitive } from "radix-svelte";
import { cn } from "$lib/utils";
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
);
import { getLabel, melt } from ".";
let className: string | undefined | null = undefined;
export { className as class };
const label = getLabel();
</script>

<LabelPrimitive.Root class={cn(labelVariants(), className)} {...$$restProps}>
<label
use:melt={$label}
class={cn(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
className
)}
{...$$restProps}
>
<slot />
</LabelPrimitive.Root>
</label>
9 changes: 9 additions & 0 deletions apps/www/src/lib/components/ui/label/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
import { createLabel, melt } from "@melt-ui/svelte";

export { default as Label } from "./Label.svelte";
export { melt };
export function getLabel() {
const {
elements: { root: label }
} = createLabel();
return label;
}

0 comments on commit c3b2ea3

Please sign in to comment.