-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from AlecsMissangu/updated-data-catalog-compon…
…ents fix(Button): updates to button styles
- Loading branch information
Showing
11 changed files
with
148 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
import MUIButton, { ButtonProps as MUIButtonProps } from "@mui/material/Button"; | ||
import MUIBox from "@mui/material/Box"; | ||
import useTheme from "@mui/material/styles/useTheme"; | ||
|
||
type LinkButtonProps = Omit<MUIButtonProps, "variant" | "color">; | ||
|
||
const LinkButton: React.FC<LinkButtonProps> = (buttonProps) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<MUIBox sx={{ width: "fit-content" }}> | ||
<MUIButton | ||
variant="text" | ||
color="primary" | ||
{...buttonProps} | ||
disableRipple | ||
sx={{ | ||
minWidth: "fit-content", | ||
padding: 0, | ||
":hover": { backgroundColor: "transparent" }, | ||
":not(.Mui-disabled):hover + .ButtonLinkLine": { opacity: 1, width: "100%" }, | ||
}} | ||
> | ||
{buttonProps.children} | ||
</MUIButton> | ||
<MUIBox | ||
className="ButtonLinkLine" | ||
borderTop={1.5} | ||
borderColor={theme.palette.primary.main} | ||
sx={{ | ||
opacity: 0, | ||
width: 0, | ||
marginLeft: "auto", | ||
marginRight: "auto", | ||
transitionDuration: "400ms", | ||
transitionProperty: "width, opacity", | ||
transitionTimingFunction: "cubic-bezier(0.39, 0.58, 0.57, 1)", | ||
}} | ||
/> | ||
</MUIBox> | ||
); | ||
}; | ||
|
||
export default LinkButton; |
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,12 +1,21 @@ | ||
import React from "react"; | ||
import { Button, ButtonProps } from "@mui/material"; | ||
import MUIButton, { ButtonProps as MUIButtonProps } from "@mui/material/Button"; | ||
|
||
type SecondaryButtonProps = Omit<ButtonProps, "variant" | "color">; | ||
type SecondaryButtonProps = Omit<MUIButtonProps, "variant" | "color">; | ||
|
||
const SecondaryButton: React.FC<SecondaryButtonProps> = (buttonProps) => ( | ||
<Button variant="outlined" color="primary" {...buttonProps}> | ||
{buttonProps.children} | ||
</Button> | ||
); | ||
const SecondaryButton: React.FC<SecondaryButtonProps> = (buttonProps) => { | ||
if (buttonProps.disableElevation) { | ||
return ( | ||
<MUIButton variant="outlined" color="primary" {...buttonProps}> | ||
{buttonProps.children} | ||
</MUIButton> | ||
); | ||
} | ||
return ( | ||
<MUIButton variant="outlined" color="inherit" {...buttonProps}> | ||
{buttonProps.children} | ||
</MUIButton> | ||
); | ||
}; | ||
|
||
export default SecondaryButton; |
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
58 changes: 34 additions & 24 deletions
58
src/v1/theme/style-overrides/component-overrides/button-overrides.ts
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,33 +1,43 @@ | ||
import { ThemeOptions } from "@mui/material"; | ||
import THEME_COLORS, { UITheme } from "../../colors/theme-colors"; | ||
|
||
const BUTTON_OVERRIDES: ThemeOptions["components"] = { | ||
MuiButton: { | ||
styleOverrides: { | ||
root: ({ theme }) => ({ | ||
paddingInline: theme.spacing(2), | ||
}), | ||
outlinedPrimary: ({ theme }) => ({ | ||
border: `1px solid ${theme.palette.primary.main}`, | ||
}), | ||
startIcon: { | ||
">*:nth-last-of-type(1)": { | ||
fontSize: "inherit", | ||
const generateButtonOverrides = (uiTheme: UITheme) => | ||
({ | ||
MuiButton: { | ||
styleOverrides: { | ||
root: ({ theme }) => ({ | ||
paddingInline: theme.spacing(2), | ||
}), | ||
outlinedInherit: ({ theme }) => ({ | ||
border: `1px solid #CFD8DC`, | ||
boxShadow: theme.shadows[2], | ||
}), | ||
outlinedPrimary: ({ theme }) => ({ | ||
border: `1px solid ${theme.palette.primary.main}`, | ||
backgroundColor: theme.palette.secondary.main, | ||
":hover": { | ||
backgroundColor: `${THEME_COLORS[uiTheme][100]}`, | ||
}, | ||
}), | ||
startIcon: { | ||
">*:nth-last-of-type(1)": { | ||
fontSize: "inherit", | ||
}, | ||
}, | ||
}, | ||
endIcon: { | ||
">*:nth-last-of-type(1)": { | ||
fontSize: "inherit", | ||
endIcon: { | ||
">*:nth-last-of-type(1)": { | ||
fontSize: "inherit", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
MuiIconButton: { | ||
styleOverrides: { | ||
root: { | ||
borderRadius: 4, | ||
MuiIconButton: { | ||
styleOverrides: { | ||
root: { | ||
borderRadius: 4, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
} satisfies ThemeOptions["components"]); | ||
|
||
export default BUTTON_OVERRIDES; | ||
export default generateButtonOverrides; |
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,3 @@ | ||
export { default as AVATAR_OVERRIDES } from "./avatar-overrides"; | ||
export { default as BUTTON_OVERRIDES } from "./button-overrides"; | ||
export { default as generateButtonOverrides } from "./button-overrides"; | ||
export { default as CARD_OVERRIDES } from "./card-overrides"; |
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,17 +1,19 @@ | ||
import { ThemeOptions } from "@mui/material"; | ||
import * as componentOverrides from "./component-overrides"; | ||
import { UITheme } from "../colors/theme-colors"; | ||
|
||
const COMPONENTS_STYLE_OVERRIDES = { | ||
...componentOverrides.AVATAR_OVERRIDES, | ||
...componentOverrides.BUTTON_OVERRIDES, | ||
...componentOverrides.CARD_OVERRIDES, | ||
MuiAppBar: { | ||
styleOverrides: { | ||
root: { | ||
height: 70, | ||
const generateComponentOverrides = (uiTheme: UITheme) => | ||
({ | ||
...componentOverrides.AVATAR_OVERRIDES, | ||
...componentOverrides.generateButtonOverrides(uiTheme), | ||
...componentOverrides.CARD_OVERRIDES, | ||
MuiAppBar: { | ||
styleOverrides: { | ||
root: { | ||
height: 70, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} satisfies ThemeOptions["components"]; | ||
} satisfies ThemeOptions["components"]); | ||
|
||
export default COMPONENTS_STYLE_OVERRIDES; | ||
export default generateComponentOverrides; |
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