Skip to content

Commit

Permalink
fix: TypeScript performance of DismissibleBanner.tsx (#11075)
Browse files Browse the repository at this point in the history
* clean up types to fix perf

* add changeset

---------

Co-authored-by: Banks Nussman <banks@nussman.us>
  • Loading branch information
bnussman-akamai and bnussman authored Oct 9, 2024
1 parent e1b6b48 commit c359ad9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11075-fixed-1728498752415.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Fix TypeScript performance of `DismissibleBanner.tsx` ([#11075](https://github.com/linode/manager/pull/11075))
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import Close from '@mui/icons-material/Close';
import Grid from '@mui/material/Unstable_Grid2';
import { SxProps } from '@mui/system';
import * as React from 'react';

import { Box } from 'src/components/Box';
import {
DismissibleNotificationOptions,
useDismissibleNotifications,
} from 'src/hooks/useDismissibleNotifications';
import { useDismissibleNotifications } from 'src/hooks/useDismissibleNotifications';

import { StyledButton, StyledNotice } from './DismissibleBanner.styles';

import type { NoticeProps } from 'src/components/Notice/Notice';
import type { DismissibleNotificationOptions } from 'src/hooks/useDismissibleNotifications';

interface Props {
interface Props extends NoticeProps {
/**
* Optional element to pass to the banner to trigger actions
*/
actionButton?: JSX.Element;
/**
* Child element to pass to the banner
*/
children: JSX.Element;
/**
* Additional classes to the root element
*/
className?: string;
/**
* Additional controls to pass to the Dismissible Banner
*/
Expand All @@ -34,16 +23,8 @@ interface Props {
* Used to check if this banner has already been dismissed
*/
preferenceKey: string;
/**
* Additional styles to apply to the root element
*/
sx?: SxProps;
}

interface DismissibleBannerProps
extends Omit<Partial<NoticeProps>, 'children'>,
Props {}

/**
* ## Usage
*
Expand All @@ -60,7 +41,7 @@ interface DismissibleBannerProps
* - Warning: Informs users of an impending change that will have an impact on their service(s).
* - Call to action: Primary Button or text link allows a user to take action directly from the banner.
*/
export const DismissibleBanner = (props: DismissibleBannerProps) => {
export const DismissibleBanner = (props: Props) => {
const {
actionButton,
children,
Expand Down
20 changes: 5 additions & 15 deletions packages/manager/src/components/Notice/Notice.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import Grid, { Grid2Props } from '@mui/material/Unstable_Grid2';
import { SxProps } from '@mui/system';
import Grid from '@mui/material/Unstable_Grid2';
import * as React from 'react';

import Error from 'src/assets/icons/alert.svg';
import Check from 'src/assets/icons/check.svg';
import Warning from 'src/assets/icons/warning.svg';
import { Typography, TypographyProps } from 'src/components/Typography';
import { Typography } from 'src/components/Typography';

import { useStyles } from './Notice.styles';

import type { Grid2Props } from '@mui/material/Unstable_Grid2';
import type { TypographyProps } from 'src/components/Typography';

export type NoticeVariant =
| 'error'
| 'info'
Expand All @@ -23,10 +25,6 @@ export interface NoticeProps extends Grid2Props {
* **Note:** This only applies to notice variants of "error".
*/
bypassValidation?: boolean;
/**
* Additional classes to be applied to the root element.
*/
className?: string;
/**
* The data-qa attribute to apply to the root element.
*/
Expand All @@ -39,10 +37,6 @@ export interface NoticeProps extends Grid2Props {
* If true, an icon will be displayed to the left of the error, reflecting the variant of the error.
*/
important?: boolean;
/**
* The function to execute when/if the error is clicked.
*/
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
/**
* The amount of spacing to apply to the bottom of the error.
*/
Expand All @@ -55,10 +49,6 @@ export interface NoticeProps extends Grid2Props {
* The amount of spacing to apply to the top of the error.
*/
spacingTop?: 0 | 4 | 8 | 12 | 16 | 24 | 32;
/**
* Additional styles to apply to the root element.
*/
sx?: SxProps;
/**
* The text to display in the error. If this is not provided, props.children will be used.
*/
Expand Down

0 comments on commit c359ad9

Please sign in to comment.