add skip navigation, page title, and global ARIA live region
This commit is contained in:
19
src/hooks/useAnnounce.ts
Normal file
19
src/hooks/useAnnounce.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
interface AnnounceState {
|
||||
message: string;
|
||||
announce: (text: string) => void;
|
||||
}
|
||||
|
||||
export const useAnnounceStore = create<AnnounceState>((set) => ({
|
||||
message: "",
|
||||
announce: (text) => {
|
||||
// Clear first to ensure re-announcement of identical messages
|
||||
set({ message: "" });
|
||||
requestAnimationFrame(() => set({ message: text }));
|
||||
},
|
||||
}));
|
||||
|
||||
export function useAnnounce() {
|
||||
return useAnnounceStore((s) => s.announce);
|
||||
}
|
||||
Reference in New Issue
Block a user