Skip to content

Commit cd7837e

Browse files
committed
refinements for scaling
1 parent b8ea2d4 commit cd7837e

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

src/TecanDeckView/LabwareDetailItem.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ const CONTAINER_STYLE = {
2626
export function LabwareDetailItem({
2727
backgroundColor = PALETTE.white,
2828
content,
29-
scaleFactor,
3029
shortLabel,
3130
}: {
3231
shortLabel: string;
3332
content: React.ReactElement;
34-
scaleFactor: number;
3533
backgroundColor?: string;
3634
}) {
3735
return (
@@ -43,7 +41,7 @@ export function LabwareDetailItem({
4341
boxShadow: `0 2px 4px ${PALETTE.black}1a`,
4442
}}
4543
>
46-
<div style={{ zoom: scaleFactor }}>{content}</div>
44+
{content}
4745
<div style={LABEL_STYLE}>{shortLabel}</div>
4846
</div>
4947
);

src/TecanDeckView/TecanDeckView.tsx

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3333
const 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

Comments
 (0)