-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 25 additions & 20 deletions
45
sites/docs/src/lib/registry/default/ui/button/button.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
<script lang="ts"> | ||
import { Button as ButtonPrimitive } from "bits-ui"; | ||
import { type Events, type Props, buttonVariants } from "./index.js"; | ||
import { type Props, buttonVariants } from "./index.js"; | ||
import { cn } from "$lib/utils.js"; | ||
type $$Props = Props; | ||
type $$Events = Events; | ||
let className: $$Props["class"] = undefined; | ||
export let variant: $$Props["variant"] = "default"; | ||
export let size: $$Props["size"] = "default"; | ||
export let builders: $$Props["builders"] = []; | ||
export { className as class }; | ||
let { | ||
class: className, | ||
variant = "default", | ||
size = "default", | ||
ref = $bindable(null), | ||
href = undefined, | ||
type = "button", | ||
children, | ||
...restProps | ||
}: Props = $props(); | ||
</script> | ||
|
||
<ButtonPrimitive.Root | ||
{builders} | ||
class={cn(buttonVariants({ variant, size, className }))} | ||
type="button" | ||
{...$$restProps} | ||
on:click | ||
on:keydown | ||
> | ||
<slot /> | ||
</ButtonPrimitive.Root> | ||
{#if href} | ||
<a bind:this={ref} class={cn(buttonVariants({ variant, size, className }))} {...restProps}> | ||
{@render children?.()} | ||
</a> | ||
{:else} | ||
<button | ||
bind:this={ref} | ||
class={cn(buttonVariants({ variant, size, className }))} | ||
{type} | ||
{...restProps} | ||
> | ||
{@render children?.()} | ||
</button> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters