Skip to content

Commit e5dc606

Browse files
fix(ui): get accurate theme tokens
1 parent dc6b8e1 commit e5dc606

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ 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"
14+
// To get pixel sizes corresponding to our theme tokens, first find the theme token CSS var in browser dev tools.
15+
// For example `var(--invoke-space-8)` is equivalent to using `8` as a space prop in a component.
16+
//
17+
// If it is already in pixels, you can use it directly. If it is in rems, you need to convert it to pixels.
18+
//
19+
// For example:
20+
// const style = window.getComputedStyle(document.documentElement)
21+
// parseFloat(style.fontSize) * parseFloat(style.getPropertyValue("--invoke-space-8"))
22+
//
23+
// 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"
1928
const BORDER_WIDTH = 1; // Standard border width
20-
const FONT_SIZE_SM = 14; // Equivalent to theme fontSize "sm"
29+
const FONT_SIZE_SM = 12; // Equivalent to theme fontSize "sm"
2130
const BADGE_MIN_WIDTH = 200;
2231
const BADGE_HEIGHT = 36;
2332

0 commit comments

Comments
 (0)