@@ -17,17 +17,17 @@ import {
1717 TecanLabwares ,
1818} from './types' ;
1919
20- // Responsive scaling constants
21- const GRID_PADDING = 8 ; // Padding around the grid container (from style.padding)
22- const GRID_GAP = 8 ; // Gap between grid cells (from style.gap)
23- const COLUMN_COUNT = 5 ; // Number of columns in the grid
24- const GRID_OVERHEAD = GRID_PADDING * 2 + GRID_GAP * ( COLUMN_COUNT - 1 ) ; // Total space used by padding and gaps
25- const COLUMN_OVERHEAD = 60 ; // Estimated width per column for borders and padding
26- const BASE_CONTENT_WIDTH = 1400 ; // Designed content width at 1.0 scale factor
27- const SCALE_SAFETY_MARGIN = 0.95 ; // 5% safety margin to prevent overflow
28- const MIN_SCALE_FACTOR = 0.1 ; // Minimum scale to keep content readable
29- const MAX_SCALE_FACTOR = 1.0 ; // Maximum scale (100% of designed size)
30- const INITIAL_SCALE_FACTOR = 0.7 ; // Initial scale before container width is measured
20+ // Scaling constants for fit-to-width behavior
21+ const GRID_PADDING = 8 ;
22+ const GRID_GAP = 8 ;
23+ const COLUMN_COUNT = 5 ;
24+ const GRID_OVERHEAD = GRID_PADDING * 2 + GRID_GAP * ( COLUMN_COUNT - 1 ) ;
25+ const COLUMN_OVERHEAD = 60 ;
26+ const BASE_CONTENT_WIDTH = 1400 ;
27+ const SCALE_SAFETY_MARGIN = 0.95 ;
28+ const MIN_SCALE_FACTOR = 0.1 ;
29+ const MAX_SCALE_FACTOR = 1.0 ;
30+ const INITIAL_SCALE_FACTOR = 0.7 ;
3131
3232// Static styles
3333const CONTAINER_STYLE = {
@@ -75,9 +75,7 @@ export function TecanDeckView({ labwares }: { labwares: TecanLabwares }) {
7575
7676 React . useEffect ( ( ) => {
7777 const container = containerRef . current ;
78- if ( ! container ) {
79- return ;
80- }
78+ if ( ! container ) return ;
8179
8280 const updateWidth = ( ) => {
8381 setAvailableWidth ( container . offsetWidth ) ;
@@ -94,9 +92,7 @@ export function TecanDeckView({ labwares }: { labwares: TecanLabwares }) {
9492 } , [ ] ) ;
9593
9694 React . useEffect ( ( ) => {
97- if ( availableWidth === undefined ) {
98- return ;
99- }
95+ if ( availableWidth === undefined ) return ;
10096
10197 const totalColumnOverhead = COLUMN_OVERHEAD * COLUMN_COUNT ;
10298 const availableContentWidth =
@@ -152,7 +148,6 @@ export function TecanDeckView({ labwares }: { labwares: TecanLabwares }) {
152148 < LabwareDetailItem
153149 shortLabel = { labware . shortLabel }
154150 content = { labware . content }
155- scaleFactor = { scaleFactor }
156151 backgroundColor = { labware . color }
157152 />
158153 ) : (
@@ -161,7 +156,13 @@ export function TecanDeckView({ labwares }: { labwares: TecanLabwares }) {
161156
162157 return (
163158 < div ref = { containerRef } style = { CONTAINER_STYLE } >
164- < div style = { GRID_CONTAINER_STYLE } >
159+ < div
160+ style = { {
161+ ...GRID_CONTAINER_STYLE ,
162+ transform : `scale(${ scaleFactor } )` ,
163+ transformOrigin : 'top left' ,
164+ } }
165+ >
165166 < div style = { LEFT_COLUMN_STYLE } >
166167 { leftColumnLabwares . map ( ( labware ) => (
167168 < div key = { labware . key } > { renderLabware ( labware ) } </ div >
0 commit comments