1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-15 17:50:48 +02:00

fix: navigation button spacing

This commit is contained in:
Tymoteusz Czech 2023-08-17 14:21:37 +02:00
parent ac369d4b94
commit 8ec9080c23
No known key found for this signature in database
GPG Key ID: 133555230D88D75F
3 changed files with 19 additions and 37 deletions

View File

@ -1,4 +1,4 @@
import { useLocation } from 'react-router-dom'; import { useLocation, useNavigate } from 'react-router-dom';
import { Paper, styled, Tab, Tabs } from '@mui/material'; import { Paper, styled, Tab, Tabs } from '@mui/material';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { CenteredNavLink } from './CenteredNavLink'; import { CenteredNavLink } from './CenteredNavLink';
@ -23,6 +23,7 @@ const StyledBadgeContainer = styled('div')(({ theme }) => ({
export const AdminTabsMenu: VFC = () => { export const AdminTabsMenu: VFC = () => {
const { uiConfig, isPro, isOss } = useUiConfig(); const { uiConfig, isPro, isOss } = useUiConfig();
const { pathname } = useLocation(); const { pathname } = useLocation();
const navigate = useNavigate();
const activeTab = pathname.split('/')[2]; const activeTab = pathname.split('/')[2];
@ -55,6 +56,7 @@ export const AdminTabsMenu: VFC = () => {
> >
{tabs.map(tab => ( {tabs.map(tab => (
<Tab <Tab
sx={{ padding: 0 }}
key={tab.route} key={tab.route}
value={tab.route?.split('/')?.[2]} value={tab.route?.split('/')?.[2]}
label={ label={

View File

@ -1,41 +1,21 @@
import { Theme } from '@mui/material'; import { styled } from '@mui/material';
import React, { FC } from 'react'; import { FC } from 'react';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import { useTheme } from '@mui/material/styles';
const createNavLinkStyle = (props: { const StyledNavLink = styled(NavLink)(({ theme }) => ({
isActive: boolean; display: 'flex',
theme: Theme; justifyContent: 'center',
}): React.CSSProperties => { alignItems: 'center',
const navLinkStyle = { width: '100%',
display: 'flex', height: '100%',
justifyContent: 'center', textDecoration: 'none',
alignItems: 'center', color: 'inherit',
width: '100%', padding: theme.spacing(0, 5),
textDecoration: 'none', '&.active': {
color: 'inherit',
padding: props.theme.spacing(1.5, 3),
};
const activeNavLinkStyle: React.CSSProperties = {
fontWeight: 'bold', fontWeight: 'bold',
borderRadius: '3px', },
padding: props.theme.spacing(1.5, 3), }));
};
return props.isActive
? { ...navLinkStyle, ...activeNavLinkStyle }
: navLinkStyle;
};
export const CenteredNavLink: FC<{ to: string }> = ({ to, children }) => { export const CenteredNavLink: FC<{ to: string }> = ({ to, children }) => {
const theme = useTheme(); return <StyledNavLink to={to}>{children}</StyledNavLink>;
return (
<NavLink
to={to}
style={({ isActive }) => createNavLinkStyle({ isActive, theme })}
>
{children}
</NavLink>
);
}; };

View File

@ -98,9 +98,9 @@ export const NavigationMenu = ({
} }
arrow arrow
placement="left" placement="left"
key={option.path}
> >
<MenuItem <MenuItem
key={option.path}
component={StyledLink} component={StyledLink}
to={option.path} to={option.path}
onClick={handleClose} onClick={handleClose}