Skip to content

Commit

Permalink
Make props more explicit for Alert and ErrorAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
benmartin-coforma committed Jan 28, 2025
1 parent 0d04dc9 commit c47446c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
20 changes: 10 additions & 10 deletions services/ui-src/src/components/alerts/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import { ReactNode } from "react";

export const Alert = ({
status = AlertTypes.INFO,
sx: sxOverride,
className,
showIcon = true,
icon,
title,
children,
link,
showIcon = true,
icon,
...props
}: Props) => {
return (
<AlertRoot
status={status}
variant="left-accent"
sx={sx.root}
className={status}
{...props}
sx={sxOverride ?? sx.root}
className={className ?? status}
>
<Flex>
{showIcon && (
Expand Down Expand Up @@ -56,13 +56,13 @@ export const Alert = ({

interface Props {
status?: AlertTypes;
title?: string;
link?: string;
sx?: CSSObject;
showIcon?: boolean;
icon?: string;
children?: ReactNode;
title?: string;
className?: string;
sx?: CSSObject;
children?: ReactNode;
link?: string;
}

const sx = {
Expand Down
11 changes: 5 additions & 6 deletions services/ui-src/src/components/alerts/ErrorAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Collapse } from "@chakra-ui/react";
import { Box, Collapse, CSSObject } from "@chakra-ui/react";
import { Alert } from "components";
import { useRef } from "react";
import { AlertTypes, ErrorVerbiage } from "types";
Expand All @@ -7,7 +7,7 @@ export const ErrorAlert = ({
error,
variant = "inline",
sxOverride,
...props
alertSxOverride,
}: Props) => {
// Focus the alert when an error is given
const ref = useRef<HTMLDivElement>(null);
Expand All @@ -25,8 +25,7 @@ export const ErrorAlert = ({
title={error.title}
showIcon={false}
className={variant}
sx={sx.root}
{...props}
sx={alertSxOverride ?? sx.root}
>
{error.children}
</Alert>
Expand All @@ -39,8 +38,8 @@ export const ErrorAlert = ({
interface Props {
error?: ErrorVerbiage;
variant?: "inline" | "toast";
sxOverride?: any;
[key: string]: any;
sxOverride?: CSSObject;
alertSxOverride?: CSSObject;
}

const sx = {
Expand Down
4 changes: 2 additions & 2 deletions services/ui-src/src/components/banners/Banner.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Alert } from "components";
import { BannerData } from "types";

export const Banner = ({ bannerData, ...props }: Props) => {
export const Banner = ({ bannerData }: Props) => {
if (bannerData) {
const { title, description, link } = bannerData;
return (
bannerData && (
<Alert title={title} link={link} {...props}>
<Alert title={title} link={link}>
{description}
</Alert>
)
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/src/components/logins/LoginCognito.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const LoginCognito = () => {
<Heading size="md" as="h2" sx={sx.heading}>
Log In with Cognito
</Heading>
<ErrorAlert error={error} sx={sx.error} />
<ErrorAlert error={error} alertSxOverride={sx.error} />
<form onSubmit={(event) => handleLogin(event)}>
<Box sx={sx.label}>
<label>
Expand Down

0 comments on commit c47446c

Please sign in to comment.