Skip to content

Commit

Permalink
Fix expandable box button being wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
oBusk committed Oct 17, 2023
1 parent a4ca8d6 commit d4e3db3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Slot } from "@radix-ui/react-slot";
import { Loader2 } from "lucide-react";
import { ButtonHTMLAttributes, forwardRef } from "react";
import { cva, VariantProps } from "^/lib/cva";
import Contents from "./Contents";

export const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
Expand Down Expand Up @@ -87,9 +88,9 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
<Loader2 className="animate-spin" />
</div>
) : null}
<span className={spinner ? "invisible" : undefined}>
<Contents className={spinner ? "invisible" : undefined}>
{children}
</span>
</Contents>
</Comp>
);
},
Expand Down
13 changes: 13 additions & 0 deletions src/components/ui/Contents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { forwardRef, HTMLAttributes } from "react";
import { cx } from "^/lib/cva";

export interface ContentsProps extends HTMLAttributes<HTMLSpanElement> {}

const Contents = forwardRef<HTMLSpanElement, ContentsProps>(
({ className, ...props }, ref) => (
<span className={cx("contents", className)} ref={ref} {...props} />
),
);
Contents.displayName = "Contents";

export default Contents;

0 comments on commit d4e3db3

Please sign in to comment.