forked from themesberg/flowbite-svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlButton.svelte
More file actions
47 lines (42 loc) · 1.55 KB
/
ControlButton.svelte
File metadata and controls
47 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script lang="ts">
import { controlButton } from "./theme";
import clsx from "clsx";
import type { ControlButtonProps } from "$lib";
import { getTheme } from "$lib/theme/themeUtils";
let { children, forward, name, class: className, spanClass, ...restProps }: ControlButtonProps = $props();
const { base, span } = $derived(controlButton({ forward }));
const theme = $derived(getTheme("controlButton"));
</script>
<button type="button" class={base({ class: clsx(className, theme) })} {...restProps}>
{#if children}
{@render children()}
{:else}
<span class={span({ class: clsx(spanClass) })}>
{#if forward}
<svg aria-hidden="true" class="h-5 w-5 sm:h-6 sm:w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
{:else}
<svg aria-hidden="true" class="h-5 w-5 sm:h-6 sm:w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
{/if}
{#if name}
<span class="sr-only">{name}</span>
{/if}
</span>
{/if}
</button>
<!--
@component
[Go to docs](https://flowbite-svelte.com/)
## Type
[ControlButtonProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L492)
## Props
@prop children
@prop forward
@prop name
@prop class: className
@prop spanClass
@prop ...restProps
-->