Skip to content

Commit

Permalink
Fix ActionButton colors via theme (orcasound#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanjscallan authored Mar 12, 2022
1 parent eef5bfe commit bd31b13
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/ActionButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Button from '@mui/material/Button'
// ActionButton receives `link` and `text` as props.
// `text` receives the text you want to place inside of the button.
// `link` determines the href that the user is directed to after clicking the button.
// 'accent1' is a custom variable declared in theme.ts through a custom value and module delcaration.
const ActionButton = ({ link, text }) => {
return (
<div>
Expand All @@ -11,12 +12,12 @@ const ActionButton = ({ link, text }) => {
variant="contained"
sx={(theme) => ({
margin: '1rem',
color: theme.palette.text.primary,
bgcolor: theme.palette.primary.main,
bgcolor: 'accents.accent1',
color: 'accents.contrastText',
width: '12rem',
borderRadius: 40,
':hover': {
color: theme.palette.text.primary,
bgcolor: 'accents.accent1',
},
})}
size="small"
Expand All @@ -26,5 +27,4 @@ const ActionButton = ({ link, text }) => {
</div>
)
}

export default ActionButton
13 changes: 13 additions & 0 deletions src/styles/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { red } from '@mui/material/colors'
import { createTheme } from '@mui/material/styles'

//Augmentation allows for custom color additions to theme (TypeScript specific)
declare module '@mui/material/styles' {
interface Palette {
accent1: Palette['primary']
}
interface PaletteOptions {
accent1: PaletteOptions['primary']
}
}

// Create a theme instance.
const theme = createTheme({
palette: {
Expand All @@ -13,6 +23,9 @@ const theme = createTheme({
error: {
main: red.A400,
},
accent1: {
main: '#007bff',
},
},
typography: {
fontFamily: 'Montserrat',
Expand Down

0 comments on commit bd31b13

Please sign in to comment.