Skip to content

Commit

Permalink
started base UI componets for banner & card, not tested, still need t…
Browse files Browse the repository at this point in the history
…o style
  • Loading branch information
andieswift committed Sep 13, 2024
1 parent 02e3f96 commit 47cc5a4
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
31 changes: 30 additions & 1 deletion services/ui-src/src/components/MACCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropsWithChildren } from "react";
import React, { PropsWithChildren, ReactChildren } from "react";
import { faChevronRight } from "@fortawesome/free-solid-svg-icons";
import { Button } from "@cmsgov/design-system";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "react-router-dom";
import closingX from "../images/ClosingX.svg";
Expand Down Expand Up @@ -34,6 +35,15 @@ export type MACCardListProps = PropsWithChildren<{
legend: string;
additionalContainerClassName?: string;
}>;
export type MACNotificationCardProps = PropsWithChildren<{
header: string;
body: ReactChildren;
date: string;
button?: {
text: string;
link: string;
};
}>;

/** Styled wrapper for use in MACCards, consolidates the use of 'mac-card'
* css class. */
Expand Down Expand Up @@ -185,3 +195,22 @@ export const MACRemovableCard = ({
</MACCardWrapper>
);
};

/** A MACCard for use for notification banners on home screen */
export const MACNotificationCard = ({
header,
body,
date,
button,
}: MACNotificationCardProps) => {
return (
<MACCardWrapper>
<div>
{header && <MACCardTitle title={header} />}
{body}
{button && <Button href={button.link}>{button.text}</Button>}
{date}
</div>
</MACCardWrapper>
);
};
51 changes: 51 additions & 0 deletions services/ui-src/src/components/NotificationBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useState } from "react";
import { Alert, Button } from "@cmsgov/design-system";
import closingX from "../images/AlertClosingX.svg";

const CLOSING_X_IMAGE = <img alt="" className="closing-x" src={closingX} />;

interface NotificationBannerProps {
header: string;
body: string;
button?: {
text: string;
link: string;
};
}

const NotificationBanner: React.FC<NotificationBannerProps> = (
props: NotificationBannerProps
) => {
// notification state should be grabbed from context
const [showNotification, setShowNotification] = useState<boolean>(true);

// closing banner invokes API call
const close = () => {
// TODO: make an API call to
setShowNotification(false);
};

if (!showNotification) return <></>;
return (
<div className="alert-bar" id="alert-bar">
{/* should use cms Alert - informational */}
<Alert>
{/* TODO: put in flex, make button black */}
<h2 className="s-c-alert__heading">{props.header}</h2>
<p className="ds-c-alert__text">{props.body}</p>
{props.button && (
<Button href={props.button.link}>{props.button.text}</Button>
)}
<button
aria-label={"Dismiss alert"}
className="close-button"
onClick={close}
>
{CLOSING_X_IMAGE}
</button>
</Alert>
</div>
);
};

export default NotificationBanner;

0 comments on commit 47cc5a4

Please sign in to comment.