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.

feat(ui): render controls that name no size at the md working size

Josh Corbett9223aa698d31
diff --git a/invokeai/frontend/webv2/src/features/identity/ui/AuthUnavailableScreen.tsx b/invokeai/frontend/webv2/src/features/identity/ui/AuthUnavailableScreen.tsx
index c5c58ee22f..8ee9c876e3 100644
--- a/invokeai/frontend/webv2/src/features/identity/ui/AuthUnavailableScreen.tsx
+++ b/invokeai/frontend/webv2/src/features/identity/ui/AuthUnavailableScreen.tsx
@@ -13,7 +13,9 @@ export const AuthUnavailableScreen = ({ onRetry }: { onRetry: () => Promise<void
return (
<AuthScreen subtitle={t('widgets.serverStatus.disconnected')} title={t('common.somethingWentWrong')}>
- <Button onClick={handleRetry}>{t('common.retry')}</Button>
+ <Button size="lg" onClick={handleRetry}>
+ {t('common.retry')}
+ </Button>
</AuthScreen>
);
};
diff --git a/invokeai/frontend/webv2/src/features/identity/ui/LoginScreen.tsx b/invokeai/frontend/webv2/src/features/identity/ui/LoginScreen.tsx
index 9349d2b5f8..93e6ae1090 100644
--- a/invokeai/frontend/webv2/src/features/identity/ui/LoginScreen.tsx
+++ b/invokeai/frontend/webv2/src/features/identity/ui/LoginScreen.tsx
@@ -72,6 +72,7 @@ export const LoginScreen = () => {
autoComplete="email"
autoFocus
placeholder="[email protected]"
+ size="lg"
value={form.values.email}
onChange={handleEmailChange}
/>
@@ -81,6 +82,7 @@ export const LoginScreen = () => {
aria-invalid={form.errors.password ? true : undefined}
autoComplete="current-password"
placeholder={t('auth.yourPassword')}
+ size="lg"
value={form.values.password}
onChange={handlePasswordChange}
/>
diff --git a/invokeai/frontend/webv2/src/features/identity/ui/SetupScreen.tsx b/invokeai/frontend/webv2/src/features/identity/ui/SetupScreen.tsx
index 6e15a9b0b0..f10d599377 100644
--- a/invokeai/frontend/webv2/src/features/identity/ui/SetupScreen.tsx
+++ b/invokeai/frontend/webv2/src/features/identity/ui/SetupScreen.tsx
@@ -71,6 +71,7 @@ export const SetupScreen = () => {
autoComplete="email"
autoFocus
placeholder="[email protected]"
+ size="lg"
value={form.values.email}
onChange={handleEmailChange}
/>
@@ -79,6 +80,7 @@ export const SetupScreen = () => {
<Input
autoComplete="name"
placeholder={t('auth.administrator')}
+ size="lg"
value={form.values.displayName}
onChange={handleDisplayNameChange}
/>
@@ -92,6 +94,7 @@ export const SetupScreen = () => {
<PasswordInput
aria-invalid={form.errors.password ? true : undefined}
autoComplete="new-password"
+ size="lg"
value={form.values.password}
onChange={handlePasswordChange}
/>
@@ -102,6 +105,7 @@ export const SetupScreen = () => {
<PasswordInput
aria-invalid={form.errors.confirmPassword ? true : undefined}
autoComplete="new-password"
+ size="lg"
value={form.values.confirmPassword}
onChange={handleConfirmPasswordChange}
/>
diff --git a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
index fea58cbe96..726790efee 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
@@ -93,7 +93,7 @@ export const ModelSelect = ({
placeholder,
scopeLabel: scopeLabelOverride,
showManagerButton = true,
- size = 'lg',
+ size = 'md',
value,
}: {
className?: string;
diff --git a/invokeai/frontend/webv2/src/platform/ui/Button.tsx b/invokeai/frontend/webv2/src/platform/ui/Button.tsx
index 8fde079cc5..5629c318d3 100644
--- a/invokeai/frontend/webv2/src/platform/ui/Button.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/Button.tsx
@@ -38,8 +38,8 @@ export const IconButton = ({ colorPalette, ...props }: IconButtonProps) => (
<ChakraIconButton colorPalette={colorPalette ?? defaultPalette(props.variant)} {...props} />
);
-/** Chakra defaults close buttons to a full `xl` control; dismissal chrome here is small and muted. */
-export const CloseButton = (props: CloseButtonProps) => <ChakraCloseButton color="fg.muted" size="md" {...props} />;
+/** Dismissal chrome is muted. */
+export const CloseButton = (props: CloseButtonProps) => <ChakraCloseButton color="fg.muted" {...props} />;
export interface ToggleIconButtonProps extends Omit<
IconButtonProps,
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/ControlHeights.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/theme/ControlHeights.browser.test.tsx
index 82c992c01f..ddbb8a6332 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/ControlHeights.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/ControlHeights.browser.test.tsx
@@ -28,7 +28,7 @@ afterEach(async () => {
root = null;
});
-const renderControls = async (size: ControlSize): Promise<Record<string, HTMLElement>> => {
+const renderControls = async (size?: ControlSize): Promise<Record<string, HTMLElement>> => {
host = document.createElement('div');
document.body.append(host);
root = createRoot(host);
@@ -87,4 +87,12 @@ describe('control heights', () => {
}
});
});
+
+ it('renders controls that name no size at md', async () => {
+ const controls = await renderControls();
+
+ for (const [id, element] of Object.entries(controls)) {
+ expect(element.getBoundingClientRect().height, id).toBeCloseTo(CONTROL_HEIGHT_PX.md, 1);
+ }
+ });
});
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/rebase.test.ts b/invokeai/frontend/webv2/src/platform/ui/theme/rebase.test.ts
index 0395170ce9..6e6d059caa 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/rebase.test.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/rebase.test.ts
@@ -10,6 +10,7 @@ const theme = baseConfig.theme!;
type TextStyleValue = { fontSize: string; letterSpacing?: string; lineHeight: string };
type StyleRecord = Record<string, Record<string, string>>;
+type AnyDefaults = { defaultVariants?: Record<string, unknown> };
type StockRecipe = { base?: StyleRecord; variants?: { size?: Record<string, StyleRecord> } };
const stockRecipe = (name: string): StockRecipe =>
@@ -113,8 +114,6 @@ describe('rebaseRecipe', () => {
expect(renamed?.md).toMatchObject({ h: stock.xs!.h, textStyle: 'md' });
expect(renamed?.['3xl']).toMatchObject({ h: stock.lg!.h, textStyle: 'xl' });
expect(Object.keys(renamed ?? {})).not.toContain('2xs');
- // Bare buttons keep their stock size until callers move to the workbench default.
- expect(recipes.button.defaultVariants).toMatchObject({ size: 'xl' });
});
// The theme pins button, input, select, combobox, and segment heights itself; these keep their stock heights, so
@@ -142,6 +141,19 @@ describe('rebaseRecipe', () => {
}
});
+ it('defaults rescaled recipes to the working size', () => {
+ for (const name of ['badge', 'button', 'input', 'select', 'spinner', 'switch'] as const) {
+ expect(
+ (recipes as Record<string, AnyDefaults>)[name] ?? (slotRecipes as Record<string, AnyDefaults>)[name],
+ name
+ ).toMatchObject({ defaultVariants: { size: 'md' } });
+ }
+ // Headings follow the type scale; icons inherit their font size; tabs have no md step.
+ expect(recipes.heading.defaultVariants).toMatchObject({ size: '3xl' });
+ expect(recipes.icon.defaultVariants).toMatchObject({ size: 'inherit' });
+ expect(slotRecipes.tabs.defaultVariants).toMatchObject({ size: '2xl' });
+ });
+
it('renames fonts in stock recipes it does not resize', () => {
expect(slotRecipes.tooltip.base?.content).toMatchObject({ textStyle: 'md' });
expect(stockRecipe('tooltip').base?.content).toMatchObject({ textStyle: 'xs' });
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/rebase.ts b/invokeai/frontend/webv2/src/platform/ui/theme/rebase.ts
index b6626b8340..3756a754bb 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/rebase.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/rebase.ts
@@ -63,7 +63,7 @@ export const SIZE_NAMES: Readonly<Record<string, NameMap>> = {
button: { '2xs': 'sm', xs: 'md', sm: 'lg', md: 'xl', lg: '3xl' },
checkbox: ONE_STEP,
checkmark: ONE_STEP,
- code: TWO_STEPS,
+ code: ONE_STEP,
colorPicker: { '2xs': 'md', xs: 'lg', sm: 'xl', md: '2xl', lg: '3xl' },
combobox: { xs: 'md', sm: 'lg', md: 'xl' },
dataList: ONE_STEP,
@@ -179,8 +179,25 @@ export const rebaseRecipe = <T extends AnyRecipe>(name: string, recipe: T, sizes
};
};
+/**
+ * Rescaled recipes default to `md`, the working size, so a control that names no size is already dense. Heading
+ * follows the type scale, and recipes without an `md` step or with a non-scale default (icon's `inherit`) keep theirs.
+ */
+const withWorkingDefault = <T extends AnyRecipe>(name: string, recipe: T): T =>
+ name !== 'heading' &&
+ SIZE_NAMES[name] &&
+ recipe.variants?.size?.md &&
+ SCALE_NAMES.has(String(recipe.defaultVariants?.size))
+ ? { ...recipe, defaultVariants: { ...recipe.defaultVariants, size: 'md' } }
+ : recipe;
+
const rebaseAll = <T extends AnyRecipe>(all: Record<string, T>): Record<string, T> =>
- Object.fromEntries(Object.entries(all).map(([name, recipe]) => [name, rebaseRecipe(name, recipe, SIZE_NAMES[name])]));
+ Object.fromEntries(
+ Object.entries(all).map(([name, recipe]) => [
+ name,
+ withWorkingDefault(name, rebaseRecipe(name, recipe, SIZE_NAMES[name])),
+ ])
+ );
export const recipes = rebaseAll<RecipeDefinition>(stockRecipes) as Record<keyof typeof stockRecipes, RecipeDefinition>;
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index 6643a0c29a..b0d230b4e0 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -327,10 +327,6 @@ export const segmentGroupSlotRecipe = defineSlotRecipe({
SEGMENT_BASIS
),
} as unknown as typeof chakraSlotRecipes.segmentGroup.variants,
- defaultVariants: {
- ...chakraSlotRecipes.segmentGroup.defaultVariants,
- size: 'md',
- },
});
const formControlFocused = {
@@ -518,10 +514,6 @@ export const menuSlotRecipe = defineSlotRecipe({
bg: 'border.subtle',
},
},
- defaultVariants: {
- ...chakraSlotRecipes.menu.defaultVariants,
- size: 'md',
- },
});
export const selectSlotRecipe = defineSlotRecipe({
@@ -833,10 +825,6 @@ export const colorPickerSlotRecipe = defineSlotRecipe({
borderRadius: 'inherit',
},
},
- defaultVariants: {
- ...chakraSlotRecipes.colorPicker.defaultVariants,
- size: 'lg',
- },
});
/**
diff --git a/invokeai/frontend/webv2/src/workbench/components/WorkbenchUnavailableScreen.tsx b/invokeai/frontend/webv2/src/workbench/components/WorkbenchUnavailableScreen.tsx
index f0857c2da5..0e457b53ba 100644
--- a/invokeai/frontend/webv2/src/workbench/components/WorkbenchUnavailableScreen.tsx
+++ b/invokeai/frontend/webv2/src/workbench/components/WorkbenchUnavailableScreen.tsx
@@ -105,20 +105,20 @@ export const WorkbenchUnavailableScreen = ({
<Heading size="3xl">{t('shell.backendUnavailable.title')}</Heading>
<Text color="fg.muted">{t('shell.backendUnavailable.description')}</Text>
</Stack>
- <Alert.Root status="error" variant="surface">
+ <Alert.Root size="lg" status="error" variant="surface">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>{t('shell.backendUnavailable.connectionFailed')}</Alert.Title>
<Alert.Description overflowWrap="anywhere">{message}</Alert.Description>
</Alert.Content>
</Alert.Root>
- <Button alignSelf="start" onClick={onRetry}>
+ <Button alignSelf="start" size="lg" onClick={onRetry}>
{t('shell.backendUnavailable.retry')}
</Button>
<Stack gap="3">
<Heading size="xl">{t('shell.backendUnavailable.draftsTitle')}</Heading>
{draftError ? (
- <Alert.Root status="error" variant="surface">
+ <Alert.Root size="lg" status="error" variant="surface">
<Alert.Indicator />
<Alert.Content>
<Alert.Description>{draftError}</Alert.Description>
diff --git a/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecoveryNotice.tsx b/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecoveryNotice.tsx
index 249763f837..1264ab6984 100644
--- a/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecoveryNotice.tsx
+++ b/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecoveryNotice.tsx
@@ -167,7 +167,7 @@ export const QueueRecoveryNotice = ({
}
if (query.data?.kind === 'unavailable' || query.isError) {
return (
- <Alert.Root borderRadius="none" status="warning" variant="surface">
+ <Alert.Root borderRadius="none" size="lg" status="warning" variant="surface">
<Alert.Indicator />
<Alert.Content>
<Alert.Title>{t('shell.queueRecovery.storageUnavailableTitle')}</Alert.Title>
@@ -182,7 +182,7 @@ export const QueueRecoveryNotice = ({
return (
<>
- <Alert.Root borderRadius="none" status="warning" variant="surface">
+ <Alert.Root borderRadius="none" size="lg" status="warning" variant="surface">
<Alert.Indicator />
<Alert.Content>
<HStack align="center" flexWrap="wrap" gap="4" justify="space-between" w="full">
diff --git a/invokeai/frontend/webv2/src/workbench/shell/ProjectConflictBanner.tsx b/invokeai/frontend/webv2/src/workbench/shell/ProjectConflictBanner.tsx
index 8520e61b7b..9340844e21 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/ProjectConflictBanner.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/ProjectConflictBanner.tsx
@@ -199,7 +199,7 @@ export const ProjectConflictBanner = () => {
return (
<>
{recoverableDraft ? (
- <Alert.Root borderRadius="none" status="warning" variant="surface">
+ <Alert.Root borderRadius="none" size="lg" status="warning" variant="surface">
<Alert.Indicator />
<Alert.Content>
<HStack align="center" gap="4" justify="space-between" w="full">
@@ -261,7 +261,12 @@ export const ProjectConflictBanner = () => {
</Alert.Root>
) : null}
{hasProjectAlert ? (
- <Alert.Root borderRadius="none" status={conflict || schemaRefusal ? 'warning' : 'info'} variant="surface">
+ <Alert.Root
+ borderRadius="none"
+ size="lg"
+ status={conflict || schemaRefusal ? 'warning' : 'info'}
+ variant="surface"
+ >
<Alert.Indicator />
<Alert.Content>
<HStack align="center" gap="4" justify="space-between" w="full">