* fix: several Navigation Bar and Drawer fixes Fixes #2821 - Fix navigation drawer animations - Fix navigation bar positioning - Do not display navigation drawer collapse button on mobile - Refactor code and rename componentst * Fix storybook test * fix: fix NavigationDrawerHeader elements space-between --------- Co-authored-by: Charles Bochet <charles@twenty.com>
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import styled from '@emotion/styled';
|
|
|
|
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
|
|
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
|
|
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
|
|
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
|
|
import { Avatar } from '@/users/components/Avatar';
|
|
|
|
import { useFavorites } from '../hooks/useFavorites';
|
|
|
|
const StyledContainer = styled.div`
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow-x: auto;
|
|
width: 100%;
|
|
`;
|
|
|
|
export const Favorites = () => {
|
|
const { favorites, handleReorderFavorite } = useFavorites({
|
|
objectNamePlural: 'companies',
|
|
});
|
|
|
|
if (!favorites || favorites.length === 0) return <></>;
|
|
|
|
return (
|
|
<StyledContainer>
|
|
<NavigationDrawerSectionTitle label="Favorites" />
|
|
<DraggableList
|
|
onDragEnd={handleReorderFavorite}
|
|
draggableItems={
|
|
<>
|
|
{favorites.map((favorite, index) => {
|
|
const {
|
|
id,
|
|
labelIdentifier,
|
|
avatarUrl,
|
|
avatarType,
|
|
link,
|
|
recordId,
|
|
} = favorite;
|
|
|
|
return (
|
|
<DraggableItem
|
|
key={id}
|
|
draggableId={id}
|
|
index={index}
|
|
itemComponent={
|
|
<NavigationDrawerItem
|
|
key={id}
|
|
label={labelIdentifier}
|
|
Icon={() => (
|
|
<Avatar
|
|
colorId={recordId}
|
|
avatarUrl={avatarUrl}
|
|
type={avatarType}
|
|
placeholder={labelIdentifier}
|
|
/>
|
|
)}
|
|
to={link}
|
|
/>
|
|
}
|
|
/>
|
|
);
|
|
})}
|
|
</>
|
|
}
|
|
/>
|
|
</StyledContainer>
|
|
);
|
|
};
|