mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 09:17:06 +08:00
fix(a11y): WCAG 2.1 AA fixes (#2219)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
||||
import { useAtom } from "jotai";
|
||||
|
||||
export const ASIDE_PANEL_ID = "aside-panel";
|
||||
|
||||
const useToggleAside = () => {
|
||||
const [asideState, setAsideState] = useAtom(asideStateAtom);
|
||||
|
||||
@@ -15,4 +17,20 @@ const useToggleAside = () => {
|
||||
return toggleAside;
|
||||
};
|
||||
|
||||
export const useAsideTriggerProps = (tab: string) => {
|
||||
const [asideState, setAsideState] = useAtom(asideStateAtom);
|
||||
|
||||
return {
|
||||
onClick: () => {
|
||||
if (asideState.tab === tab) {
|
||||
setAsideState({ tab, isAsideOpen: !asideState.isAsideOpen });
|
||||
} else {
|
||||
setAsideState({ tab, isAsideOpen: true });
|
||||
}
|
||||
},
|
||||
"aria-expanded": asideState.isAsideOpen && asideState.tab === tab,
|
||||
"aria-controls": ASIDE_PANEL_ID,
|
||||
} as const;
|
||||
};
|
||||
|
||||
export default useToggleAside;
|
||||
|
||||
Reference in New Issue
Block a user