@noxlovette/material 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,7 +14,7 @@ Floating action buttons (FABs) help people take primary actions.
|
|
|
14
14
|
import { fab } from './theme.js';
|
|
15
15
|
import type { FABProps } from './types.js';
|
|
16
16
|
import FABMenu from './FABMenu.svelte';
|
|
17
|
-
import { Layer, Icon } from '../../utils/index.js';
|
|
17
|
+
import { Layer, Icon, LoadingIndicator } from '../../utils/index.js';
|
|
18
18
|
import { clickOutside } from '../../actions/index.js';
|
|
19
19
|
import { Button, type ButtonRootProps } from 'bits-ui';
|
|
20
20
|
|
|
@@ -26,6 +26,7 @@ Floating action buttons (FABs) help people take primary actions.
|
|
|
26
26
|
config = 'primary',
|
|
27
27
|
iconProps,
|
|
28
28
|
label,
|
|
29
|
+
loading,
|
|
29
30
|
expanded = false,
|
|
30
31
|
class: className,
|
|
31
32
|
withMenu,
|
|
@@ -48,7 +49,7 @@ Floating action buttons (FABs) help people take primary actions.
|
|
|
48
49
|
);
|
|
49
50
|
|
|
50
51
|
function handleClick(e: MouseEvent) {
|
|
51
|
-
if (disabled) {
|
|
52
|
+
if (disabled || loading) {
|
|
52
53
|
e.preventDefault();
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
@@ -68,8 +69,12 @@ Floating action buttons (FABs) help people take primary actions.
|
|
|
68
69
|
data-cy="m3-fab"
|
|
69
70
|
{...restProps as ButtonRootProps}
|
|
70
71
|
>
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
{#if loading}
|
|
73
|
+
<LoadingIndicator />
|
|
74
|
+
{:else}
|
|
75
|
+
<Icon {...withMenu && showMenu ? { name: 'close' } : iconProps} class={icon()} />
|
|
76
|
+
<Layer />
|
|
77
|
+
{/if}
|
|
73
78
|
{#if expanded && !(withMenu && showMenu)}
|
|
74
79
|
<p class={labelClass()}>
|
|
75
80
|
{label}
|
|
@@ -147,6 +147,8 @@ export type FABProps = FABVariants & AnchorButtonAttributes & {
|
|
|
147
147
|
withMenu?: boolean;
|
|
148
148
|
/** Configuration for the FAB's icon. */
|
|
149
149
|
iconProps: IconProps;
|
|
150
|
+
/** Whether the FAB is in a loading state. Displays a loading indicator instead of the icon. */
|
|
151
|
+
loading?: boolean;
|
|
150
152
|
/** The URL to link to. If provided, the FAB will render as an `<a>` tag. */
|
|
151
153
|
href?: string;
|
|
152
154
|
/** The `formaction` attribute for the FAB when used in a form. */
|
|
@@ -10,16 +10,17 @@ This component takes NavbarItems as its children
|
|
|
10
10
|
@see https://m3.material.io/components/navigation-bar/overview
|
|
11
11
|
-->
|
|
12
12
|
<script lang="ts">
|
|
13
|
+
import clsx from 'clsx';
|
|
13
14
|
import { NavigationMenu } from 'bits-ui';
|
|
14
15
|
import { navbar } from './theme.js';
|
|
15
16
|
import type { NavBarProps } from './types.js';
|
|
16
17
|
|
|
17
|
-
const { children, fab, ghost = false }: NavBarProps = $props();
|
|
18
|
+
const { children, fab, ghost = false, class: className, ...restProps }: NavBarProps = $props();
|
|
18
19
|
|
|
19
20
|
const { base, items, fab: fabCls, ghost: ghostCls } = $derived(navbar());
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
|
-
<div class={base()}>
|
|
23
|
+
<div class={base({ class: clsx(className) })} {...restProps}>
|
|
23
24
|
{#if fab}
|
|
24
25
|
<div class={fabCls()}>
|
|
25
26
|
{@render fab?.()}
|