Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/lib/buttons/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { SizeType, ButtonProps } from "$lib";
import { getTheme } from "$lib/theme/themeUtils";
import { button } from "./theme";
import Spinner from "$lib/spinner/Spinner.svelte";

const group: SizeType = getContext("group");
const ctxDisabled: boolean | undefined = getContext("disabled");
Expand All @@ -28,10 +29,7 @@
<button type="button" {...restProps} class={btnCls} disabled={isDisabled}>
{@render children?.()}
{#if loading}
<svg class="ml-2 h-4 w-4 animate-spin text-white" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
</svg>
<Spinner size="4" class="ms-2" type="loading" color={actualColor} />
{/if}
</button>
{:else}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/spinner/Spinner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
<animateTransform attributeName="transform" type="rotate" from="0 50 50" to="360 50 50" dur="1.2s" repeatCount="indefinite" />
</g>
</svg>
{:else if type === "loading"}
<svg {...restProps} role="status" class={spinnerClass} fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
</svg>
{/if}

<!--
Expand Down
8 changes: 6 additions & 2 deletions src/lib/spinner/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const spinner = tv({
dots: "inline-flex items-center justify-center",
bars: "inline-flex items-center justify-center",
pulse: "animate-pulse",
orbit: ""
orbit: "",
loading: "animate-spin"
},
color: {
primary: "fill-primary-600 text-gray-300",
Expand All @@ -32,7 +33,10 @@ export const spinner = tv({
purple: "fill-purple-600 text-gray-300",
fuchsia: "fill-fuchsia-600 text-gray-300",
pink: "fill-pink-600 text-gray-300",
rose: "fill-rose-600 text-gray-300"
rose: "fill-rose-600 text-gray-300",
light: "fill-white text-gray-900",
dark: "fill-gray-800 text-white",
alternative: "fill-transparent text-gray-900"
},
size: {
"4": "w-4 h-4",
Expand Down
7 changes: 2 additions & 5 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ export interface TimepickerProps {
timeIntervals?: string[];
columns?: ColumnCount;
// Callback props instead of events
onselect?: (data: { time: string; endTime: string; [key: string]: string }) => void;
onselect?: (data: { time: string; endTime: string;[key: string]: string }) => void;
}

// textarea
Expand Down Expand Up @@ -1551,10 +1551,7 @@ export type SpeedDialButtonProps = ButtonProps &
};

// spinner
export interface SpinnerProps extends SVGAttributes<SVGSVGElement> {
type?: "default" | "dots" | "bars" | "pulse" | "orbit";
color?: SpinnerVaraiants["color"];
size?: SpinnerVaraiants["size"];
export interface SpinnerProps extends SpinnerVaraiants, Omit<SVGAttributes<SVGSVGElement>, "color" | "type"> {
currentFill?: string;
currentColor?: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/routes/docs-examples/components/spinner/Type.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
<Spinner type="bars" color="blue" />
<Spinner type="orbit" color="rose" />
<Spinner type="pulse" color="green" />
<Spinner type="loading" color="light" />