generated from timelessco/react-components-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(button): ♻️ update button related components (#41)
- Loading branch information
1 parent
60143f2
commit 7e39af2
Showing
11 changed files
with
93 additions
and
100 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
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,28 @@ | ||
import * as React from "react"; | ||
import { Box, BoxProps } from "reakit"; | ||
|
||
import { forwardRefWithAs } from "../utils/types"; | ||
|
||
export type ButtonIconProps = BoxProps; | ||
|
||
export const ButtonIcon = forwardRefWithAs< | ||
ButtonIconProps, | ||
HTMLSpanElement, | ||
"span" | ||
>((props, ref) => { | ||
const { children, ...rest } = props; | ||
|
||
const _children = React.isValidElement(children) | ||
? React.cloneElement(children, { | ||
"aria-hidden": true, | ||
focusable: false, | ||
role: "img", | ||
}) | ||
: children; | ||
|
||
return ( | ||
<Box as="span" ref={ref} {...rest}> | ||
{_children} | ||
</Box> | ||
); | ||
}); |
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,19 @@ | ||
import { CloseIcon } from "../icons"; | ||
import { forwardRefWithAs } from "../utils/types"; | ||
import { IconButton, IconButtonProps } from "./IconButton"; | ||
|
||
export type CloseButtonProps = IconButtonProps; | ||
|
||
export const CloseButton = forwardRefWithAs< | ||
CloseButtonProps, | ||
HTMLButtonElement, | ||
"button" | ||
>((props, ref) => { | ||
const { children, ...rest } = props; | ||
|
||
return ( | ||
<IconButton aria-label="Close" ref={ref} {...rest}> | ||
{children || <CloseIcon />} | ||
</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
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,3 +1,5 @@ | ||
export * from "./Button"; | ||
export * from "./IconButton"; | ||
export * from "./ButtonGroup"; | ||
export * from "./ButtonIcon"; | ||
export * from "./CloseButton"; | ||
export * from "./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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const buttonGroup = { | ||
base: "lib:inline-block lib:shadow-sm lib:rounded-lg", | ||
base: "lib:inline-block lib:shadow-sm lib:rounded-lg ", | ||
attached: "lib:collapse-border", | ||
}; |
7e39af2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: