Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

💄 Replace icon with spinner on loading icon buttons (#2810)

Luke Vella0a514a523ed8
diff --git a/apps/web/src/features/poll/components/notification-toggle.tsx b/apps/web/src/features/poll/components/notification-toggle.tsx
index 7aa16c2e8..d8f1ecd28 100644
--- a/apps/web/src/features/poll/components/notification-toggle.tsx
+++ b/apps/web/src/features/poll/components/notification-toggle.tsx
@@ -66,6 +66,7 @@ export function NotificationToggle() {
render={
<Button
variant="ghost"
+ size="icon"
aria-pressed={poll.muted}
aria-label={
poll.muted
diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsx
index 198193ad5..3fc044555 100644
--- a/packages/ui/src/button.tsx
+++ b/packages/ui/src/button.tsx
@@ -24,6 +24,7 @@ const Button = ({
...props
}: ButtonPrimitive.Props &
VariantProps<typeof buttonVariants> & { loading?: boolean }) => {
+ const isIconButton = size?.startsWith("icon");
return (
<ButtonPrimitive
className={cn(
@@ -31,6 +32,7 @@ const Button = ({
buttonVariants({ variant, size }),
{
"pointer-events-none": loading,
+ "[&_svg:not([data-slot=spinner])]:hidden": loading && isIconButton,
},
className,
)}
@@ -38,7 +40,8 @@ const Button = ({
>
{loading ? (
<Loader2Icon
- data-icon="inline-start"
+ data-slot="spinner"
+ data-icon={isIconButton ? undefined : "inline-start"}
className="size-4 animate-spin opacity-75"
/>
) : null}