2025-03-28 14:16:20 +01:00
|
|
|
<script lang="ts">
|
2025-10-13 16:05:50 +02:00
|
|
|
let {
|
|
|
|
|
highlight = $bindable(false),
|
|
|
|
|
highlight_on_click = false,
|
|
|
|
|
red = $bindable(false),
|
|
|
|
|
round = false,
|
|
|
|
|
flat = false,
|
|
|
|
|
disabled = false,
|
|
|
|
|
icon = "",
|
|
|
|
|
icon_small = false,
|
|
|
|
|
label = "",
|
|
|
|
|
title = null,
|
|
|
|
|
link_href = "",
|
|
|
|
|
link_target = "_self",
|
|
|
|
|
click = null,
|
|
|
|
|
style = null,
|
|
|
|
|
type = null,
|
|
|
|
|
form = null
|
|
|
|
|
}: {
|
|
|
|
|
highlight?: boolean;
|
|
|
|
|
highlight_on_click?: boolean;
|
|
|
|
|
red?: boolean;
|
|
|
|
|
round?: boolean;
|
|
|
|
|
flat?: boolean;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
icon?: string;
|
|
|
|
|
icon_small?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
title?: any;
|
|
|
|
|
link_href?: string;
|
|
|
|
|
link_target?: string;
|
|
|
|
|
click?: (e?: MouseEvent) => void;
|
|
|
|
|
style?: any;
|
|
|
|
|
type?: any;
|
|
|
|
|
form?: any;
|
|
|
|
|
} = $props();
|
2024-02-16 14:50:34 +01:00
|
|
|
|
2025-03-28 14:16:20 +01:00
|
|
|
let click_int = (e: MouseEvent) => {
|
2024-02-16 14:50:34 +01:00
|
|
|
if (highlight_on_click) {
|
|
|
|
|
try {
|
|
|
|
|
click(e)
|
|
|
|
|
highlight = true
|
|
|
|
|
} catch (err) {
|
|
|
|
|
red = true
|
|
|
|
|
throw err
|
|
|
|
|
}
|
2025-03-28 14:16:20 +01:00
|
|
|
} else if (click !== null) {
|
2024-02-16 14:50:34 +01:00
|
|
|
click(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-16 12:17:36 +01:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-12 17:53:53 +01:00
|
|
|
{#if link_href === ""}
|
2023-11-16 12:17:36 +01:00
|
|
|
<button
|
2025-10-13 16:05:50 +02:00
|
|
|
onclick={click_int}
|
2023-11-16 12:17:36 +01:00
|
|
|
class="button"
|
|
|
|
|
class:button_highlight={highlight}
|
|
|
|
|
class:button_red={red}
|
|
|
|
|
class:round
|
|
|
|
|
class:flat
|
2023-11-16 16:33:35 +01:00
|
|
|
title={title}
|
2023-11-16 12:17:36 +01:00
|
|
|
style={style}
|
|
|
|
|
type={type}
|
|
|
|
|
form={form}
|
2025-03-28 14:16:20 +01:00
|
|
|
disabled={disabled ? true:null}
|
2023-11-16 12:17:36 +01:00
|
|
|
>
|
|
|
|
|
{#if icon !== ""}
|
|
|
|
|
<i class="icon" class:small={icon_small}>{icon}</i>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if label !== ""}
|
|
|
|
|
<span>{label}</span>
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
{:else}
|
|
|
|
|
<a
|
2025-10-13 16:05:50 +02:00
|
|
|
onclick={click_int}
|
2023-11-16 12:17:36 +01:00
|
|
|
href="{link_href}"
|
|
|
|
|
target={link_target}
|
|
|
|
|
class="button"
|
|
|
|
|
class:button_highlight={highlight}
|
|
|
|
|
class:button_red={red}
|
|
|
|
|
class:round
|
|
|
|
|
class:flat
|
2023-11-16 16:33:35 +01:00
|
|
|
title={title}
|
2023-11-16 12:17:36 +01:00
|
|
|
style={style}
|
|
|
|
|
>
|
|
|
|
|
{#if icon !== ""}
|
|
|
|
|
<i class="icon" class:small={icon_small}>{icon}</i>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if label !== ""}
|
|
|
|
|
<span>{label}</span>
|
|
|
|
|
{/if}
|
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.button {
|
|
|
|
|
flex: 0 0 content;
|
|
|
|
|
}
|
|
|
|
|
.flat {
|
|
|
|
|
background: none;
|
2024-02-15 18:52:46 +01:00
|
|
|
color: var(--body_text_color);
|
2024-07-09 18:18:26 +02:00
|
|
|
box-shadow: none;
|
2023-11-16 12:17:36 +01:00
|
|
|
}
|
|
|
|
|
</style>
|