Skip to content

Commit 5d236ae

Browse files
fix(ui): canvas staging waiting for image placeholder sizing and layout
1 parent e5dc606 commit 5d236ae

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ import type { Logger } from 'roarr';
2121
// parseFloat(style.fontSize) * parseFloat(style.getPropertyValue("--invoke-space-8"))
2222
//
2323
// This will give you the pixel value for the theme token in pixels.
24-
const SPACING_2 = 6; // Equivalent to theme token 2
25-
const SPACING_4 = 12; // Equivalent to theme token 4
26-
const SPACING_8 = 24; // Equivalent to theme token 8
27-
const BORDER_RADIUS_BASE = 4; // Equivalent to theme borderRadius "base"
28-
const BORDER_WIDTH = 1; // Standard border width
29-
const FONT_SIZE_SM = 12; // Equivalent to theme fontSize "sm"
30-
const BADGE_MIN_WIDTH = 200;
24+
//
25+
// You cannot do this dynamically in this file, because it depends on the styles being applied to the document, which
26+
// will not have happened yet when this module is loaded.
27+
28+
const SPACING_4 = 12; // --invoke-space-4 in pixels
29+
const BORDER_RADIUS_BASE = 4; // --invoke-radii-base in pixels
30+
const BORDER_WIDTH = 1;
31+
const FONT_SIZE_MD = 14.4; // --invoke-fontSizes-md
32+
const BADGE_WIDTH = 192;
3133
const BADGE_HEIGHT = 36;
3234

3335
type ImageNameSrc = { type: 'imageName'; data: string };
@@ -93,9 +95,9 @@ export class CanvasStagingAreaModule extends CanvasModuleBase {
9395
badgeBg: new Konva.Rect({
9496
name: `${this.type}:placeholder_badge_bg`,
9597
fill: 'hsl(220 12% 10% / 0.8)', // 'base.900' with opacity
96-
x: SPACING_2 - 2, // Slight offset for visual balance
97-
y: SPACING_2 - 2,
98-
width: Math.min(BADGE_MIN_WIDTH + 4, width - SPACING_2 * 2 + 4),
98+
x: SPACING_4,
99+
y: SPACING_4,
100+
width: BADGE_WIDTH,
99101
height: BADGE_HEIGHT,
100102
cornerRadius: BORDER_RADIUS_BASE,
101103
stroke: 'hsl(220 12% 50% / 1)', // 'base.700'
@@ -106,14 +108,14 @@ export class CanvasStagingAreaModule extends CanvasModuleBase {
106108
text: new Konva.Text({
107109
name: `${this.type}:placeholder_text`,
108110
fill: 'hsl(220 12% 80% / 1)', // 'base.300'
109-
x: SPACING_2,
110-
y: SPACING_2,
111-
width: Math.min(BADGE_MIN_WIDTH, width - SPACING_4),
112-
height: SPACING_8,
111+
x: SPACING_4,
112+
y: SPACING_4,
113+
width: BADGE_WIDTH,
114+
height: BADGE_HEIGHT,
113115
align: 'center',
114116
verticalAlign: 'middle',
115117
fontFamily: '"Inter Variable", sans-serif',
116-
fontSize: FONT_SIZE_SM,
118+
fontSize: FONT_SIZE_MD,
117119
fontStyle: '600', // Equivalent to theme fontWeight "semibold"
118120
text: 'Waiting for Image',
119121
listening: false,

0 commit comments

Comments
 (0)