Skip to content

chore(site): Upgrade to MUI v5 #7437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73c3c17
Initial changes
BrunoQuaresma May 5, 2023
047c10b
Apply codemod
BrunoQuaresma May 5, 2023
0b26a9b
Apply variant mod
BrunoQuaresma May 5, 2023
d0b064a
Migrate theme options
BrunoQuaresma May 5, 2023
9a5203d
Merge branch 'main' into bq/migrate-to-muiv5
BrunoQuaresma May 8, 2023
1f078ce
Fix all TS problems
BrunoQuaresma May 8, 2023
fc683c8
Merge branch 'main' into bq/migrate-to-muiv5
BrunoQuaresma May 8, 2023
77777fb
Remove unusable test
BrunoQuaresma May 8, 2023
479ce07
Button and input text
BrunoQuaresma May 8, 2023
9dfec8f
Set typography
BrunoQuaresma May 8, 2023
50e9f22
Remove default outlined
BrunoQuaresma May 8, 2023
34d9d8d
Improve theme
BrunoQuaresma May 8, 2023
9a62dcc
Setup links
BrunoQuaresma May 8, 2023
756277e
Fix link
BrunoQuaresma May 8, 2023
5c45cf6
Fix button outlined neutral
BrunoQuaresma May 8, 2023
5ae26fa
Fix
BrunoQuaresma May 8, 2023
a1cbc12
Update workspace header
BrunoQuaresma May 8, 2023
55c0751
Merge branch 'main' into bq/migrate-to-muiv5
BrunoQuaresma May 9, 2023
168814c
Fix format
BrunoQuaresma May 9, 2023
a591559
Adjust buttons
BrunoQuaresma May 9, 2023
a4bba50
Fix table loaders
BrunoQuaresma May 9, 2023
a24edee
Few tweaks on deployment settings
BrunoQuaresma May 9, 2023
4abb23d
Fix typo
BrunoQuaresma May 9, 2023
a0bbf8f
Fix filter size
BrunoQuaresma May 9, 2023
029e658
Fix skeleton path
BrunoQuaresma May 9, 2023
367c445
Fix storybook
BrunoQuaresma May 9, 2023
9682b7b
Many storybook fixes
BrunoQuaresma May 9, 2023
82d2e53
Fix table min
BrunoQuaresma May 9, 2023
a38eb9a
Fix colors and input sizes
BrunoQuaresma May 9, 2023
9a0e553
Previous design issue
BrunoQuaresma May 9, 2023
1145725
Better workspace build state error
BrunoQuaresma May 9, 2023
7251da2
Fix type
BrunoQuaresma May 9, 2023
a3a807a
Merge branch 'main' into bq/migrate-to-muiv5
BrunoQuaresma May 10, 2023
e18c0c1
Apply Kira PR comments
BrunoQuaresma May 10, 2023
47ab467
Fix fmt
BrunoQuaresma May 10, 2023
6bb6f5b
Fix
BrunoQuaresma May 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Button and input text
  • Loading branch information
BrunoQuaresma committed May 8, 2023
commit 479ce0771278ce407752cb7fc88632dac25476cd
20 changes: 17 additions & 3 deletions site/mui.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { Theme } from "@mui/material/styles"
import { PaletteColor, PaletteColorOptions, Theme } from "@mui/material/styles"

declare module "@mui/styles/defaultTheme" {
interface DefaultTheme extends Theme {}
}

declare module "@mui/material/styles" {
interface TypeBackground {
paperLight: string
}

interface Palette {
neutral: PaletteColor
}

interface PaletteOptions {
neutral?: PaletteColorOptions
}
}

declare module "@mui/styles/defaultTheme" {
interface DefaultTheme extends Theme {}
declare module "@mui/material/Button" {
interface ButtonPropsColorOverrides {
neutral: true
}
}
2 changes: 2 additions & 0 deletions site/src/components/SignInForm/OAuthSignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const OAuthSignInForm: FC<OAuthSignInFormProps> = ({
fullWidth
type="submit"
variant="outlined"
size="large"
>
{Language.githubSignIn}
</Button>
Expand All @@ -57,6 +58,7 @@ export const OAuthSignInForm: FC<OAuthSignInFormProps> = ({
)}`}
>
<Button
size="large"
startIcon={
authMethods.oidc.iconUrl ? (
<img
Expand Down
3 changes: 2 additions & 1 deletion site/src/components/SignInForm/PasswordSignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const PasswordSignInForm: FC<PasswordSignInFormProps> = ({

return (
<form onSubmit={form.handleSubmit}>
<Stack>
<Stack spacing={2.5}>
<TextField
{...getFieldHelpers("email")}
onChange={onChangeTrimmed(form)}
Expand All @@ -63,6 +63,7 @@ export const PasswordSignInForm: FC<PasswordSignInFormProps> = ({
/>
<div>
<LoadingButton
size="large"
loading={isSigningIn}
fullWidth
type="submit"
Expand Down
1 change: 1 addition & 0 deletions site/src/components/SignInForm/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({

<Button
fullWidth
size="large"
onClick={() => setShowPasswordAuth(true)}
variant="outlined"
startIcon={<EmailIcon className={styles.icon} />}
Expand Down
181 changes: 58 additions & 123 deletions site/src/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { colors } from "./colors"
import { ThemeOptions, createTheme, Theme } from "@mui/material/styles"
import { BODY_FONT_FAMILY, borderRadius, borderRadiusSm } from "./constants"
import { BODY_FONT_FAMILY, borderRadius } from "./constants"

// MUI does not have aligned heights for buttons and inputs so we have to "hack" it a little bit
const INPUT_HEIGHT = 46
const BUTTON_LG_HEIGHT = 46

export type PaletteIndex = keyof Theme["palette"]
export type PaletteStatusIndex = Extract<
Expand Down Expand Up @@ -55,6 +59,9 @@ export let dark = createTheme({
action: {
hover: colors.gray[14],
},
neutral: {
main: colors.gray[1],
},
},
typography: {
fontFamily: BODY_FONT_FAMILY,
Expand Down Expand Up @@ -125,23 +132,22 @@ export let dark = createTheme({
letterSpacing: 1.5,
},
},
shape: {
borderRadius,
},
})

dark = createTheme(dark, {
components: {
MuiCssBaseline: {
styleOverrides: {
"@global": {
body: {
backgroundImage: `linear-gradient(to right bottom, ${dark.palette.background.default}, ${colors.gray[17]})`,
backgroundRepeat: "no-repeat",
backgroundAttachment: "fixed",
},
":root": {
colorScheme: dark.palette.mode,
},
},
},
styleOverrides: `
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0 100px ${dark.palette.background.default} inset !important;
}
`,
},
MuiAvatar: {
styleOverrides: {
Expand All @@ -166,78 +172,23 @@ dark = createTheme(dark, {
},
MuiButton: {
defaultProps: {
variant: "contained",
variant: "outlined",
color: "neutral",
},
styleOverrides: {
root: {
// Prevents a loading button from collapsing!
minHeight: 40,
height: 40, // Same size of input height
fontWeight: "normal",
fontSize: 16,
textTransform: "none",
letterSpacing: "none",
border: `1px solid ${dark.palette.divider}`,
whiteSpace: "nowrap",

"&:focus-visible": {
outline: `2px solid ${dark.palette.primary.dark}`,
},
},
root: ({ ownerState }) => {
let height: number | undefined = undefined

contained: {
boxShadow: "none",
color: dark.palette.text.primary,
backgroundColor: colors.gray[13],
borderColor: colors.gray[12],
if (ownerState.size === "large") {
height = BUTTON_LG_HEIGHT
}

"&:hover:not(:disabled):not(.MuiButton-containedPrimary):not(.MuiButton-containedSecondary)":
{
boxShadow: "none",
backgroundColor: colors.gray[12],
borderColor: colors.gray[11],
},

"&.Mui-disabled:not(.MuiButton-containedPrimary):not(.MuiButton-containedSecondary)":
{
color: colors.gray[9],
backgroundColor: colors.gray[14],
cursor: "not-allowed",
pointerEvents: "auto",
},
},
sizeSmall: {
padding: `0 16px`,
fontSize: 14,
minHeight: 36,
height: 36,
borderRadius: borderRadiusSm,
},
iconSizeSmall: {
width: 14,
height: 14,
marginLeft: "0 !important",
marginRight: 8,

"& svg:not(.MuiCircularProgress-svg)": {
width: 14,
height: 14,
},
},
outlined: {
border: `1px solid ${colors.gray[11]}`,

"&:hover:not(:disabled)": {
borderColor: colors.gray[1],
background: "none",
},

"&.Mui-disabled": {
color: colors.gray[9],
border: `1px solid ${colors.gray[12]}`,
pointerEvents: "auto",
cursor: "not-allowed",
},
return {
height,
textTransform: "none",
letterSpacing: "normal",
fontWeight: 500,
}
},
},
},
Expand Down Expand Up @@ -310,30 +261,6 @@ dark = createTheme(dark, {
},
},
},
MuiInputBase: {
styleOverrides: {
root: {
borderRadius,
},
},
},
MuiOutlinedInput: {
styleOverrides: {
root: {
"& .MuiOutlinedInput-notchedOutline": {
borderColor: dark.palette.divider,
},

"& input:-webkit-autofill": {
WebkitBoxShadow: `0 0 0 1000px ${dark.palette.background.paper} inset`,
},

"&:hover:not(.Mui-focused) .MuiOutlinedInput-notchedOutline": {
borderColor: dark.palette.divider,
},
},
},
},
MuiLink: {
styleOverrides: {
root: {
Expand All @@ -352,18 +279,6 @@ dark = createTheme(dark, {
},
},
},
MuiFormHelperText: {
styleOverrides: {
contained: {
marginLeft: 0,
marginRight: 0,
},

marginDense: {
marginTop: 8,
},
},
},
MuiSkeleton: {
styleOverrides: {
root: {
Expand Down Expand Up @@ -434,15 +349,35 @@ dark = createTheme(dark, {
},
MuiTextField: {
defaultProps: {
margin: "dense",
variant: "outlined",
spellCheck: false,
InputLabelProps: {
shrink: true,
},
},
},
MuiFormControl: {
MuiInputBase: {
defaultProps: {
variant: "outlined",
margin: "dense",
color: "primary",
},
styleOverrides: {
root: ({ ownerState }) => {
let height: number | undefined = undefined

if (ownerState.size === "medium") {
height = INPUT_HEIGHT
}

return {
height,
}
},
},
},
MuiFormHelperText: {
defaultProps: {
sx: {
marginLeft: 0,
marginTop: 1,
},
},
},
MuiList: {
Expand Down