Skip to content

Commit

Permalink
fix(slash): passing className property to Button remove af-btn defaul…
Browse files Browse the repository at this point in the history
…tClassName
  • Loading branch information
MartinWeb committed Dec 26, 2024
1 parent d578a81 commit 0b2a159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions slash/react/src/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type StoryProps = Omit<
> & {
children: string;
classModifier: string[];
className: string;
};
type Story = StoryObj<StoryProps>;

Expand All @@ -43,6 +44,7 @@ export const Playground: Story = {
args: {
children: "Button",
classModifier: [] as string[],
className: "",
},
argTypes: {
classModifier: {
Expand Down
17 changes: 7 additions & 10 deletions slash/react/src/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@axa-fr/design-system-slash-css/dist/Button/Button.scss";
import classNames from "classnames";

import { ComponentPropsWithoutRef, PropsWithChildren } from "react";
import { getComponentClassName } from "../utilities";

type ButtonProps = {
classModifier?: string;
Expand All @@ -13,17 +13,14 @@ export const Button = ({
className,
...args
}: PropsWithChildren<ButtonProps>) => {
const classes = classModifier
?.split(" ")
.map((modifier) => `af-btn--${modifier}`)
.join(" ");
const componentClassName = getComponentClassName(
className,
classModifier,
"af-btn",
);

return (
<button
className={classNames("af-btn", classes, className)}
type="button"
{...args}
>
<button className={componentClassName} type="button" {...args}>
{children}
</button>
);
Expand Down

0 comments on commit 0b2a159

Please sign in to comment.