-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom): create round button, extend theme with custom property (#9
- Loading branch information
Showing
6 changed files
with
101 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { FC } from "react"; | ||
import { Button as Btn, ButtonProps, makeStyles, useTheme } from "@material-ui/core"; | ||
import clsx from "clsx"; | ||
|
||
export const Button: FC<{ rounded?: boolean } & ButtonProps> = ({ | ||
children, | ||
className, | ||
rounded = false, | ||
...rest | ||
}) => { | ||
const { custom } = useTheme(); | ||
const useStyles = makeStyles({ | ||
rounded: { | ||
// using a high value for large buttons, for most cases a 28px should be enough | ||
borderRadius: "250px", | ||
}, | ||
}); | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Btn {...rest} className={clsx(className, { [classes.rounded]: rounded || custom?.button?.rounded })}> | ||
{children} | ||
</Btn> | ||
); | ||
}; |
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 @@ | ||
export { Button } from "./Button"; |
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,25 @@ | ||
import React, { FC } from "react"; | ||
import { ButtonBase as Btn, ButtonBaseProps, makeStyles, useTheme } from "@material-ui/core"; | ||
import clsx from "clsx"; | ||
|
||
export const ButtonBase: FC<{ rounded?: boolean } & ButtonBaseProps> = ({ | ||
children, | ||
className, | ||
rounded = false, | ||
...rest | ||
}) => { | ||
const { custom } = useTheme(); | ||
const useStyles = makeStyles({ | ||
rounded: { | ||
// using a high value for large buttons, for most cases a 28px should be enough | ||
borderRadius: "250px", | ||
}, | ||
}); | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Btn {...rest} className={clsx(className, { [classes.rounded]: rounded || custom?.button?.rounded })}> | ||
{children} | ||
</Btn> | ||
); | ||
}; |
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 @@ | ||
export { ButtonBase } from "./ButtonBase"; |
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