fix: remove loadingText prop

This commit is contained in:
Lucas Smith
2023-12-22 01:46:41 +00:00
parent 075fdd1f88
commit 1aa0fc3101
8 changed files with 19 additions and 25 deletions

View File

@ -1,7 +1,8 @@
import * as React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { VariantProps, cva } from 'class-variance-authority';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import { Loader } from 'lucide-react';
import { cn } from '../lib/utils';
@ -53,15 +54,10 @@ export interface ButtonProps
* Will display the loading spinner and disable the button.
*/
loading?: boolean;
/**
* The label to show in the button when `isLoading` is true
*/
loadingText?: string;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, loadingText, loading, ...props }, ref) => {
({ className, variant, size, asChild = false, loading, ...props }, ref) => {
if (asChild) {
return (
<Slot className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
@ -79,7 +75,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
disabled={isDisabled}
>
{isLoading && <Loader className={cn('mr-2 animate-spin', loaderVariants({ size }))} />}
{isLoading && loadingText ? loadingText : props.children}
{props.children}
</button>
);
},