Skip to content

Commit c1b34e1

Browse files
cursoragenthipsterusername
authored andcommitted
Standardize UI spacing and constants across canvas and image components
Co-authored-by: kent <kent@invoke.ai>
1 parent 89f1684 commit c1b34e1

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

invokeai/frontend/web/src/features/controlLayers/konva/CanvasStagingAreaModule.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import type { Atom } from 'nanostores';
1111
import { atom, effect } from 'nanostores';
1212
import type { Logger } from 'roarr';
1313

14+
// Theme-consistent spacing constants (in pixels)
15+
const SPACING_2 = 8; // Equivalent to theme token 2
16+
const SPACING_4 = 16; // Equivalent to theme token 4
17+
const SPACING_8 = 32; // Equivalent to theme token 8
18+
const BORDER_RADIUS_BASE = 6; // Equivalent to theme borderRadius "base"
19+
const BORDER_WIDTH = 1; // Standard border width
20+
const FONT_SIZE_SM = 14; // Equivalent to theme fontSize "sm"
21+
const BADGE_MIN_WIDTH = 200;
22+
const BADGE_HEIGHT = 36;
23+
1424
type ImageNameSrc = { type: 'imageName'; data: string };
1525
type DataURLSrc = { type: 'dataURL'; data: string };
1626

@@ -74,28 +84,28 @@ export class CanvasStagingAreaModule extends CanvasModuleBase {
7484
badgeBg: new Konva.Rect({
7585
name: `${this.type}:placeholder_badge_bg`,
7686
fill: 'hsl(220 12% 10% / 0.8)', // 'base.900' with opacity
77-
x: 6,
78-
y: 6,
79-
width: Math.min(204, width - 12),
80-
height: 36,
81-
cornerRadius: 6,
87+
x: SPACING_2 - 2, // Slight offset for visual balance
88+
y: SPACING_2 - 2,
89+
width: Math.min(BADGE_MIN_WIDTH + 4, width - (SPACING_2 * 2) + 4),
90+
height: BADGE_HEIGHT,
91+
cornerRadius: BORDER_RADIUS_BASE,
8292
stroke: 'hsl(220 12% 50% / 1)', // 'base.700'
83-
strokeWidth: 1,
93+
strokeWidth: BORDER_WIDTH,
8494
listening: false,
8595
perfectDrawEnabled: false,
8696
}),
8797
text: new Konva.Text({
8898
name: `${this.type}:placeholder_text`,
8999
fill: 'hsl(220 12% 80% / 1)', // 'base.300'
90-
x: 8,
91-
y: 8,
92-
width: Math.min(200, width - 16),
93-
height: 32,
100+
x: SPACING_2,
101+
y: SPACING_2,
102+
width: Math.min(BADGE_MIN_WIDTH, width - SPACING_4),
103+
height: SPACING_8,
94104
align: 'center',
95105
verticalAlign: 'middle',
96106
fontFamily: '"Inter Variable", sans-serif',
97-
fontSize: 14,
98-
fontStyle: '600',
107+
fontSize: FONT_SIZE_SM,
108+
fontStyle: '600', // Equivalent to theme fontWeight "semibold"
99109
text: 'Waiting for Image',
100110
listening: false,
101111
perfectDrawEnabled: false,
@@ -141,8 +151,8 @@ export class CanvasStagingAreaModule extends CanvasModuleBase {
141151
const { width, height } = this.manager.stateApi.getBbox().rect;
142152
this.konva.placeholder.rect.width(width);
143153
this.konva.placeholder.rect.height(height);
144-
this.konva.placeholder.badgeBg.width(Math.min(204, width - 12));
145-
this.konva.placeholder.text.width(Math.min(200, width - 16));
154+
this.konva.placeholder.badgeBg.width(Math.min(BADGE_MIN_WIDTH + 4, width - (SPACING_2 * 2) + 4));
155+
this.konva.placeholder.text.width(Math.min(BADGE_MIN_WIDTH, width - SPACING_4));
146156
};
147157

148158
initialize = () => {

invokeai/frontend/web/src/features/gallery/components/ImageViewer/ProgressImage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ export const ProgressImage = memo(() => {
4646
borderColor="base.700"
4747
borderWidth={1}
4848
bg="base.900"
49-
opacity={0.8}
49+
opacity="0.8"
5050
fontSize="sm"
5151
fontWeight="semibold"
52-
zIndex={1}
52+
zIndex="docked"
5353
pointerEvents="none"
54+
borderRadius="base"
5455
>
5556
Waiting for Image
5657
</Badge>

0 commit comments

Comments
 (0)