-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: simplify alert components (#252)
- Loading branch information
Fran McDade
authored and
Fran McDade
committed
Nov 5, 2024
1 parent
1e494e0
commit 5e60c4f
Showing
9 changed files
with
84 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import { css } from "@emotion/react"; | ||
import styled from "@emotion/styled"; | ||
import { TABLET } from "../../../theme/common/breakpoints"; | ||
import { Alert } from "./alert"; | ||
import { Alert } from "@mui/material"; | ||
import { SIZE } from "../../../styles/common/constants/size"; | ||
import { | ||
textBody4002Lines, | ||
textBodyLarge500, | ||
} from "../../../styles/common/mixins/fonts"; | ||
|
||
/** | ||
* Flat alert - typically used when in full stretch or full "bleed" across a container. | ||
* e.g. the entire width of mobile viewports. | ||
*/ | ||
export const FlatAlert = styled(Alert)` | ||
border-left: none; | ||
border-radius: 0; | ||
border-right: none; | ||
box-shadow: none; | ||
`; | ||
|
||
/* eslint-disable valid-jsdoc -- disable require param */ | ||
/** | ||
* Fluid alert - typically used to transition between flat paper (mobile) and rounded paper (tablet or desktop). | ||
*/ | ||
/* eslint-enable valid-jsdoc -- disable require param */ | ||
export const FluidAlert = styled(Alert)` | ||
${({ theme }) => theme.breakpoints.down(TABLET)} { | ||
border-left: none; | ||
border-radius: 0; | ||
border-right: none; | ||
box-shadow: none; | ||
} | ||
export const StyledAlert = styled(Alert)` | ||
${(props) => | ||
props.size === SIZE.LARGE && | ||
css` | ||
padding: 20px; | ||
.MuiAlert-icon { | ||
padding: 2px 0; | ||
} | ||
.MuiAlert-message { | ||
${textBody4002Lines(props)}; | ||
.MuiAlertTitle-root { | ||
${textBodyLarge500(props)}; | ||
} | ||
} | ||
`} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,18 @@ | ||
import { | ||
AlertTitle, | ||
Alert as MAlert, | ||
AlertProps as MAlertProps, | ||
} from "@mui/material"; | ||
import React, { ReactNode } from "react"; | ||
import { AlertProps } from "@mui/material"; | ||
import React, { forwardRef } from "react"; | ||
import { BaseComponentProps } from "../../types"; | ||
import { StyledAlert } from "./alert.styles"; | ||
|
||
export interface AlertProps { | ||
children?: ReactNode; | ||
className?: string; | ||
color?: MAlertProps["color"]; | ||
icon?: MAlertProps["icon"]; | ||
severity: MAlertProps["severity"]; | ||
title?: ReactNode; | ||
variant?: MAlertProps["variant"]; | ||
} | ||
|
||
export const Alert = ({ | ||
children, | ||
className, | ||
color, | ||
icon, | ||
severity, | ||
title, | ||
variant = "standard", | ||
}: AlertProps): JSX.Element => { | ||
export const Alert = forwardRef< | ||
HTMLDivElement, | ||
AlertProps & BaseComponentProps | ||
>(function Alert( | ||
{ children, className, ...props }: AlertProps & BaseComponentProps, | ||
ref | ||
): JSX.Element { | ||
return ( | ||
<MAlert | ||
className={className} | ||
color={color} | ||
icon={icon} | ||
severity={severity} | ||
variant={variant} | ||
> | ||
{title && <AlertTitle>{title}</AlertTitle>} | ||
<StyledAlert className={className} ref={ref} {...props}> | ||
{children} | ||
</MAlert> | ||
</StyledAlert> | ||
); | ||
}; | ||
}); |
20 changes: 0 additions & 20 deletions
20
src/components/common/Alert/components/AlertText/alertText.styles.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum SIZE { | ||
LARGE = "large", | ||
MEDIUM = "medium", | ||
SMALL = "small", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters