import React, { useState, useEffect } from "react"; // import Link from "next/link"; import { useRouter } from "next/router"; // import { useWindowSize, useWindowWidth, useWindowHeight } from "@react-hook/window-size"; // import { Layout, Menu, Switch } from "antd"; import { HomeOutlined, AppstoreOutlined, BarChartOutlined, CloudOutlined, ShopOutlined, TeamOutlined, UserOutlined, UploadOutlined, VideoCameraOutlined } from "@ant-design/icons"; // import { Input } from "antd"; // // // // const { Search } = Input; // const { Header, Content, Footer, Sider } = Layout; const AppLayout = props => { const [siderKey, setSiderKey] = useState(""); const [isSiderCollapsed, setSiderCollapsed] = useState(false); const [window, setWindow] = useState({ width: -1, height: -1 }); const [width, height] = useWindowSize(); useEffect(() => { setWindow({ width: width, height: height }); return () => { // cleanup }; }, [width, height]); const router = useRouter(); useEffect(() => { console.log(siderKey); return () => { // cleanup }; }, [siderKey]); useEffect(() => { console.log("useEffect fired by useRouter"); const urlPath = router.pathname; switch (urlPath) { case "/": setSiderKey(0); break; case "/profile": setSiderKey(1); break; case "/videos": setSiderKey(2); break; case "/backup": setSiderKey(3); break; case "/analytics": setSiderKey(4); break; } return () => { // cleanup }; }, [router]); const contentStyleWidth = // responsive design window.width < 480 ? { width: "calc(100vw - 32px)" } : {}; return ( 480 ? "80" : "0"} // enable responsive hidden sider for mobile only onBreakpoint={broken => { console.log(broken); }} collapsed={isSiderCollapsed} onCollapse={(collapsed, type) => { setSiderCollapsed(collapsed); console.log(collapsed, type); }} >
Sider Logo
Home
Profile
Videos
Backup
Analytics
Cloud Apps Collaborate Shop
Main Logo
{props.children}
); }; export default AppLayout;