Skip to content

Commit 5db69ad

Browse files
Adds prettier and comment.
1 parent a859860 commit 5db69ad

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

src/components/Grid/Cell.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ import { StyledCell } from "./StyledCell";
55

66
type CellProps = GridChildComponentProps<ItemDataType> & {
77
width: number;
8-
}
8+
};
99

1010
export const Cell = memo(
11-
({
12-
data,
13-
rowIndex,
14-
columnIndex,
15-
style,
16-
...props
17-
}: CellProps) => {
11+
({ data, rowIndex, columnIndex, style, ...props }: CellProps) => {
1812
const {
1913
cell: CellData,
2014
getSelectionType,
@@ -59,7 +53,7 @@ export const Cell = memo(
5953

6054
const selectionBorderLeft = rightOfSelectionBorder || rightOfFocus || isFocused;
6155
const selectionBorderTop = belowSelectionBorder || belowFocus || isFocused;
62-
console.log("Only row? ",rowCount === 1 )
56+
console.log("Only row? ", rowCount === 1);
6357
return (
6458
<div
6559
style={style}

src/components/Grid/Grid.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -777,15 +777,17 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
777777
}, [rowStart, onItemsRendered]);
778778

779779
const CellWithWidth = (args: GridChildComponentProps<ItemDataType>): JSX.Element => {
780-
const width = columnWidth(args.columnIndex);
781-
return (
782-
<Cell
783-
{...args}
784-
width={width}
785-
/>
786-
);
787-
};
780+
const width = columnWidth(args.columnIndex);
781+
return (
782+
<Cell
783+
{...args}
784+
width={width}
785+
/>
786+
);
787+
};
788788

789+
// Handles the case when rowCount changes, expanding the cell height
790+
// to fit content if there is only one row.
789791
useEffect(() => {
790792
if (gridRef.current) {
791793
gridRef.current.resetAfterRowIndex(0);
@@ -794,11 +796,10 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
794796

795797
const getRowHeight = useCallback(
796798
(index: number, parentHeight: number): number => {
797-
798799
if (rowCount === 1 && index === 0) {
799-
return parentHeight - rowHeight*2;
800+
return parentHeight - rowHeight * 2;
800801
}
801-
802+
802803
return rowHeight;
803804
},
804805
[rowCount, rowHeight]
@@ -858,7 +859,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
858859
>
859860
{CellWithWidth}
860861
</VariableSizeGrid>
861-
)}
862+
)}
862863
</AutoSizer>
863864
</ContextMenuTrigger>
864865
<ContextMenu.Content>

src/components/Grid/StyledCell.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ export const StyledCell = styled.div<{
8989
`
9090
: "border-right: none;"
9191
}
92-
${
93-
$isOnlyRow
94-
&& "border: none;"
95-
}
92+
${$isOnlyRow && "border: none;"}
9693
`}
9794
${({
9895
theme,
@@ -102,7 +99,7 @@ export const StyledCell = styled.div<{
10299
$type = "body",
103100
$isSelectedTop,
104101
$isSelectedLeft,
105-
$isOnlyRow
102+
$isOnlyRow,
106103
}) =>
107104
$isSelectedTop ||
108105
$isSelectedLeft ||
@@ -136,10 +133,7 @@ export const StyledCell = styled.div<{
136133
? `border-right: 1px solid ${theme.click.grid[$type].cell.color.stroke.selectDirect};`
137134
: ""
138135
}
139-
${
140-
$isOnlyRow
141-
&& "border: none;"
142-
}
136+
${$isOnlyRow && "border: none;"}
143137
}
144138
`
145139
: ""};

0 commit comments

Comments
 (0)