Skip to content

Commit

Permalink
Merge pull request #80 from harshmangalam/revert-79-main
Browse files Browse the repository at this point in the history
Revert "enhance alert box accessbility #52 issue"
  • Loading branch information
harshmangalam authored Oct 15, 2024
2 parents 6f31617 + 3c75ee4 commit b1349fc
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/components/ui/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
import { component$, useStore } from "@builder.io/qwik";
import { component$ } from "@builder.io/qwik";

type Props = {
text: string;
status: "alert-info" | "alert-success" | "alert-warning" | "alert-error";
onClose?: () => void;
};

export const Alert = component$((props: Props) => {
const { text, status = "alert-info", onClose } = props;
const store = useStore({ isVisible: true });

const handleClose = () => {
store.isVisible = false;
if (onClose) {
onClose();
}
};

if (!store.isVisible) return null;

const { text, status = "alert-info" } = props;
return (
<div
role="alert"
aria-live="assertive"
aria-atomic="true"
class={["alert", status]}
aria-label="Alert"
>
<div class={["alert", status]}>
<span>{text}</span>
{onClose && (
<button
onClick={handleClose}
aria-label="Close alert"
class="close-button"
>
&times; {/* Close icon */}
</button>
)}
</div>
);
});

0 comments on commit b1349fc

Please sign in to comment.