Skip to content

Commit edae6d2

Browse files
committed
refactor: address PR review comments
- Use Array.from().map() instead of repetitive array literals in grid calculation functions - Fix storybook action import: use 'storybook/actions' instead of 'storybook/test' in both Plate and Table stories - Add ROW_COUNT constant for consistency with COLUMN_COUNT - Restore action() usage in Plate stories for drag-and-drop demo Addresses review comments from spawnia in PR #315
1 parent 79800a8 commit edae6d2

3 files changed

Lines changed: 10 additions & 21 deletions

File tree

src/Plate/index.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StoryFn } from '@storybook/react-webpack5';
22
import React from 'react';
3+
import { action } from 'storybook/actions';
34

45
import { PALETTE } from '../theme';
56

@@ -91,10 +92,7 @@ const Template: StoryFn<Partial<PlateProps<CoordinateSystem12x8>>> =
9192
data={null}
9293
coordinateSystem={COORDINATE_SYSTEM_12X8}
9394
dndContextProps={{
94-
onDragEnd: () => {
95-
// Handle drag end event
96-
// Access data via event parameter if needed: const sourceData = e.active.data.current; const targetData = e.over?.data.current;
97-
},
95+
onDragEnd: action('onDragEnd'), // dataLocation: `const sourceData = e.active.data.current; const targetData = e.over?.data.current;`
9896
}}
9997
{...args}
10098
/>

src/Table/index.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StoryFn } from '@storybook/react-webpack5';
22
import React, { useState } from 'react';
3-
import { action } from 'storybook/test';
3+
import { action } from 'storybook/actions';
44

55
import { THEME } from '../theme';
66

src/TecanDeckView/TecanDeckView.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
const GRID_PADDING = 8;
2525
const GRID_GAP = 8;
2626
const COLUMN_COUNT = 5;
27+
const ROW_COUNT = 3;
2728
const GRID_OVERHEAD = GRID_PADDING * 2 + GRID_GAP * (COLUMN_COUNT - 1);
2829
const COLUMN_OVERHEAD = 60;
2930
const BASE_CONTENT_WIDTH = 1400;
@@ -71,27 +72,17 @@ const RIGHT_COLUMN_STYLE = {
7172
function calculateGridTemplateColumns(labwares: TecanLabwares): string {
7273
const filledByColumn = getFilledLabwaresByColumn(labwares);
7374

74-
const columnSizes = [
75-
(filledByColumn[0]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
76-
(filledByColumn[1]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
77-
(filledByColumn[2]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
78-
(filledByColumn[3]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
79-
(filledByColumn[4]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
80-
];
81-
82-
return columnSizes.join(' ');
75+
return Array.from({ length: COLUMN_COUNT }, (_, i) =>
76+
(filledByColumn[i]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
77+
).join(' ');
8378
}
8479

8580
function calculateGridTemplateRows(labwares: TecanLabwares): string {
8681
const filledByRow = getFilledLabwaresByRow(labwares);
8782

88-
const rowSizes = [
89-
(filledByRow[0]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
90-
(filledByRow[1]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
91-
(filledByRow[2]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
92-
];
93-
94-
return rowSizes.join(' ');
83+
return Array.from({ length: ROW_COUNT }, (_, i) =>
84+
(filledByRow[i]?.length ?? 0) > 0 ? 'auto' : 'minmax(40px, 60px)',
85+
).join(' ');
9586
}
9687

9788
export function TecanDeckView({ labwares }: { labwares: TecanLabwares }) {

0 commit comments

Comments
 (0)