Skip to content

Commit f51014e

Browse files
feat(ui): make launchpad button its own component
1 parent 9862ba9 commit f51014e

File tree

2 files changed

+43
-69
lines changed

2 files changed

+43
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Button, Flex, Heading, Icon, Text } from '@invoke-ai/ui-library';
2+
import { memo } from 'react';
3+
import type { IconType } from 'react-icons';
4+
5+
export const LaunchpadButton = memo(
6+
(props: { onClick: () => void; icon: IconType; title: string; description: string }) => {
7+
const { onClick, icon, title, description } = props;
8+
9+
return (
10+
<Button onClick={onClick} variant="outline" p={4} textAlign="left" flexDir="column" gap={2} h="unset">
11+
<Flex alignItems="center" gap={4} w="full">
12+
<Icon as={icon} boxSize={8} color="base.300" />
13+
<Heading size="sm" color="base.100">
14+
{title}
15+
</Heading>
16+
</Flex>
17+
<Text lineHeight="1.4" flex="1" whiteSpace="normal" wordBreak="break-word">
18+
{description}
19+
</Text>
20+
</Button>
21+
);
22+
}
23+
);
24+
25+
LaunchpadButton.displayName = 'LaunchpadButton';

invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/LaunchpadForm/LaunchpadForm.tsx

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Flex, Grid, Heading, Icon, Text } from '@invoke-ai/ui-library';
1+
import { Button, Flex, Grid, Heading, Text } from '@invoke-ai/ui-library';
22
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent';
33
import { map } from 'es-toolkit/compat';
44
import { setInstallModelsTabByName } from 'features/modelManagerV2/store/installModelsStore';
@@ -10,6 +10,8 @@ import { PiFolderOpenBold, PiLinkBold, PiStarBold } from 'react-icons/pi';
1010
import { SiHuggingface } from 'react-icons/si';
1111
import { useGetStarterModelsQuery } from 'services/api/endpoints/models';
1212

13+
import { LaunchpadButton } from './LaunchpadButton';
14+
1315
export const LaunchpadForm = memo(() => {
1416
const { t } = useTranslation();
1517
const { data: starterModelsData } = useGetStarterModelsQuery();
@@ -43,77 +45,24 @@ export const LaunchpadForm = memo(() => {
4345
<Flex flexDir="column" gap={2} alignItems="flex-start">
4446
<Heading size="sm">{t('modelManager.launchpad.manualInstall')}</Heading>
4547
<Grid templateColumns="repeat(auto-fit, minmax(280px, 1fr))" gap={3} w="full">
46-
<Button
48+
<LaunchpadButton
4749
onClick={navigateToUrlTab}
48-
variant="outline"
49-
p={4}
50-
textAlign="left"
51-
flexDir="column"
52-
gap={2}
53-
h="unset"
54-
>
55-
<Flex alignItems="center" gap={4} w="full">
56-
<Icon as={PiLinkBold} boxSize={8} color="base.300" />
57-
<Heading size="sm" color="base.100">
58-
{t('modelManager.urlOrLocalPath')}
59-
</Heading>
60-
</Flex>
61-
<Text lineHeight="1.4" flex="1" whiteSpace="normal" wordBreak="break-word">
62-
{t('modelManager.launchpad.urlDescription')}
63-
</Text>
64-
</Button>
65-
<Button
50+
icon={PiLinkBold}
51+
title={t('modelManager.urlOrLocalPath')}
52+
description={t('modelManager.launchpad.urlDescription')}
53+
/>
54+
<LaunchpadButton
6655
onClick={navigateToHuggingFaceTab}
67-
variant="outline"
68-
p={4}
69-
textAlign="left"
70-
flexDir="column"
71-
gap={2}
72-
h="unset"
73-
>
74-
<Flex alignItems="center" gap={4} w="full">
75-
<Icon as={SiHuggingface} boxSize={8} color="base.300" />
76-
<Heading size="sm" color="base.100">
77-
{t('modelManager.huggingFace')}
78-
</Heading>
79-
</Flex>
80-
<Text
81-
fontSize="sm"
82-
color="base.400"
83-
lineHeight="1.4"
84-
flex="1"
85-
whiteSpace="normal"
86-
wordBreak="break-word"
87-
>
88-
{t('modelManager.launchpad.huggingFaceDescription')}
89-
</Text>
90-
</Button>
91-
<Button
56+
icon={SiHuggingface}
57+
title={t('modelManager.huggingFace')}
58+
description={t('modelManager.launchpad.huggingFaceDescription')}
59+
/>
60+
<LaunchpadButton
9261
onClick={navigateToScanFolderTab}
93-
variant="outline"
94-
p={4}
95-
textAlign="left"
96-
flexDir="column"
97-
gap={2}
98-
h="unset"
99-
>
100-
<Flex alignItems="center" gap={4} w="full">
101-
<Icon as={PiFolderOpenBold} boxSize={8} color="base.300" />
102-
<Heading size="sm" color="base.100">
103-
{t('modelManager.scanFolder')}
104-
</Heading>
105-
</Flex>
106-
<Text
107-
fontSize="sm"
108-
color="base.400"
109-
lineHeight="1.4"
110-
flex="1"
111-
whiteSpace="normal"
112-
wordBreak="break-word"
113-
>
114-
{t('modelManager.launchpad.scanFolderDescription')}
115-
</Text>
116-
</Button>
62+
icon={PiFolderOpenBold}
63+
title={t('modelManager.scanFolder')}
64+
description={t('modelManager.launchpad.scanFolderDescription')}
65+
/>
11766
</Grid>
11867
</Flex>
11968
{/* Recommended Section */}

0 commit comments

Comments
 (0)