2023-11-16 12:17:36 +01:00
|
|
|
<script>
|
|
|
|
|
export let highlight = false;
|
2024-02-16 14:50:34 +01:00
|
|
|
export let highlight_on_click = false
|
2023-11-16 12:17:36 +01:00
|
|
|
export let red = false;
|
|
|
|
|
export let round = false;
|
|
|
|
|
export let flat = false;
|
2023-11-16 16:33:35 +01:00
|
|
|
export let disabled = false;
|
2023-11-16 12:17:36 +01:00
|
|
|
export let icon = ""
|
|
|
|
|
export let icon_small = false;
|
|
|
|
|
export let label = ""
|
2023-11-16 16:33:35 +01:00
|
|
|
export let title = ""
|
2023-11-16 12:17:36 +01:00
|
|
|
export let link_href = ""
|
|
|
|
|
export let link_target = ""
|
|
|
|
|
export let click = e => {}
|
|
|
|
|
export let style = ""
|
|
|
|
|
export let type = ""
|
|
|
|
|
export let form = ""
|
2024-02-16 14:50:34 +01:00
|
|
|
|
|
|
|
|
let click_int = e => {
|
|
|
|
|
if (highlight_on_click) {
|
|
|
|
|
try {
|
|
|
|
|
click(e)
|
|
|
|
|
highlight = true
|
|
|
|
|
} catch (err) {
|
|
|
|
|
red = true
|
|
|
|
|
throw err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
click(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-16 12:17:36 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if link_target === ""}
|
|
|
|
|
<button
|
2024-02-16 14:50:34 +01:00
|
|
|
on:click={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}
|
2023-11-16 16:33:35 +01:00
|
|
|
disabled={disabled ? "disabled":""}
|
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
|
|
|
|
|
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}
|
2023-11-16 16:33:35 +01:00
|
|
|
disabled={disabled ? "disabled":""}
|
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}
|
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.button {
|
|
|
|
|
flex: 0 0 content;
|
|
|
|
|
}
|
|
|
|
|
.flat {
|
|
|
|
|
background: none;
|
|
|
|
|
margin: 0;
|
2024-02-15 18:52:46 +01:00
|
|
|
color: var(--body_text_color);
|
2023-11-16 12:17:36 +01:00
|
|
|
}
|
|
|
|
|
</style>
|