From 76a546edcc1b7aa679ae5397bbf81549035f0c00 Mon Sep 17 00:00:00 2001 From: Abubakkar Date: Wed, 21 Feb 2024 17:20:31 +0500 Subject: [PATCH] Replace makeStyles with styled in ReportComplete for MUI v5 compatibility This commit transitions the ReportComplete component styling approach from using makeStyles to the styled API provided by Material-UI v5. The change is part of an effort to align with the latest best practices and features offered by Material-UI, ensuring greater consistency and ease of theme integration across the project. --- .../src/ReportComplete.tsx | 159 +++++++++--------- 1 file changed, 79 insertions(+), 80 deletions(-) diff --git a/examples/custom-snackbar-example-2/src/ReportComplete.tsx b/examples/custom-snackbar-example-2/src/ReportComplete.tsx index 9167d6f..e4f9994 100644 --- a/examples/custom-snackbar-example-2/src/ReportComplete.tsx +++ b/examples/custom-snackbar-example-2/src/ReportComplete.tsx @@ -1,67 +1,69 @@ -import { useState, forwardRef, useCallback } from "react"; -import clsx from "clsx"; -import { makeStyles } from "@mui/styles"; -import { useSnackbar, SnackbarContent, CustomContentProps } from "notistack"; -import Collapse from "@mui/material/Collapse"; -import Paper from "@mui/material/Paper"; -import Typography from "@mui/material/Typography"; -import Card from "@mui/material/Card"; -import CardActions from "@mui/material/CardActions"; -import Button from "@mui/material/Button"; -import IconButton from "@mui/material/IconButton"; -import CloseIcon from "@mui/icons-material/Close"; -import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; -import CheckCircleIcon from "@mui/icons-material/CheckCircle"; +import React, { useState, forwardRef, useCallback } from 'react'; +import { styled } from '@mui/material/styles'; +import { useSnackbar, SnackbarContent } from 'notistack'; +import Collapse from '@mui/material/Collapse'; +import Paper from '@mui/material/Paper'; +import Typography from '@mui/material/Typography'; +import Card from '@mui/material/Card'; +import CardActions from '@mui/material/CardActions'; +import Button from '@mui/material/Button'; +import IconButton from '@mui/material/IconButton'; +import CloseIcon from '@mui/icons-material/Close'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import CheckCircleIcon from '@mui/icons-material/CheckCircle'; -const useStyles = makeStyles(() => ({ - root: { - "@media (min-width:600px)": { - minWidth: "344px !important" - } +const StyledSnackbarContent = styled(SnackbarContent)(({ theme }) => ({ + '@media (min-width:600px)': { + minWidth: '344px !important', }, - card: { - width: "100%" - }, - typography: { - color: "#000" - }, - actionRoot: { - padding: "8px 8px 8px 16px", - justifyContent: "space-between" - }, - icons: { - marginLeft: "auto" - }, - expand: { - padding: "8px 8px", - transform: "rotate(0deg)", - color: "#000", - transition: "all .2s" - }, - expandOpen: { - transform: "rotate(180deg)" - }, - paper: { - backgroundColor: "#fff", - padding: 16 - }, - checkIcon: { - fontSize: 20, - paddingRight: 4 +})); + +const StyledCard = styled(Card)(({ theme }) => ({ + width: '100%', + backgroundColor: '#fddc6c', +})); + +const StyledTypography = styled(Typography)(({ theme }) => ({ + color: '#000', +})); + +const StyledCardActions = styled(CardActions)(({ theme }) => ({ + padding: '8px 8px 8px 16px', + justifyContent: 'space-between', +})); + +const StyledIconButton = styled(IconButton)(({ theme }) => ({ + padding: '8px 8px', + color: '#000', + transition: 'all .2s', + '&.expandOpen': { + transform: 'rotate(180deg)', }, - button: { - padding: 0, - textTransform: "none" - } })); -interface ReportCompleteProps extends CustomContentProps { +const StyledPaper = styled(Paper)(({ theme }) => ({ + backgroundColor: '#fff', + padding: 16, +})); + +const StyledButton = styled(Button)(({ theme }) => ({ + padding: 0, + textTransform: 'none', +})); + +const StyledCheckCircleIcon = styled(CheckCircleIcon)(({ theme }) => ({ + fontSize: 20, + paddingRight: 4, +})); + +interface ReportCompleteProps { + id: string | number; + message: string; allowDownload?: boolean; } const ReportComplete = forwardRef( - ({ id, ...props }, ref) => { - const classes = useStyles(); + ({ id, message, ...props }, ref) => { const { closeSnackbar } = useSnackbar(); const [expanded, setExpanded] = useState(false); @@ -74,53 +76,50 @@ const ReportComplete = forwardRef( }, [id, closeSnackbar]); return ( - - - - - {props.message} - -
- + + + + {message} + +
+ - - + - +
- +
- + PDF ready - - + + - - +
+ ); } ); -ReportComplete.displayName = "ReportComplete"; +ReportComplete.displayName = 'ReportComplete'; export default ReportComplete;