Basic
import { html, renderApp } from 'mates';
import { SpeedDial } from 'mates-ui';
import { DownloadIcon, EditIcon, MailIcon } from 'mates-icons';
const App = () => () => html`
${SpeedDial({
label: "Create",
actions: [
{ icon: EditIcon(), label: "Edit", onClick: () => {} },
{ icon: MailIcon({ size: 20 }), label: "Email", onClick: () => {} },
{ icon: DownloadIcon(), label: "Download", onClick: () => {} },
],
})}
`;
renderApp(App, document.getElementById('app'));
Positions
import { html, atom, renderApp } from 'mates';
import { SpeedDial, OutlinedButton, FilledButton } from 'mates-ui';
import { DeleteIcon, EditIcon, ShareIcon } from 'mates-icons';
const POSITIONS = ["bottom-right", "bottom-left", "bottom-center", "top-right", "top-left"];
const App = () => {
const pos = atom("bottom-right");
return () => html`
<x-col gap="var(--md-space-4)">
<x-row gap="var(--md-space-2)" wrap>
${POSITIONS.map((p) => pos() === p
? FilledButton(p, { size: "sm", onClick: () => pos.set(p) })
: OutlinedButton(p, { size: "sm", onClick: () => pos.set(p) })
)}
</x-row>
${SpeedDial({
label: "Position demo",
position: pos(),
actions: [
{ icon: EditIcon(), label: "Edit", onClick: () => {} },
{ icon: ShareIcon(), label: "Share", onClick: () => {} },
{ icon: DeleteIcon(), label: "Delete", onClick: () => {} },
],
})}
</x-col>
`;
};
renderApp(App, document.getElementById('app'));
Custom trigger icon
import { html, renderApp } from 'mates';
import { SpeedDial } from 'mates-ui';
import { BookmarkIcon, DeleteIcon, FavoriteIcon, PrintIcon, ShareIcon } from 'mates-icons';
const App = () => () => html`
${SpeedDial({
label: "Favourites",
icon: FavoriteIcon({ size: 24 }),
position: "bottom-left",
actions: [
{ icon: BookmarkIcon(), label: "Bookmark", onClick: () => {} },
{ icon: ShareIcon(), label: "Share", onClick: () => {} },
{ icon: PrintIcon(), label: "Print", onClick: () => {} },
{ icon: DeleteIcon(), label: "Remove", onClick: () => {} },
],
})}
`;
renderApp(App, document.getElementById('app'));
Disabled actions
import { html, renderApp } from 'mates';
import { SpeedDial } from 'mates-ui';
import { DownloadIcon, EditIcon, MailIcon } from 'mates-icons';
const App = () => () => html`
${SpeedDial({
label: "Actions",
position: "bottom-center",
actions: [
{ icon: EditIcon(), label: "Edit", onClick: () => {} },
{ icon: MailIcon(), label: "Email (disabled)", onClick: () => {}, disabled: true },
{ icon: DownloadIcon(), label: "Download", onClick: () => {} },
],
})}
`;
renderApp(App, document.getElementById('app'));