mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 04:39:58 +00:00
web/DialogButton: add "link" buttons
This commit is contained in:
parent
fe1d17ba8d
commit
0b06299da0
2 changed files with 31 additions and 15 deletions
|
@ -23,21 +23,36 @@
|
|||
onDestroy(() => clearInterval(interval));
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
class="button elevated popup-button {button.color}"
|
||||
class:color={button.color}
|
||||
class:active={button.main}
|
||||
{disabled}
|
||||
on:click={async () => {
|
||||
await button.action();
|
||||
closeFunc();
|
||||
}}
|
||||
>
|
||||
{button.text}{seconds ? ` (${seconds})` : ""}
|
||||
</button>
|
||||
|
||||
{#if button.link}
|
||||
<a
|
||||
class="button elevated link-button"
|
||||
class:color={button.color}
|
||||
class:active={button.main}
|
||||
href={button.link}
|
||||
>
|
||||
{button.text}
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
class="button elevated popup-button {button.color}"
|
||||
class:color={button.color}
|
||||
class:active={button.main}
|
||||
{disabled}
|
||||
on:click={async () => {
|
||||
await button.action();
|
||||
closeFunc();
|
||||
}}
|
||||
>
|
||||
{button.text}{seconds ? ` (${seconds})` : ""}
|
||||
</button>
|
||||
{/if}
|
||||
<style>
|
||||
.link-button {
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.popup-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
|
|
|
@ -6,7 +6,8 @@ export type DialogButton = {
|
|||
color?: "red",
|
||||
main: boolean,
|
||||
timeout?: number, // milliseconds
|
||||
action: () => unknown | Promise<unknown>
|
||||
action: () => unknown | Promise<unknown>,
|
||||
link?: string
|
||||
}
|
||||
|
||||
export type SmallDialogIcons = "warn-red";
|
||||
|
|
Loading…
Reference in a new issue