-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Don't export the legacy getButtonClasses function * Deleted legacy Button component; add ref forwarding support to new button
- Loading branch information
Showing
10 changed files
with
47 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import { ButtonHTMLAttributes } from "react"; | ||
import { ButtonHTMLAttributes, ForwardedRef, forwardRef } from "react"; | ||
|
||
import styles from "./Button.module.css"; | ||
|
||
export function Button({ | ||
className = "", | ||
color = "primary", | ||
size = "normal", | ||
variant = "solid", | ||
...rest | ||
}: ButtonHTMLAttributes<HTMLButtonElement> & { | ||
color?: "primary" | "secondary"; | ||
size?: "normal" | "large" | "small"; | ||
variant?: "outline" | "solid"; | ||
}) { | ||
export const Button = forwardRef(function Button( | ||
{ | ||
className = "", | ||
color = "primary", | ||
size = "normal", | ||
variant = "solid", | ||
...rest | ||
}: ButtonHTMLAttributes<HTMLButtonElement> & { | ||
color?: "primary" | "secondary"; | ||
size?: "normal" | "large" | "small"; | ||
variant?: "outline" | "solid"; | ||
}, | ||
ref: ForwardedRef<HTMLButtonElement> | ||
) { | ||
return ( | ||
<button | ||
className={`${className} ${styles.Button}`} | ||
data-color={color} | ||
data-size={size} | ||
data-variant={variant} | ||
ref={ref} | ||
{...rest} | ||
/> | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.