mirror of https://github.com/usememos/memos
chore: update home sidebar
parent
5ff0234c71
commit
65a34ee41a
@ -0,0 +1,37 @@
|
|||||||
|
import { Drawer, IconButton } from "@mui/joy";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
import HomeSidebar from "./HomeSidebar";
|
||||||
|
import Icon from "./Icon";
|
||||||
|
|
||||||
|
const HomeSidebarDrawer = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setOpen(false);
|
||||||
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
const toggleDrawer = (inOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
||||||
|
if (event.type === "keydown" && ((event as React.KeyboardEvent).key === "Tab" || (event as React.KeyboardEvent).key === "Shift")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setOpen(inOpen);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="md:hidden">
|
||||||
|
<IconButton onClick={toggleDrawer(true)}>
|
||||||
|
<Icon.Search className="w-5 h-auto dark:text-gray-200" />
|
||||||
|
</IconButton>
|
||||||
|
<Drawer anchor="right" open={open} onClose={toggleDrawer(false)}>
|
||||||
|
<div className="w-full px-4">
|
||||||
|
<HomeSidebar />
|
||||||
|
</div>
|
||||||
|
</Drawer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default HomeSidebarDrawer;
|
@ -1,15 +0,0 @@
|
|||||||
import store, { useAppSelector } from "..";
|
|
||||||
import { setHomeSidebarStatus } from "../reducer/layout";
|
|
||||||
|
|
||||||
export const useLayoutStore = () => {
|
|
||||||
const state = useAppSelector((state) => state.layout);
|
|
||||||
return {
|
|
||||||
state,
|
|
||||||
getState: () => {
|
|
||||||
return store.getState().tag;
|
|
||||||
},
|
|
||||||
setHomeSidebarStatus: (showHomeSidebar: boolean) => {
|
|
||||||
store.dispatch(setHomeSidebarStatus(showHomeSidebar));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,24 +0,0 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
||||||
|
|
||||||
interface State {
|
|
||||||
showHomeSidebar: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const layoutSlice = createSlice({
|
|
||||||
name: "layout",
|
|
||||||
initialState: {
|
|
||||||
showHomeSidebar: false,
|
|
||||||
} as State,
|
|
||||||
reducers: {
|
|
||||||
setHomeSidebarStatus: (state, action: PayloadAction<boolean>) => {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
showHomeSidebar: action.payload,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const { setHomeSidebarStatus } = layoutSlice.actions;
|
|
||||||
|
|
||||||
export default layoutSlice.reducer;
|
|
@ -1,7 +0,0 @@
|
|||||||
// resolution is used to define the breakpoints for the media queries.
|
|
||||||
// It's same as the breakpoints defined in tailwind.config.js
|
|
||||||
export const resolution = {
|
|
||||||
sm: 640,
|
|
||||||
md: 768,
|
|
||||||
lg: 1024,
|
|
||||||
};
|
|
Loading…
Reference in New Issue