Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): align the projects page to one grid

joshistoast4d0c806c305d
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 53c70cc097..f044b05c83 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -457,7 +457,8 @@
"label": "Sort by",
"name": "Name"
},
- "unpin": "Unpin"
+ "unpin": "Unpin",
+ "viewLabel": "Project layout"
},
"users": {
"accountCount_one": "{{count}} account in this workspace.",
diff --git a/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx b/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx
index fb37633fbb..03d0d36062 100644
--- a/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx
@@ -6,17 +6,33 @@ export interface EmptyStateProps extends ChakraEmptyState.RootProps {
description?: string | null;
icon?: React.ReactNode;
danger?: boolean;
+ /**
+ * Where the block sits on its own cross axis.
+ *
+ * `center` (the default) is right inside a dialog, a panel, or anywhere the
+ * empty state is the only thing on screen. `start` is right on a page whose
+ * heading, description and toolbar are all flush left: a centered block
+ * under a left-aligned page has no shared edge with anything above it, and
+ * reads as a different screen rather than as the page's own content.
+ *
+ * `start` also drops the recipe's horizontal padding, so the text lands
+ * exactly on the page's text column. Left-aligning but staying inset would
+ * be worse than centering — a near miss reads as a mistake, where a clean
+ * center reads as a choice.
+ */
+ align?: 'center' | 'start';
}
export const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(function EmptyState(props, ref) {
- const { title, description, icon, children, danger, ...rest } = props;
+ const { title, description, icon, children, danger, align = 'center', ...rest } = props;
const fgColor = danger ? 'fg.error' : undefined;
+ const isStart = align === 'start';
return (
- <ChakraEmptyState.Root ref={ref} {...rest} size={props.size ?? 'sm'}>
- <ChakraEmptyState.Content>
+ <ChakraEmptyState.Root ref={ref} {...rest} {...(isStart ? { px: '0' } : {})} size={props.size ?? 'sm'}>
+ <ChakraEmptyState.Content alignItems={isStart ? 'flex-start' : undefined}>
{icon && <ChakraEmptyState.Indicator color={fgColor}>{icon}</ChakraEmptyState.Indicator>}
{description ? (
- <VStack textAlign="center" color={fgColor}>
+ <VStack align={isStart ? 'start' : 'center'} textAlign={isStart ? 'start' : 'center'} color={fgColor}>
<ChakraEmptyState.Title>{title}</ChakraEmptyState.Title>
<ChakraEmptyState.Description>{description}</ChakraEmptyState.Description>
</VStack>
diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectCard.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectCard.tsx
deleted file mode 100644
index db45473f88..0000000000
--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectCard.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Flex, Icon, Text } from '@chakra-ui/react';
-import { Link } from '@tanstack/react-router';
-import { PlusIcon } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-/** The library's leading cell: start a fresh draft in the editor. */
-
-const NEW_PROJECT_SEARCH = { new: true } as const;
-const LINK_STYLE = { inset: 0, position: 'absolute' } as const;
-const CARD_HOVER = { bg: 'bg.subtle', borderColor: 'border.emphasized' } as const;
-const CARD_TRANSITION =
- 'border-color var(--wb-motion-duration-medium) ease, background var(--wb-motion-duration-medium) ease';
-
-export const NewProjectCard = () => {
- const { t } = useTranslation();
-
- return (
- <Flex
- align="center"
- borderColor="border.subtle"
- borderStyle="dashed"
- borderWidth="1.5px"
- direction="column"
- gap="2"
- justify="center"
- minH="28"
- position="relative"
- rounded="lg"
- transition={CARD_TRANSITION}
- _hover={CARD_HOVER}
- >
- <Link aria-label={t('projects.createNewProject')} search={NEW_PROJECT_SEARCH} style={LINK_STYLE} to="/app" />
- <Icon as={PlusIcon} boxSize="5" color="fg.muted" />
- <Text color="fg.muted" fontSize="xs" fontWeight="600">
- {t('projects.newProject')}
- </Text>
- </Flex>
- );
-};
diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx
index ef5c7b2e5d..ff27db7efe 100644
--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx
+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx
@@ -1,19 +1,19 @@
import type { SystemStyleObject } from '@chakra-ui/react';
-import { Alert, Box, Flex, Icon, SimpleGrid, Skeleton, Stack, Text } from '@chakra-ui/react';
+import { Alert, Box, Flex, Icon, SimpleGrid, Skeleton, Text } from '@chakra-ui/react';
import { Button } from '@platform/ui/Button';
import { EmptyState } from '@platform/ui/EmptyState';
import { Scrollable } from '@platform/ui/Scrollable';
+import { Link } from '@tanstack/react-router';
import { refreshProjectLibrary, useProjectLibrarySelector } from '@workbench/projects/library';
import { useOpenProjectsSelector } from '@workbench/projects/openProjects';
-import { FolderIcon, SearchXIcon } from 'lucide-react';
+import { FolderIcon, PlusIcon, SearchXIcon } from 'lucide-react';
import { useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef } from 'react';
import { useVirtualizer } from 'react-hook-tanstack-virtual';
import { useTranslation } from 'react-i18next';
import type { ProjectGroupId, ProjectRowModel, ProjectSortId, ProjectsViewId } from './projectLibraryView';
-import { NewProjectCard } from './NewProjectCard';
import { ProjectCard } from './ProjectCard';
import { PROJECT_COVER_ASPECT_RATIO } from './ProjectCover';
import { buildProjectGroups, flattenProjectGroupsToRows } from './projectLibraryView';
@@ -57,6 +57,7 @@ const GROUP_LABEL_KEY: Record<ProjectGroupId, string> = {
const SKELETON_GRID_COLUMNS = { base: 1, lg: 3, sm: 2 } as const;
const NO_MATCHES_ICON = <Icon as={SearchXIcon} />;
const NO_PROJECTS_ICON = <Icon as={FolderIcon} />;
+const NEW_PROJECT_SEARCH = { new: true } as const;
export interface ProjectsBrowserProps {
/**
@@ -271,6 +272,16 @@ const VirtualProjectsRow = ({
);
};
+/**
+ * Both empty states align to `start`, on the same axis as the page heading,
+ * the description and the search field. A centered block under a left-aligned
+ * page shares an edge with nothing above it.
+ *
+ * The action is a button, not the dashed tile this used to render. That tile
+ * was a grid cell with no grid around it — floating at an arbitrary width, and
+ * shown even in list view — and it repeated a call to action the header
+ * already carries. A button matches what the no-matches state beside it does.
+ */
const ProjectsEmptyState = ({
isSearching,
onClearSearch,
@@ -285,6 +296,7 @@ const ProjectsEmptyState = ({
if (isSearching) {
return (
<EmptyState
+ align="start"
description={t('projects.noSearchMatchesDescription')}
icon={NO_MATCHES_ICON}
title={t('projects.noSearchMatches', { search: searchTerm.trim() })}
@@ -297,15 +309,22 @@ const ProjectsEmptyState = ({
}
return (
- <Stack gap="4">
- <EmptyState
- description={t('projects.noSavedProjectsDescription')}
- icon={NO_PROJECTS_ICON}
- title={t('projects.noSavedProjects')}
- />
- <Box maxW="xs" mx="auto" w="full">
- <NewProjectCard />
- </Box>
- </Stack>
+ <EmptyState
+ align="start"
+ description={t('projects.noSavedProjectsDescription')}
+ icon={NO_PROJECTS_ICON}
+ title={t('projects.noSavedProjects')}
+ >
+ {/* Outline, not solid: the header already carries this action as the
+ page's one accent, and repeating that weight a few hundred pixels
+ away doubles the loudest thing on an otherwise quiet screen without
+ adding a choice. */}
+ <Button asChild size="xs" variant="outline">
+ <Link search={NEW_PROJECT_SEARCH} to="/app">
+ <Icon as={PlusIcon} boxSize="3.5" />
+ {t('projects.newProject')}
+ </Link>
+ </Button>
+ </EmptyState>
);
};
diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsToolbar.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsToolbar.tsx
index 7622826bf2..5527567365 100644
--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsToolbar.tsx
+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsToolbar.tsx
@@ -1,4 +1,4 @@
-import { Flex, Icon, Input, InputGroup, Menu, Portal } from '@chakra-ui/react';
+import { Flex, Icon, Input, InputGroup, Menu, Portal, SegmentGroup } from '@chakra-ui/react';
import { Button, IconButton } from '@platform/ui/Button';
import { MenuContent } from '@platform/ui/Menu';
import { Tooltip } from '@platform/ui/Tooltip';
@@ -9,9 +9,22 @@ import { useTranslation } from 'react-i18next';
/* eslint-disable react-perf/jsx-no-jsx-as-prop */
import type { ProjectSortId, ProjectsViewId } from './projectLibraryView';
-import { PROJECT_SORT_IDS } from './projectLibraryView';
+import { isProjectsViewId, PROJECT_SORT_IDS, PROJECTS_VIEW_IDS } from './projectLibraryView';
-/** Search, ordering, and layout for the project library. */
+/**
+ * Search, ordering, and layout for the project library.
+ *
+ * The row spans the page's measure rather than packing to the left: search
+ * holds the left edge under the heading, and the controls sit on the right
+ * edge under the header's buttons. That gives the top of the page two vertical
+ * lines instead of one line and a drifting cluster.
+ *
+ * The layout choice is a `SegmentGroup`, not two adjacent icon buttons. Two
+ * buttons where one happens to be highlighted read as two actions, one of
+ * which is somehow active; a segmented control reads as one control with two
+ * positions, which is what it is. It also inherits the design system's
+ * concentric radii — `radii.sm` items inside a `radii.md` track.
+ */
const MENU_POSITIONING = { placement: 'bottom-end' } as const;
const SEARCH_ICON = <Icon as={SearchIcon} boxSize="3.5" color="fg.subtle" />;
@@ -22,6 +35,16 @@ const SORT_LABEL_KEY: Record<ProjectSortId, string> = {
name: 'projects.sort.name',
};
+const VIEW_LABEL_KEY: Record<ProjectsViewId, string> = {
+ grid: 'projects.gridView',
+ list: 'projects.listView',
+};
+
+const VIEW_ICON: Record<ProjectsViewId, typeof LayoutGridIcon> = {
+ grid: LayoutGridIcon,
+ list: ListIcon,
+};
+
export const ProjectsToolbar = ({
searchTerm,
sort,
@@ -52,8 +75,14 @@ export const ProjectsToolbar = ({
},
[onSortChange]
);
- const handleGridView = useCallback(() => onViewChange('grid'), [onViewChange]);
- const handleListView = useCallback(() => onViewChange('list'), [onViewChange]);
+ const handleViewChange = useCallback(
+ (details: { value: string | null }) => {
+ if (isProjectsViewId(details.value)) {
+ onViewChange(details.value);
+ }
+ },
+ [onViewChange]
+ );
return (
<Flex align="center" gap="2" wrap="wrap">
@@ -82,7 +111,7 @@ export const ProjectsToolbar = ({
<Menu.Root positioning={MENU_POSITIONING} onSelect={handleSortSelect}>
<Menu.Trigger asChild>
- <Button size="xs" variant="outline">
+ <Button ms="auto" size="xs" variant="outline">
<Icon as={ArrowUpDownIcon} boxSize="3.5" />
{t(SORT_LABEL_KEY[sort])}
</Button>
@@ -106,30 +135,26 @@ export const ProjectsToolbar = ({
</Portal>
</Menu.Root>
- <Flex gap="0.5">
- <Tooltip content={t('projects.gridView')}>
- <IconButton
- aria-label={t('projects.gridView')}
- aria-pressed={view === 'grid'}
- size="xs"
- variant={view === 'grid' ? 'subtle' : 'ghost'}
- onClick={handleGridView}
- >
- <Icon as={LayoutGridIcon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- <Tooltip content={t('projects.listView')}>
- <IconButton
- aria-label={t('projects.listView')}
- aria-pressed={view === 'list'}
- size="xs"
- variant={view === 'list' ? 'subtle' : 'ghost'}
- onClick={handleListView}
- >
- <Icon as={ListIcon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- </Flex>
+ <SegmentGroup.Root aria-label={t('projects.viewLabel')} size="xs" value={view} onValueChange={handleViewChange}>
+ <SegmentGroup.Indicator />
+ {PROJECTS_VIEW_IDS.map((id) => (
+ <SegmentGroup.Item key={id} px="2" value={id}>
+ {/* The hidden radio is the control, so it carries the name — the
+ visible label is an icon with no text of its own. */}
+ <SegmentGroup.ItemHiddenInput aria-label={t(VIEW_LABEL_KEY[id])} />
+ <SegmentGroup.ItemText display="flex">
+ {/* The tooltip wraps the icon, never the item: `Tooltip.Trigger`
+ is `asChild` and merges its own `data-state` onto whatever it
+ clones, which on the item overwrites `data-state="checked"` —
+ the selected segment then styles as unselected and the
+ indicator measures 0×0. */}
+ <Tooltip content={t(VIEW_LABEL_KEY[id])}>
+ <Icon as={VIEW_ICON[id]} boxSize="3.5" />
+ </Tooltip>
+ </SegmentGroup.ItemText>
+ </SegmentGroup.Item>
+ ))}
+ </SegmentGroup.Root>
</Flex>
);
};