Skip to content

Commit

Permalink
[sparkle] - refactor: adjust Button component props and usage
Browse files Browse the repository at this point in the history
 - Removed 'size' prop from MetaButtonProps interface, aligning it with buttonVariants
 - Updated ButtonProps to inherit changes from MetaButtonProps, dropping 'size'
 - Replaced MiniButton with Button component and added 'size' prop inline in NavigationList
 - Modified SplitButton to default 'size' prop to undefined if not provided
  • Loading branch information
JulesBelveze committed Dec 5, 2024
1 parent 333b084 commit 53833e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions sparkle/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ const spinnerVariantsMapIsLoading: Record<ButtonVariantType, SpinnerVariant> = {

export interface MetaButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
Omit<VariantProps<typeof buttonVariants>, "size"> {
VariantProps<typeof buttonVariants> {
asChild?: boolean;
variant?: ButtonVariantType | null;
size?: ButtonSizeType;
}

const MetaButton = React.forwardRef<HTMLButtonElement, MetaButtonProps>(
Expand All @@ -106,7 +105,7 @@ const MetaButton = React.forwardRef<HTMLButtonElement, MetaButtonProps>(
MetaButton.displayName = "MetaButton";

export interface ButtonProps
extends Omit<MetaButtonProps, "children" | "size">,
extends Omit<MetaButtonProps, "children">,
Omit<LinkWrapperProps, "children" | "className"> {
label?: string;
icon?: React.ComponentType;
Expand Down
4 changes: 2 additions & 2 deletions sparkle/src/components/NavigationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";

import { Icon, LinkWrapper, LinkWrapperProps } from "@sparkle/components/";
import { MiniButton } from "@sparkle/components/Button";
import { Button } from "@sparkle/components/Button";
import { MoreIcon } from "@sparkle/icons";
import { cn } from "@sparkle/lib/utils";

Expand Down Expand Up @@ -149,7 +149,7 @@ const NavigationListItemAction = React.forwardRef<
)}
{...props}
>
<MiniButton icon={MoreIcon} variant={"ghost"} />
<Button size="mini" icon={MoreIcon} variant="ghost" />
</div>
);
});
Expand Down
7 changes: 3 additions & 4 deletions sparkle/src/components/SplitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface SplitButtonActionProps {
}

export interface SplitButtonProps
extends Omit<MetaButtonProps, "children" | "onClick" | "size"> {
extends Omit<MetaButtonProps, "children" | "onClick"> {
/**
* List of possible actions, will be displayed in dropdown
*/
Expand All @@ -61,7 +61,6 @@ export interface SplitButtonProps
* Event handler for action change
*/
onActionChange?: (action: SplitButtonActionProps) => void;
size: ButtonSizeType;
}

const SplitButton = React.forwardRef<HTMLButtonElement, SplitButtonProps>(
Expand Down Expand Up @@ -94,7 +93,7 @@ const SplitButton = React.forwardRef<HTMLButtonElement, SplitButtonProps>(
<div className="s-flex s-items-center">
<Button
{...props}
size={size}
size={size || undefined}
variant={variant}
label={actionToUse.label}
icon={actionToUse.icon}
Expand All @@ -110,7 +109,7 @@ const SplitButton = React.forwardRef<HTMLButtonElement, SplitButtonProps>(
<DropdownMenuTrigger asChild>
<Button
{...props}
size={size}
size={size || undefined}
variant={variant}
icon={ChevronDownIcon}
disabled={disabled}
Expand Down

0 comments on commit 53833e9

Please sign in to comment.