Files
classroomio/src/components/PrimaryButton/index.svelte
T

39 lines
1.1 KiB
Svelte
Raw Normal View History

2021-05-08 11:47:18 +03:00
<script>
2022-12-03 22:45:01 +01:00
import { Moon } from 'svelte-loading-spinners';
2021-08-18 19:47:02 +03:00
import { VARIANTS, VARIANTS_CLASS } from './constants';
2021-12-30 22:30:30 +02:00
2021-08-18 19:47:02 +03:00
export let label = '';
export let className = '';
2021-05-14 08:04:35 +03:00
export let onClick = () => {};
2021-08-18 19:47:02 +03:00
export let name = '';
2022-11-28 11:23:46 +01:00
export let type = 'button';
2021-06-26 21:32:42 +03:00
export let variant = VARIANTS.CONTAINED;
2021-07-03 19:29:41 +00:00
export let disablePadding = false;
export let isDisabled = false;
2021-12-30 22:30:30 +02:00
export let isLoading = false;
$: variant = isLoading ? VARIANTS.OUTLINED : variant;
$: isDisabled = isLoading ? true : isDisabled;
2021-05-08 11:47:18 +03:00
</script>
<button
2021-07-03 19:29:41 +00:00
class="{isDisabled &&
2021-07-06 08:39:17 +03:00
'bg-opacity-25 hover:bg-opacity-25 cursor-not-allowed'} flex items-center h-auto {VARIANTS_CLASS[
variant
]} {!disablePadding &&
2022-11-28 11:23:46 +01:00
'py-1 px-5'} rounded-none {className} py-2 w-full justify-center sm:w-auto {isLoading &&
2022-12-03 22:45:01 +01:00
'py-2 border-blue-700'} hover:shadow-xl transition delay-150 duration-300 ease-in-out"
2021-05-14 08:04:35 +03:00
on:click={onClick}
{name}
{type}
2021-07-03 19:29:41 +00:00
disabled={isDisabled}
2021-05-08 11:47:18 +03:00
>
2021-12-30 22:30:30 +02:00
{#if isLoading}
2022-12-03 22:45:01 +01:00
<Moon size="30" color="#1d4ed8" unit="px" duration="1s" />
2021-12-30 22:30:30 +02:00
{:else if !!label}
2021-07-03 19:29:41 +00:00
{label}
{:else}
<slot />
{/if}
2021-05-08 11:47:18 +03:00
</button>