2022-02-25 20:24:32 +08:00
|
|
|
<script lang="ts">
|
2022-07-22 02:12:46 +08:00
|
|
|
import { get_styles } from "../../utils";
|
2022-06-02 01:02:18 +08:00
|
|
|
import type { Styles } from "@gradio/utils";
|
2022-05-12 12:40:41 +08:00
|
|
|
|
2022-06-02 01:02:18 +08:00
|
|
|
export let style: Styles = {};
|
2022-05-12 12:40:41 +08:00
|
|
|
export let elem_id: 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";
|
|
|
|
export let size: "sm" | "lg" = style.size || "lg";
|
2023-02-22 03:11:46 +08:00
|
|
|
export let disabled: boolean = false;
|
2022-06-02 02:33:53 +08:00
|
|
|
|
2023-01-18 04:47:40 +08:00
|
|
|
$: ({ styles } = get_styles(style, ["full_width"]));
|
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}
|
|
|
|
class="{size} {variant}"
|
|
|
|
style={styles}
|
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);
|
|
|
|
background: var(--button-primary-background);
|
|
|
|
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);
|
|
|
|
background: var(--button-primary-background-hover);
|
|
|
|
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);
|
|
|
|
background: var(--button-secondary-background);
|
|
|
|
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);
|
|
|
|
background: var(--button-secondary-background-hover);
|
|
|
|
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);
|
|
|
|
background: var(--button-cancel-background);
|
|
|
|
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);
|
|
|
|
background: var(--button-cancel-background-hover);
|
|
|
|
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>
|