Skip to content

Commit 7111bc0

Browse files
committed
do not have a function returning
a compoenent inside a component
1 parent 8662165 commit 7111bc0

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { SingleTabProps } from '@/ui/layout/tab/components/TabList';
2+
import { useTheme } from '@emotion/react';
3+
import { isDefined } from 'twenty-shared/utils';
4+
import { Avatar } from 'twenty-ui/display';
5+
6+
export const TabAvatar = ({ tab }: { tab: SingleTabProps }) => {
7+
const theme = useTheme();
8+
if (isDefined(tab.logo)) {
9+
return <Avatar avatarUrl={tab.logo} size="md" placeholder={tab.title} />;
10+
}
11+
return (
12+
<Avatar
13+
Icon={tab.Icon}
14+
size="md"
15+
placeholder={tab.title}
16+
iconColor={
17+
tab.disabled ? theme.font.color.tertiary : theme.font.color.secondary
18+
}
19+
/>
20+
);
21+
};

packages/twenty-front/src/modules/ui/layout/tab/components/TabListDropdown.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
22
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
33
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
4+
import { TabAvatar } from '@/ui/layout/tab/components/TabAvatar';
45
import { SingleTabProps } from '@/ui/layout/tab/components/TabList';
56
import { TabMoreButton } from '@/ui/layout/tab/components/TabMoreButton';
6-
import { useTheme } from '@emotion/react';
7-
import { Avatar } from 'twenty-ui/display';
87
import { MenuItemSelectAvatar } from 'twenty-ui/navigation';
98

109
type TabListDropdownProps = {
@@ -32,7 +31,6 @@ export const TabListDropdown = ({
3231
loading,
3332
}: TabListDropdownProps) => {
3433
const hiddenTabs = tabs.visible.slice(overflow.firstHiddenTabIndex);
35-
const theme = useTheme();
3634

3735
return (
3836
<Dropdown
@@ -51,29 +49,12 @@ export const TabListDropdown = ({
5149
<DropdownMenuItemsContainer>
5250
{hiddenTabs.map((tab) => {
5351
const isDisabled = tab.disabled ?? loading;
54-
const avatar = tab.logo ? (
55-
<Avatar
56-
avatarUrl={tab.logo}
57-
size="md"
58-
placeholder={tab.title}
59-
/>
60-
) : tab.Icon ? (
61-
<Avatar
62-
Icon={tab.Icon}
63-
size="md"
64-
placeholder={tab.title}
65-
iconColor={
66-
tab.disabled
67-
? theme.font.color.tertiary
68-
: theme.font.color.secondary
69-
}
70-
/>
71-
) : null;
52+
7253
return (
7354
<MenuItemSelectAvatar
7455
key={tab.id}
7556
text={tab.title}
76-
avatar={avatar}
57+
avatar={<TabAvatar tab={tab} />}
7758
selected={tab.id === tabs.activeId}
7859
onClick={isDisabled ? undefined : () => onTabSelect(tab.id)}
7960
disabled={isDisabled}

0 commit comments

Comments
 (0)