Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore(site): fix material ui warning #4161

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 14 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@emoji-mart/react": "^1.0.1",
"@fontsource/ibm-plex-mono": "4.5.10",
"@fontsource/inter": "4.5.11",
"@material-ui/core": "4.9.4",
"@material-ui/core": "4.12.1",
"@material-ui/icons": "4.5.1",
"@material-ui/lab": "4.0.0-alpha.42",
"@testing-library/react-hooks": "8.0.1",
Expand Down
6 changes: 3 additions & 3 deletions site/src/components/Dialogs/ConfirmDialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DialogActions from "@material-ui/core/DialogActions"
import { fade, makeStyles } from "@material-ui/core/styles"
import { alpha, makeStyles } from "@material-ui/core/styles"
import Typography from "@material-ui/core/Typography"
import React, { ReactNode } from "react"
import { Dialog, DialogActionButtons, DialogActionButtonsProps } from "../Dialog"
Expand Down Expand Up @@ -65,11 +65,11 @@ const useStyles = makeStyles((theme) => ({
marginBottom: theme.spacing(3),
},
description: {
color: fade(theme.palette.text.secondary, 0.75),
color: alpha(theme.palette.text.secondary, 0.75),
lineHeight: "160%",

"& strong": {
color: fade(theme.palette.text.secondary, 0.95),
color: alpha(theme.palette.text.secondary, 0.95),
},
},
}))
Expand Down
36 changes: 18 additions & 18 deletions site/src/components/Dialogs/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MuiDialog, { DialogProps as MuiDialogProps } from "@material-ui/core/Dialog"
import MuiDialogTitle from "@material-ui/core/DialogTitle"
import { darken, fade, lighten, makeStyles } from "@material-ui/core/styles"
import { alpha, darken, lighten, makeStyles } from "@material-ui/core/styles"
import SvgIcon from "@material-ui/core/SvgIcon"
import * as React from "react"
import { combineClasses } from "../../util/combineClasses"
Expand Down Expand Up @@ -57,7 +57,7 @@ const useTitleStyles = makeStyles(
icon: {
height: 84,
width: 84,
color: fade(theme.palette.action.disabled, 0.4),
color: alpha(theme.palette.action.disabled, 0.4),
},
}),
{ name: "CdrDialogTitle" },
Expand Down Expand Up @@ -155,27 +155,27 @@ const useButtonStyles = makeStyles((theme) => ({
boxShadow: "none",
},
cancelButton: {
background: fade(theme.palette.primary.main, 0.1),
background: alpha(theme.palette.primary.main, 0.1),
color: theme.palette.primary.main,

"&:hover": {
background: fade(theme.palette.primary.main, 0.3),
background: alpha(theme.palette.primary.main, 0.3),
},
},
confirmDialogCancelButton: (props: StyleProps) => {
const color =
props.type === "info" ? theme.palette.primary.contrastText : theme.palette.error.contrastText
return {
background: fade(color, 0.15),
background: alpha(color, 0.15),
color,

"&:hover": {
background: fade(color, 0.3),
background: alpha(color, 0.3),
},

"&.Mui-disabled": {
background: fade(color, 0.15),
color: fade(color, 0.5),
background: alpha(color, 0.15),
color: alpha(color, 0.5),
},
}
},
Expand Down Expand Up @@ -214,15 +214,15 @@ const useButtonStyles = makeStyles((theme) => ({
},
"&.Mui-disabled": {
backgroundColor: theme.palette.action.disabledBackground,
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
},
},

"&.MuiButton-outlined": {
color: theme.palette.error.main,
borderColor: theme.palette.error.main,
"&:hover": {
backgroundColor: fade(theme.palette.error.main, theme.palette.action.hoverOpacity),
backgroundColor: alpha(theme.palette.error.main, theme.palette.action.hoverOpacity),
"@media (hover: none)": {
backgroundColor: "transparent",
},
Expand All @@ -231,21 +231,21 @@ const useButtonStyles = makeStyles((theme) => ({
},
},
"&.Mui-disabled": {
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
borderColor: theme.palette.action.disabled,
},
},

"&.MuiButton-text": {
color: theme.palette.error.main,
"&:hover": {
backgroundColor: fade(theme.palette.error.main, theme.palette.action.hoverOpacity),
backgroundColor: alpha(theme.palette.error.main, theme.palette.action.hoverOpacity),
"@media (hover: none)": {
backgroundColor: "transparent",
},
},
"&.Mui-disabled": {
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
},
},
},
Expand All @@ -264,15 +264,15 @@ const useButtonStyles = makeStyles((theme) => ({
},
"&.Mui-disabled": {
backgroundColor: theme.palette.action.disabledBackground,
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
},
},

"&.MuiButton-outlined": {
color: theme.palette.success.main,
borderColor: theme.palette.success.main,
"&:hover": {
backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity),
backgroundColor: alpha(theme.palette.success.main, theme.palette.action.hoverOpacity),
"@media (hover: none)": {
backgroundColor: "transparent",
},
Expand All @@ -281,21 +281,21 @@ const useButtonStyles = makeStyles((theme) => ({
},
},
"&.Mui-disabled": {
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
borderColor: theme.palette.action.disabled,
},
},

"&.MuiButton-text": {
color: theme.palette.success.main,
"&:hover": {
backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity),
backgroundColor: alpha(theme.palette.success.main, theme.palette.action.hoverOpacity),
"@media (hover: none)": {
backgroundColor: "transparent",
},
},
"&.Mui-disabled": {
color: fade(theme.palette.text.disabled, 0.5),
color: alpha(theme.palette.text.disabled, 0.5),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/Icons/CloseIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SvgIcon from "@material-ui/core/SvgIcon"
import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon"

export const CloseIcon: typeof SvgIcon = (props) => (
export const CloseIcon: typeof SvgIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 31 31">
<path
d="M29.5 1.5l-28 28M29.5 29.5l-28-28"
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/Icons/FileCopyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SvgIcon from "@material-ui/core/SvgIcon"
import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon"

export const FileCopyIcon: typeof SvgIcon = (props) => (
export const FileCopyIcon: typeof SvgIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 20 20">
<path
d="M12.7412 2.2807H4.32014C3.5447 2.2807 2.91663 2.90877 2.91663 3.68421V13.5088H4.32014V3.68421H12.7412V2.2807ZM14.8465 5.08772H7.12716C6.35172 5.08772 5.72365 5.71579 5.72365 6.49123V16.3158C5.72365 17.0912 6.35172 17.7193 7.12716 17.7193H14.8465C15.6219 17.7193 16.25 17.0912 16.25 16.3158V6.49123C16.25 5.71579 15.6219 5.08772 14.8465 5.08772ZM14.8465 16.3158H7.12716V6.49123H14.8465V16.3158Z"
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/Icons/SearchIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SvgIcon from "@material-ui/core/SvgIcon"
import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon"

export const SearchIcon: typeof SvgIcon = (props) => (
export const SearchIcon: typeof SvgIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 16 16">
<path d="M15.707 13.293L13 10.586C13.63 9.536 14 8.311 14 7C14 3.14 10.859 0 7 0C3.141 0 0 3.14 0 7C0 10.86 3.141 14 7 14C8.312 14 9.536 13.631 10.586 13L13.293 15.707C13.488 15.902 13.744 16 14 16C14.256 16 14.512 15.902 14.707 15.707L15.707 14.707C16.098 14.316 16.098 13.684 15.707 13.293ZM7 12C4.239 12 2 9.761 2 7C2 4.239 4.239 2 7 2C9.761 2 12 4.239 12 7C12 9.761 9.761 12 7 12Z" />
</SvgIcon>
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/Icons/UsersOutlinedIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SvgIcon from "@material-ui/core/SvgIcon"
import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon"

export const UsersOutlinedIcon: typeof SvgIcon = (props) => (
export const UsersOutlinedIcon: typeof SvgIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 20 20">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/Icons/WorkspacesIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SvgIcon from "@material-ui/core/SvgIcon"
import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon"

export const WorkspacesIcon: typeof SvgIcon = (props) => (
export const WorkspacesIcon: typeof SvgIcon = (props: SvgIconProps) => (
<SvgIcon {...props} viewBox="0 0 16 16">
<path d="M6 14H2V2H12V5.5L14 7V1C14 0.734784 13.8946 0.48043 13.7071 0.292893C13.5196 0.105357 13.2652 0 13 0L1 0C0.734784 0 0.48043 0.105357 0.292893 0.292893C0.105357 0.48043 0 0.734784 0 1L0 15C0 15.2652 0.105357 15.5196 0.292893 15.7071C0.48043 15.8946 0.734784 16 1 16H6V14Z" />
<path d="M12 8L8 11V16H11V13H13.035V16H16V11L12 8Z" />
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/LoadingButton/LoadingButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Button, { ButtonProps } from "@material-ui/core/Button"
import CircularProgress from "@material-ui/core/CircularProgress"
import { makeStyles } from "@material-ui/core/styles"
import { Theme } from "@material-ui/core/styles/createMuiTheme"
import { Theme } from "@material-ui/core/styles/createTheme"
import { FC } from "react"

export interface LoadingButtonProps extends ButtonProps {
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const PageHeader: React.FC<React.PropsWithChildren<PageHeaderProps>> = ({
actions,
className,
}) => {
const styles = useStyles()
const styles = useStyles({})

return (
<div className={combineClasses([styles.root, className])}>
Expand All @@ -27,7 +27,7 @@ export const PageHeader: React.FC<React.PropsWithChildren<PageHeaderProps>> = ({
}

export const PageHeaderTitle: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const styles = useStyles()
const styles = useStyles({})

return <h1 className={styles.title}>{children}</h1>
}
Expand Down
17 changes: 8 additions & 9 deletions site/src/components/Pill/Pill.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeStyles } from "@material-ui/core/styles"
import { makeStyles, Theme } from "@material-ui/core/styles"
import { FC } from "react"
import { MONOSPACE_FONT_FAMILY } from "theme/constants"
import { PaletteIndex } from "theme/palettes"
Expand All @@ -12,8 +12,9 @@ export interface PillProps {
lightBorder?: boolean
}

export const Pill: FC<PillProps> = ({ className, icon, text, type, lightBorder = false }) => {
const styles = useStyles({ icon, type, lightBorder })
export const Pill: FC<PillProps> = (props) => {
const { className, icon, text = false } = props
const styles = useStyles(props)
return (
<div className={combineClasses([styles.wrapper, styles.pillColor, className])} role="status">
{icon && <div className={styles.iconWrapper}>{icon}</div>}
Expand All @@ -22,7 +23,7 @@ export const Pill: FC<PillProps> = ({ className, icon, text, type, lightBorder =
)
}

const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles<Theme, PillProps>((theme) => ({
wrapper: {
fontFamily: MONOSPACE_FONT_FAMILY,
display: "inline-flex",
Expand All @@ -34,16 +35,14 @@ const useStyles = makeStyles((theme) => ({
fontWeight: 500,
color: "#FFF",
height: theme.spacing(3),
paddingLeft: ({ icon }: { icon?: React.ReactNode }) =>
icon ? theme.spacing(0.75) : theme.spacing(1.5),
paddingLeft: ({ icon }) => (icon ? theme.spacing(0.75) : theme.spacing(1.5)),
paddingRight: theme.spacing(1.5),
whiteSpace: "nowrap",
},

pillColor: {
backgroundColor: ({ type }: { type?: PaletteIndex }) =>
type ? theme.palette[type].dark : theme.palette.text.secondary,
borderColor: ({ type, lightBorder }: { type?: PaletteIndex; lightBorder?: boolean }) =>
backgroundColor: ({ type }) => (type ? theme.palette[type].dark : theme.palette.text.secondary),
borderColor: ({ type, lightBorder }) =>
type
? lightBorder
? theme.palette[type].light
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Menu from "@material-ui/core/Menu"
import MenuItem from "@material-ui/core/MenuItem"
import OutlinedInput from "@material-ui/core/OutlinedInput"
import { makeStyles } from "@material-ui/core/styles"
import { Theme } from "@material-ui/core/styles/createMuiTheme"
import { Theme } from "@material-ui/core/styles/createTheme"
import SearchIcon from "@material-ui/icons/Search"
import debounce from "just-debounce-it"
import { useCallback, useRef, useState } from "react"
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/TabPanel/TabPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeStyles } from "@material-ui/core/styles"
import { fade } from "@material-ui/core/styles/colorManipulator"
import { alpha } from "@material-ui/core/styles/colorManipulator"
import { FC } from "react"
import { TabSidebar, TabSidebarItem } from "../TabSidebar/TabSidebar"

Expand Down Expand Up @@ -53,7 +53,7 @@ const useStyles = makeStyles((theme) => ({
position: "absolute",
left: -50,
top: 31,
color: fade(theme.palette.common.black, 0.1),
color: alpha(theme.palette.common.black, 0.1),
transition: "transform 0.3s ease",
zIndex: -1,
},
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/TableCellData/TableCellData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const TableCellDataPrimary: React.FC<React.PropsWithChildren<{ highlight?
export const TableCellDataSecondary: React.FC<React.PropsWithChildren<unknown>> = ({
children,
}) => {
const styles = useStyles()
const styles = useStyles({})

return <span className={styles.secondary}>{children}</span>
}
Expand Down
10 changes: 5 additions & 5 deletions site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ export const HelpTooltip: React.FC<React.PropsWithChildren<HelpTooltipProps>> =
}

export const HelpTooltipTitle: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const styles = useStyles()
const styles = useStyles({})

return <h4 className={styles.title}>{children}</h4>
}

export const HelpTooltipText: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const styles = useStyles()
const styles = useStyles({})

return <p className={styles.text}>{children}</p>
}
Expand All @@ -112,7 +112,7 @@ export const HelpTooltipLink: React.FC<React.PropsWithChildren<{ href: string }>
children,
href,
}) => {
const styles = useStyles()
const styles = useStyles({})

return (
<Link href={href} target="_blank" rel="noreferrer" className={styles.link}>
Expand All @@ -129,7 +129,7 @@ export const HelpTooltipAction: React.FC<
ariaLabel?: string
}>
> = ({ children, icon: Icon, onClick, ariaLabel }) => {
const styles = useStyles()
const styles = useStyles({})
const tooltip = useHelpTooltip()

return (
Expand All @@ -149,7 +149,7 @@ export const HelpTooltipAction: React.FC<
}

export const HelpTooltipLinksGroup: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const styles = useStyles()
const styles = useStyles({})

return (
<Stack spacing={1} className={styles.linksGroup}>
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/UserDropdown/UsersDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const UserDropdown: React.FC<React.PropsWithChildren<UserDropdownProps>>
data-testid="user-dropdown-trigger"
>
<div className={styles.inner}>
<Badge overlap="circle">
<Badge overlap="circular">
<UserAvatar username={user.username} avatarURL={user.avatar_url} />
</Badge>
{anchorEl ? (
Expand Down
4 changes: 2 additions & 2 deletions site/src/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMuiTheme } from "@material-ui/core/styles"
import { createTheme } from "@material-ui/core/styles"
import { PaletteOptions } from "@material-ui/core/styles/createPalette"
import { borderRadius } from "./constants"
import { getOverrides } from "./overrides"
Expand All @@ -7,7 +7,7 @@ import { props } from "./props"
import { typography } from "./typography"

const makeTheme = (palette: PaletteOptions) => {
const theme = createMuiTheme({
const theme = createTheme({
palette,
typography,
shape: {
Expand Down
Loading