2022-02-25 20:24:32 +08:00
|
|
|
<script lang="ts">
|
2022-05-12 12:40:41 +08:00
|
|
|
export let elem_id: string = "";
|
2023-03-16 05:01:53 +08:00
|
|
|
export let elem_classes: Array<string> = [];
|
2022-06-17 07:49:54 +08:00
|
|
|
export let visible: boolean = true;
|
2023-03-07 04:52:31 +08:00
|
|
|
export let variant: "primary" | "secondary" | "stop" = "secondary";
|
2023-06-08 09:35:31 +08:00
|
|
|
export let size: "sm" | "lg" = "lg";
|
2023-02-22 03:11:46 +08:00
|
|
|
export let disabled: boolean = false;
|
2023-06-22 03:34:12 +08:00
|
|
|
export let scale: number | null = null;
|
2023-06-08 09:35:31 +08:00
|
|
|
export let min_width: number | undefined = undefined;
|
2022-02-25 20:24:32 +08:00
|
|
|
</script>
|
|
|
|
|
2022-05-09 23:18:13 +08:00
|
|
|
<button
|
|
|
|
on:click
|
2023-01-18 04:47:40 +08:00
|
|
|
class:hide={!visible}
|
2023-03-16 05:01:53 +08:00
|
|
|
class="{size} {variant} {elem_classes.join(' ')}"
|
2023-06-08 09:35:31 +08:00
|
|
|
style:flex-grow={scale}
|
2023-06-22 03:25:25 +08:00
|
|
|
style:width={scale === 0 ? "fit-content" : null}
|
2023-06-08 09:35:31 +08:00
|
|
|
style:min-width={typeof min_width === "number"
|
|
|
|
? `calc(min(${min_width}px, 100%))`
|
|
|
|
: null}
|
2022-05-12 12:40:41 +08:00
|
|
|
id={elem_id}
|
2023-02-22 03:11:46 +08:00
|
|
|
{disabled}
|
2022-05-09 23:18:13 +08:00
|
|
|
>
|
2022-02-25 20:24:32 +08:00
|
|
|
<slot />
|
|
|
|
</button>
|
2023-01-18 04:47:40 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
button {
|
|
|
|
display: inline-flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2023-03-07 04:52:31 +08:00
|
|
|
transition: var(--button-transition);
|
|
|
|
box-shadow: var(--button-shadow);
|
2023-01-18 04:47:40 +08:00
|
|
|
padding: var(--size-0-5) var(--size-2);
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
2023-02-22 03:11:46 +08:00
|
|
|
button:hover,
|
|
|
|
button[disabled] {
|
2023-03-07 04:52:31 +08:00
|
|
|
box-shadow: var(--button-shadow-hover);
|
|
|
|
}
|
|
|
|
button:active {
|
|
|
|
box-shadow: var(--button-shadow-active);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
|
|
|
|
2023-02-22 03:11:46 +08:00
|
|
|
button[disabled] {
|
2023-02-23 03:23:38 +08:00
|
|
|
opacity: 0.5;
|
|
|
|
filter: grayscale(30%);
|
2023-02-22 03:11:46 +08:00
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
|
|
|
|
2023-01-18 04:47:40 +08:00
|
|
|
.hide {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.primary {
|
2023-03-07 04:52:31 +08:00
|
|
|
border: var(--button-border-width) solid var(--button-primary-border-color);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-primary-background-fill);
|
2023-03-07 04:52:31 +08:00
|
|
|
color: var(--button-primary-text-color);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
2023-02-22 03:11:46 +08:00
|
|
|
.primary:hover,
|
|
|
|
.primary[disabled] {
|
2023-01-18 04:47:40 +08:00
|
|
|
border-color: var(--button-primary-border-color-hover);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-primary-background-fill-hover);
|
2023-01-18 04:47:40 +08:00
|
|
|
color: var(--button-primary-text-color-hover);
|
|
|
|
}
|
|
|
|
|
|
|
|
.secondary {
|
2023-03-07 04:52:31 +08:00
|
|
|
border: var(--button-border-width) solid
|
|
|
|
var(--button-secondary-border-color);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-secondary-background-fill);
|
2023-03-07 04:52:31 +08:00
|
|
|
color: var(--button-secondary-text-color);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
|
|
|
|
2023-02-22 03:11:46 +08:00
|
|
|
.secondary:hover,
|
|
|
|
.secondary[disabled] {
|
2023-01-18 04:47:40 +08:00
|
|
|
border-color: var(--button-secondary-border-color-hover);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-secondary-background-fill-hover);
|
2023-01-18 04:47:40 +08:00
|
|
|
color: var(--button-secondary-text-color-hover);
|
|
|
|
}
|
|
|
|
|
|
|
|
.stop {
|
2023-03-07 04:52:31 +08:00
|
|
|
border: var(--button-border-width) solid var(--button-cancel-border-color);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-cancel-background-fill);
|
2023-03-07 04:52:31 +08:00
|
|
|
color: var(--button-cancel-text-color);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
|
|
|
|
2023-02-22 03:11:46 +08:00
|
|
|
.stop:hover,
|
|
|
|
.stop[disabled] {
|
2023-01-18 04:47:40 +08:00
|
|
|
border-color: var(--button-cancel-border-color-hover);
|
2023-03-18 08:20:55 +08:00
|
|
|
background: var(--button-cancel-background-fill-hover);
|
2023-01-18 04:47:40 +08:00
|
|
|
color: var(--button-cancel-text-color-hover);
|
|
|
|
}
|
|
|
|
|
|
|
|
.sm {
|
2023-03-07 04:52:31 +08:00
|
|
|
border-radius: var(--button-small-radius);
|
|
|
|
padding: var(--button-small-padding);
|
|
|
|
font-weight: var(--button-small-text-weight);
|
|
|
|
font-size: var(--button-small-text-size);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.lg {
|
2023-03-07 04:52:31 +08:00
|
|
|
border-radius: var(--button-large-radius);
|
|
|
|
padding: var(--button-large-padding);
|
|
|
|
font-weight: var(--button-large-text-weight);
|
|
|
|
font-size: var(--button-large-text-size);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
|
|
|
</style>
|