// ** MUI Imports import { styled, useTheme } from '@mui/material/styles' import useScrollTrigger from '@mui/material/useScrollTrigger' import MuiAppBar, { AppBarProps } from '@mui/material/AppBar' import MuiToolbar, { ToolbarProps } from '@mui/material/Toolbar' // ** Type Import import { LayoutProps } from 'src/@core/layouts/types' // ** Util Import import { hexToRGBA } from 'src/@core/utils/hex-to-rgba' interface Props { hidden: LayoutProps['hidden'] toggleNavVisibility: () => void settings: LayoutProps['settings'] saveSettings: LayoutProps['saveSettings'] appBarContent: NonNullable['content'] appBarProps: NonNullable['componentProps'] } const AppBar = styled(MuiAppBar)(({ theme }) => ({ transition: 'none', alignItems: 'center', justifyContent: 'center', padding: theme.spacing(0, 6), backgroundColor: 'transparent', color: theme.palette.text.primary, minHeight: theme.mixins.toolbar.minHeight, [theme.breakpoints.down('sm')]: { paddingLeft: theme.spacing(4), paddingRight: theme.spacing(4) } })) const Toolbar = styled(MuiToolbar)(({ theme }) => ({ width: '100%', padding: '0 !important', borderBottomLeftRadius: theme.shape.borderRadius, borderBottomRightRadius: theme.shape.borderRadius, minHeight: `${theme.mixins.toolbar.minHeight}px !important`, transition: 'padding .25s ease-in-out, box-shadow .25s ease-in-out, background-color .25s ease-in-out' })) const LayoutAppBar = (props: Props) => { // ** Props const { settings, appBarProps, appBarContent: userAppBarContent } = props // ** Hooks const theme = useTheme() const scrollTrigger = useScrollTrigger({ threshold: 0, disableHysteresis: true }) // ** Vars const { skin, appBar, appBarBlur, contentWidth } = settings const appBarFixedStyles = () => { return { px: `${theme.spacing(6)} !important`, boxShadow: skin === 'bordered' ? 0 : 3, ...(appBarBlur && { backdropFilter: 'blur(8px)' }), backgroundColor: hexToRGBA(theme.palette.background.paper, appBarBlur ? 0.9 : 1), ...(skin === 'bordered' && { border: `1px solid ${theme.palette.divider}`, borderTopWidth: 0 }) } } if (appBar === 'hidden') { return null } let userAppBarStyle = {} if (appBarProps && appBarProps.sx) { userAppBarStyle = appBarProps.sx } const userAppBarProps = Object.assign({}, appBarProps) delete userAppBarProps.sx return ( {(userAppBarContent && userAppBarContent(props)) || null} ) } export default LayoutAppBar