This PR address advanced toggle alignment, especially the left yellow dot placement. In other advanced settings navigation drawer, the dot appears -20px to left, while this was not the case for advanced toggle's dot. Matched the height and paddings to that of NavigationDrawerItem. @Bonapara FYI before: <img width="399" alt="Screenshot 2025-03-13 at 15 49 21" src="https://github.com/user-attachments/assets/6dd60b3a-1b2e-43a0-ad28-dc44437460ab" /> after: <img width="401" alt="Screenshot 2025-03-13 at 15 47 43" src="https://github.com/user-attachments/assets/86e51b07-e84a-413a-8a49-1820c165dc68" /> --------- Co-authored-by: Charles Bochet <charles@twenty.com>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { useMatch, useResolvedPath } from 'react-router-dom';
|
|
|
|
import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper';
|
|
import { SettingsNavigationItem } from '@/settings/hooks/useSettingsNavigationItems';
|
|
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
|
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
|
|
import { isDefined } from 'twenty-shared';
|
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
|
|
|
type SettingsNavigationDrawerItemProps = {
|
|
item: SettingsNavigationItem;
|
|
subItemState?: NavigationDrawerSubItemState;
|
|
};
|
|
|
|
export const SettingsNavigationDrawerItem = ({
|
|
item,
|
|
subItemState,
|
|
}: SettingsNavigationDrawerItemProps) => {
|
|
const href = item.path ? getSettingsPath(item.path) : '';
|
|
const pathName = useResolvedPath(href).pathname;
|
|
const isActive = !!useMatch({
|
|
path: pathName,
|
|
end: !item.matchSubPages,
|
|
});
|
|
|
|
if (isDefined(item.isHidden) && item.isHidden) {
|
|
return null;
|
|
}
|
|
|
|
if (isDefined(item.isAdvanced) && item.isAdvanced) {
|
|
return (
|
|
<AdvancedSettingsWrapper>
|
|
<NavigationDrawerItem
|
|
indentationLevel={item.indentationLevel}
|
|
subItemState={subItemState}
|
|
label={item.label}
|
|
to={href}
|
|
Icon={item.Icon}
|
|
active={isActive}
|
|
soon={item.soon}
|
|
onClick={item.onClick}
|
|
/>
|
|
</AdvancedSettingsWrapper>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<NavigationDrawerItem
|
|
indentationLevel={item.indentationLevel}
|
|
subItemState={subItemState}
|
|
label={item.label}
|
|
to={href}
|
|
Icon={item.Icon}
|
|
active={isActive}
|
|
soon={item.soon}
|
|
onClick={item.onClick}
|
|
/>
|
|
);
|
|
};
|