Files
twenty/packages/twenty-front/src/hooks/useIsMatchingLocation.ts
NitinPSingh 5404a8ba2d fixes #6499 alignment issue on workspace switcher (#6589)
fix #6499 

- fix the size of workspace switcher to 32px from 40px

![Screenshot 2024-08-09
140212](https://github.com/user-attachments/assets/425c9089-8969-4d59-82ef-10572cfa7027)

- fix alignment issues

![Screenshot 2024-08-09
142357](https://github.com/user-attachments/assets/2e3e76f2-8a81-48e9-86ff-691c11215583)

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-16 15:31:04 +02:00

20 lines
535 B
TypeScript

import { useCallback } from 'react';
import { matchPath, useLocation } from 'react-router-dom';
import { AppBasePath } from '@/types/AppBasePath';
export const useIsMatchingLocation = () => {
const location = useLocation();
return useCallback(
(path: string, basePath?: AppBasePath) => {
const constructedPath = basePath
? (new URL(basePath + path, document.location.origin).pathname ?? '')
: path;
return !!matchPath(constructedPath, location.pathname);
},
[location.pathname],
);
};