diff --git a/packages/manager/.changeset/pr-9359-tech-stories-1688401214973.md b/packages/manager/.changeset/pr-9359-tech-stories-1688401214973.md new file mode 100644 index 00000000000..15450f9ebd0 --- /dev/null +++ b/packages/manager/.changeset/pr-9359-tech-stories-1688401214973.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tech Stories +--- + +MUI v5 - `Components > Snackbar` ([#9359](https://github.com/linode/manager/pull/9359)) diff --git a/packages/manager/src/components/DismissibleBanner/DismissibleBanner.stories.mdx b/packages/manager/src/components/DismissibleBanner/DismissibleBanner.stories.mdx index 6a29c6f7ef5..640b56e884e 100644 --- a/packages/manager/src/components/DismissibleBanner/DismissibleBanner.stories.mdx +++ b/packages/manager/src/components/DismissibleBanner/DismissibleBanner.stories.mdx @@ -40,7 +40,7 @@ export const DismissibleBannerTemplate = (args) => { export const CallToActionBanner = () => { return ( - + { export const BetaBanner = () => { return ( - + Managed Database for MySQL is available in a free, open beta period until May 2nd, 2022. This is a beta environment and should not be used diff --git a/packages/manager/src/components/Notice/Notice.stories.mdx b/packages/manager/src/components/Notice/Notice.stories.mdx index f60de9e2047..a837d85b83b 100644 --- a/packages/manager/src/components/Notice/Notice.stories.mdx +++ b/packages/manager/src/components/Notice/Notice.stories.mdx @@ -15,7 +15,8 @@ import { Notice } from './Notice'; Types of Notices: -- Success/Marketing (blue line) +- Success/Marketing (green line) +- Info (blue line) - Error/critical (red line) - Warning (yellow line) @@ -25,6 +26,12 @@ Types of Notices: + + + + + + @@ -43,6 +50,12 @@ Types of Notices: + + + + + + diff --git a/packages/manager/src/components/Notice/Notice.tsx b/packages/manager/src/components/Notice/Notice.tsx index b4c45b9b672..a64c6daa9bd 100644 --- a/packages/manager/src/components/Notice/Notice.tsx +++ b/packages/manager/src/components/Notice/Notice.tsx @@ -100,6 +100,16 @@ export const useStyles = makeStyles< successList: { borderLeft: `5px solid ${theme.palette.success.dark}`, }, + info: { + animation: '$fadeIn 225ms linear forwards', + borderLeft: `5px solid ${theme.palette.info.dark}`, + [`&.${classes.important}`]: { + borderLeftWidth: 32, + }, + }, + infoList: { + borderLeft: `5px solid ${theme.palette.info.dark}`, + }, marketing: { borderLeft: `5px solid ${theme.color.green}`, }, @@ -115,6 +125,7 @@ export interface NoticeProps extends Grid2Props { important?: boolean; warning?: boolean; success?: boolean; + info?: boolean; marketing?: boolean; typeProps?: TypographyProps; className?: string; @@ -131,25 +142,26 @@ export interface NoticeProps extends Grid2Props { export const Notice = (props: NoticeProps) => { const { + breakWords, + children, className, - important, - text, + dataTestId, error, - breakWords, errorGroup, - warning, - success, - marketing, - typeProps, - children, flag, + important, + info, + marketing, notificationList, onClick, - spacingTop, spacingBottom, spacingLeft, - dataTestId, + spacingTop, + success, sx, + text, + typeProps, + warning, } = props; const { classes, cx } = useStyles(); @@ -206,6 +218,8 @@ export const Notice = (props: NoticeProps) => { [classes.errorList]: error && notificationList, [classes.success]: success && !notificationList, [classes.successList]: success && notificationList, + [classes.info]: info && !notificationList, + [classes.infoList]: info && notificationList, [classes.warning]: warning && !notificationList, [classes.marketing]: marketing, [classes.warningList]: warning && notificationList, @@ -228,7 +242,7 @@ export const Notice = (props: NoticeProps) => { )} {important && ((success && ) || - (warning && ( + ((warning || info) && ( )) || (error && ))} diff --git a/packages/manager/src/components/SnackBar/index.ts b/packages/manager/src/components/SnackBar/index.ts deleted file mode 100644 index 9df7163ee1e..00000000000 --- a/packages/manager/src/components/SnackBar/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import SnackBar from './SnackBar'; -export default SnackBar; diff --git a/packages/manager/src/components/SnackBar/CloseSnackbar.tsx b/packages/manager/src/components/Snackbar/CloseSnackbar.tsx similarity index 100% rename from packages/manager/src/components/SnackBar/CloseSnackbar.tsx rename to packages/manager/src/components/Snackbar/CloseSnackbar.tsx diff --git a/packages/manager/src/components/SnackBar/SnackBar.tsx b/packages/manager/src/components/Snackbar/Snackbar.tsx similarity index 85% rename from packages/manager/src/components/SnackBar/SnackBar.tsx rename to packages/manager/src/components/Snackbar/Snackbar.tsx index 07ab94a5d10..03cfcc7984d 100644 --- a/packages/manager/src/components/SnackBar/SnackBar.tsx +++ b/packages/manager/src/components/Snackbar/Snackbar.tsx @@ -1,10 +1,10 @@ import { SnackbarProvider, SnackbarProviderProps } from 'notistack'; import * as React from 'react'; -import { makeStyles } from '@mui/styles'; +import { makeStyles } from 'tss-react/mui'; import { Theme } from '@mui/material/styles'; import CloseSnackbar from './CloseSnackbar'; -const useStyles = makeStyles((theme: Theme) => ({ +const useStyles = makeStyles()((theme: Theme) => ({ root: { '& div': { backgroundColor: `${theme.bg.white} !important`, @@ -29,7 +29,7 @@ const useStyles = makeStyles((theme: Theme) => ({ borderLeft: `6px solid ${theme.palette.primary.main}`, }, success: { - borderLeft: `6px solid ${theme.palette.primary.main}`, + borderLeft: `6px solid ${theme.color.green}`, }, error: { borderLeft: `6px solid ${theme.palette.error.dark}`, @@ -39,10 +39,8 @@ const useStyles = makeStyles((theme: Theme) => ({ }, })); -type CombinedProps = SnackbarProviderProps; - -const SnackBar: React.FC = (props) => { - const classes = useStyles(); +export const Snackbar = (props: SnackbarProviderProps) => { + const { classes } = useStyles(); /** * This pattern is taken from the Notistack docs: * https://iamhosseindhv.com/notistack/demos#action-for-all-snackbars @@ -78,5 +76,3 @@ const SnackBar: React.FC = (props) => { ); }; - -export default SnackBar; diff --git a/packages/manager/src/features/Account/AutoBackups.tsx b/packages/manager/src/features/Account/AutoBackups.tsx index 7fccbc77040..d6c4c28b647 100644 --- a/packages/manager/src/features/Account/AutoBackups.tsx +++ b/packages/manager/src/features/Account/AutoBackups.tsx @@ -49,7 +49,7 @@ const AutoBackups = (props: Props) => { {!!isManagedCustomer ? ( - + You’re a Managed customer, which means your Linodes are already automatically backed up - no need to toggle this setting. diff --git a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx index ae4d4cb9ae2..dea35630607 100644 --- a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx +++ b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx @@ -562,7 +562,7 @@ const DatabaseCreate = () => { {flags.databaseBeta ? ( - + Notice: There is no charge for database clusters during beta. {' '} diff --git a/packages/manager/src/features/Events/EventsLanding.tsx b/packages/manager/src/features/Events/EventsLanding.tsx index 68b7c0dee43..528743e2a99 100644 --- a/packages/manager/src/features/Events/EventsLanding.tsx +++ b/packages/manager/src/features/Events/EventsLanding.tsx @@ -1,6 +1,6 @@ import { Event, getEvents } from '@linode/api-v4/lib/account'; import { ResourcePage } from '@linode/api-v4/lib/types'; -import { withSnackbar, WithSnackbarProps } from 'notistack'; +import { useSnackbar } from 'notistack'; import { compose as rCompose, concat, uniq } from 'ramda'; import * as React from 'react'; import { connect } from 'react-redux'; @@ -61,7 +61,7 @@ interface Props { emptyMessage?: string; // Custom message for the empty state (i.e. no events). } -type CombinedProps = Props & StateProps & WithSnackbarProps; +type CombinedProps = Props & StateProps; const appendToEvents = (oldEvents: Event[], newEvents: Event[]) => rCompose( @@ -173,6 +173,7 @@ export const reducer: EventsReducer = (state, action) => { export const EventsLanding: React.FC = (props) => { const classes = useStyles(); + const { enqueueSnackbar } = useSnackbar(); const [loading, setLoading] = React.useState(false); const [loadMoreEvents, setLoadMoreEvents] = React.useState(false); @@ -199,7 +200,7 @@ export const EventsLanding: React.FC = (props) => { getEventsRequest({ page: currentPage }) .then(handleEventsRequestSuccess) .catch(() => { - props.enqueueSnackbar('There was an error loading more events', { + enqueueSnackbar('There was an error loading more events', { variant: 'error', }); setLoading(false); @@ -403,6 +404,6 @@ const mapStateToProps = (state: ApplicationState) => ({ const connected = connect(mapStateToProps); -const enhanced = compose(connected, withSnackbar); +const enhanced = compose(connected); export default enhanced(EventsLanding); diff --git a/packages/manager/src/features/Images/ImagesCreate/CreateImageTab.tsx b/packages/manager/src/features/Images/ImagesCreate/CreateImageTab.tsx index fdd262e59c1..2d169c6e0ff 100644 --- a/packages/manager/src/features/Images/ImagesCreate/CreateImageTab.tsx +++ b/packages/manager/src/features/Images/ImagesCreate/CreateImageTab.tsx @@ -246,7 +246,7 @@ export const CreateImageTab: React.FC = (props) => { {generalError ? ( ) : null} - {notice ? : null} + {notice ? : null} = (props) => { ) : null} {generalError && } - {notice && } + {notice && } {['create', 'restore'].includes(mode) && (