-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tech: Add IconButton component (#4706)
<!-- PR title: tech/ Add IconButton component --> ## Describe your changes Small wrapper around the `Button` component for icon only buttons similar to the one we have in Hope. <!-- What changes are made? If there are many changes, a list might be a good format. If it makes sense, add screenshots and/or screen recordings here. --> ## Justify why they are needed Reuse styles needed for icon buttons. ## Checklist before requesting a review - [x] I have performed a self-review of my code
- Loading branch information
Showing
5 changed files
with
48 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import clsx from 'clsx' | ||
import { type ComponentProps, forwardRef } from 'react' | ||
import { Button } from './Button' | ||
import { iconButtonStyles } from './Button.css' | ||
|
||
type ButtonProps = ComponentProps<typeof Button<'button'>> | ||
|
||
export const IconButton = forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, children, ...props }, forwardedRef) => ( | ||
<Button | ||
className={clsx(iconButtonStyles, className)} | ||
variant="ghost" | ||
size="icon" | ||
Icon={children} | ||
{...props} | ||
ref={forwardedRef} | ||
/> | ||
), | ||
) | ||
|
||
IconButton.displayName = 'IconButton' |
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