Skip to content

Commit

Permalink
Added onAlertClosed prop to Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaakher committed Nov 2, 2023
1 parent 5da285e commit 264e66c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/elements/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { DirectionType, SeverityType } from "../types/commonTypes";
import { Button } from "./Button";
import { cn } from "../util";

// TODO: make handleClose to detect when the alert is closed from outside this component

type AlertTypes = {
severity?: SeverityType | "hyper" | "oceanic";
/** The title of the alert placed above the text of the alert. Can be used alone */
Expand Down Expand Up @@ -37,6 +35,7 @@ type AlertTypes = {
persistent?: boolean;
icon?: any;
className?: any;
onAlertClosed?: any;
};

export const Alert: React.FunctionComponent<AlertTypes> = ({
Expand Down Expand Up @@ -162,6 +161,7 @@ export const Alert: React.FunctionComponent<AlertTypes> = ({
direction === "rtl" ? "hawa-left-2" : "hawa-right-2"
)}
onClick={() => {
props.onAlertClosed();
setClosed(true);
setTimeout(() => {
if (alertRef?.current) {
Expand Down
2 changes: 1 addition & 1 deletion stories/ElementsStories/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Alert } from "../../components/elements";
import { ArgsTable, Story, Title } from "@storybook/blocks";
import { ArgsTable, Story } from "@storybook/blocks";
import { setLocale, t } from "../translations/i18n";

const meta = {
Expand Down

0 comments on commit 264e66c

Please sign in to comment.