-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5095d6e
commit a6d8674
Showing
9 changed files
with
137 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createContext } from "react"; | ||
|
||
export const LayoutContext = createContext<{ | ||
collapsed: boolean | ||
setCollapsed: React.Dispatch<React.SetStateAction<boolean>> | ||
}>({ | ||
collapsed: false, | ||
setCollapsed: () => { }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
import logo from "#src/assets/images/logo.svg"; | ||
import { Typography } from "antd"; | ||
import { createUseStyles } from "react-jss"; | ||
import { clsx } from "clsx"; | ||
|
||
import { useNavigate } from "react-router-dom"; | ||
|
||
const { Title } = Typography; | ||
|
||
const useStyles = createUseStyles({ | ||
logoContainer: { | ||
"display": "flex", | ||
"justifyContent": "center", | ||
"alignItems": "center", | ||
"gap": "0.5em", | ||
"height": "3.5em", | ||
"&:hover": { | ||
cursor: "pointer", | ||
}, | ||
}, | ||
logo: { | ||
width: "2.4em", | ||
}, | ||
}); | ||
|
||
export interface LogoProps { | ||
collapsed: boolean | ||
} | ||
|
||
export default function Logo({ collapsed }: LogoProps) { | ||
const classes = useStyles(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className={classes.logoContainer} onClick={() => navigate(import.meta.env.VITE_BASE_HOME_PATH)}> | ||
<img src={logo} alt="logo" className={classes.logo} /> | ||
<div | ||
// 和 header 高度保持一致 | ||
className="h-12 flex items-center justify-center gap-2 cursor-pointer" | ||
onClick={() => navigate(import.meta.env.VITE_BASE_HOME_PATH)} | ||
> | ||
<img | ||
src={logo} | ||
alt="logo" | ||
width={32} | ||
height={32} | ||
/> | ||
|
||
<Title level={1} className={clsx("!text-sm !m-0", { hidden: collapsed })} ellipsis={true}>React Antd Admin</Title> | ||
|
||
{collapsed | ||
? null | ||
: ( | ||
<Title level={1} className="!text-sm !m-0" ellipsis={true}>React Antd Admin</Title> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BasicButton } from "#src/components"; | ||
import { LayoutContext } from "#src/layout/container-layout/layout-context"; | ||
import { cn } from "#src/utils"; | ||
|
||
import { MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons"; | ||
import { useContext } from "react"; | ||
|
||
interface SiderTriggerProps { | ||
className?: string | ||
} | ||
export default function SiderTrigger({ className }: SiderTriggerProps) { | ||
const { collapsed, setCollapsed } = useContext(LayoutContext); | ||
|
||
return ( | ||
<BasicButton | ||
type="text" | ||
style={{ | ||
boxShadow: "0px -3px 5px 0 rgb(29, 35, 41, 0.05)", | ||
}} | ||
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />} | ||
onClick={() => setCollapsed(!collapsed)} | ||
className={cn(className, "absolute bottom-0 h-10 !w-full rounded-none border border-t-gray-200")} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters