-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3286 from getAlby/revert-3283-allow-to-close-aler…
…t-banner Revert "feat: allow to close wallet update banner"
- Loading branch information
Showing
7 changed files
with
8 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,22 @@ | ||
import { PopiconsXLine } from "@popicons/react"; | ||
import { useState } from "react"; | ||
import { classNames } from "~/app/utils"; | ||
|
||
type Props = { | ||
type: "warn" | "info"; | ||
children: React.ReactNode; | ||
showClose?: boolean; | ||
onClose?: () => void; // Optional callback function | ||
}; | ||
|
||
export default function Alert({ | ||
type, | ||
children, | ||
showClose = false, | ||
onClose, | ||
}: Props) { | ||
const [isVisible, setIsVisible] = useState(true); | ||
|
||
const handleClose = () => { | ||
setIsVisible(false); | ||
if (onClose) { | ||
onClose(); // Invoke the callback function if provided | ||
} | ||
}; | ||
|
||
if (!isVisible) return null; | ||
|
||
export default function Alert({ type, children }: Props) { | ||
return ( | ||
<div | ||
className={classNames( | ||
"border rounded-md p-3 flex justify-between relative", | ||
type === "warn" && | ||
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900", | ||
type === "info" && | ||
"border rounded-md p-3", | ||
type == "warn" && | ||
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900", | ||
type == "info" && | ||
"text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-100 dark:border-blue-900" | ||
)} | ||
> | ||
{showClose && ( | ||
<button | ||
onClick={handleClose} | ||
className="absolute right-2 top-2 text-gray-600 dark:text-neutral-400 hover:text-gray-700 dark:hover:text-neutral-300" | ||
aria-label="Close alert" | ||
> | ||
<PopiconsXLine className="w-5 h-5" /> | ||
</button> | ||
)} | ||
<div className="pr-8">{children}</div> | ||
{children} | ||
</div> | ||
); | ||
} |
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
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
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