Skip to content

Commit

Permalink
docs: update the table column resizing example to align with the visu…
Browse files Browse the repository at this point in the history
…al specifications (#872)

* docs: update the table column resizing example to align with the visual specification

* docs: update example for table column resizing on hover

* docs: update minimum table column width to 80px
  • Loading branch information
cheton authored Jun 11, 2024
1 parent 6c6d3ec commit 4d3e26a
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const App = () => {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle();
const dividerColor = {
dark: 'gray:70',
light: 'gray:30',
dark: 'gray:50',
light: 'gray:50',
}[colorMode];
const highlightedDividerColor = {
dark: 'gray:50',
Expand Down Expand Up @@ -75,7 +75,9 @@ const App = () => {
bottom: 0,
borderLeft: 1,
borderLeftColor: isResizing ? highlightedDividerColor : dividerColor,
opacity: 0.6,
_hover: {
opacity: 1,
borderLeftColor: highlightedDividerColor,
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
state: {
columnOrder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const App = () => {
data: items,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getCoreRowModel: getCoreRowModel(),
getRowId: row => row.id, //good to have guaranteed unique row ids/keys for rendering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const App = () => {
onChange={row.getToggleSelectedHandler()}
/>
),
minSize: 48,
size: 48,
style: {
px: '4x',
Expand Down Expand Up @@ -131,7 +132,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 48,
minSize: 80,
},
state: {
rowSelection,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docs/pages/components/table/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getCoreRowModel: getCoreRowModel(),
getRowId: (originalRow, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getCoreRowModel: getCoreRowModel(),
getRowId: (originalRow, index) => {
Expand Down Expand Up @@ -122,7 +122,7 @@ const App = () => {
size: Math.max(
percentageWidth, // percentage of table width
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
}
Expand All @@ -148,7 +148,7 @@ const App = () => {
id,
size: Math.max(
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
state: {
columnOrder,
Expand Down Expand Up @@ -261,7 +261,7 @@ const App = () => {
size: Math.max(
percentageWidth, // percentage of table width
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
}
Expand All @@ -287,7 +287,7 @@ const App = () => {
id,
size: Math.max(
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
});
Expand Down
13 changes: 8 additions & 5 deletions packages/react-docs/pages/components/table/column-resizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
columnResizeMode,
getCoreRowModel: getCoreRowModel(),
Expand All @@ -100,7 +100,7 @@ const App = () => {
});

const layout = 'flexbox'; // One of: 'flexbox', 'table'
const variant = 'outline'; // One of: 'default', 'outline'
const variant = 'default'; // One of: 'default', 'outline'

return (
<>
Expand Down Expand Up @@ -147,8 +147,8 @@ const App = () => {
// ResizeHandle
const resizeHandleSX = (() => {
const dividerColor = {
dark: 'gray:70',
light: 'gray:30',
dark: 'gray:50',
light: 'gray:50',
}[colorMode];
const highlightedDividerColor = {
dark: 'gray:50',
Expand All @@ -163,12 +163,15 @@ const App = () => {
position: 'absolute',
top: (variant === 'outline') ? -1 : 0,
right: -1 * (isResizingColumn ? dividerWidth + translucentWidth : hoverableWidth),
height: isResizingColumn ? tableHeight : 36,
height: isResizingColumn ? tableHeight : '9x',
zIndex: 1,

borderLeft: dividerWidth,
borderLeftColor: isResizingColumn ? highlightedDividerColor : dividerColor,
opacity: isResizingColumn ? 1 : 0,
_hover: {
height: tableHeight,
opacity: 1,
borderLeftColor: highlightedDividerColor,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
state: {
columnOrder,
Expand Down Expand Up @@ -175,7 +175,7 @@ const App = () => {
size: Math.max(
percentageWidth, // percentage of table width
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
}
Expand All @@ -201,7 +201,7 @@ const App = () => {
id,
size: Math.max(
textWidth + gutterWidth, // text width with padding
minSize, // minimum size (e.g. 40px)
minSize, // minimum size (e.g. 80px)
),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
state: {
columnVisibility,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docs/pages/components/table/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
Expand Down
3 changes: 2 additions & 1 deletion packages/react-docs/pages/components/table/row-expanding.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const App = () => {
/>
);
},
minSize: 48,
size: 48,
},
{
Expand Down Expand Up @@ -168,7 +169,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getRowCanExpand: () => true,
getCoreRowModel: getCoreRowModel(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const App = () => {
onChange={row.getToggleSelectedHandler()}
/>
),
minSize: 48,
size: 48,
style: {
px: '4x',
Expand Down Expand Up @@ -172,7 +173,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 48,
minSize: 80,
},
state: {
rowSelection,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-docs/pages/components/table/row-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const App = () => {
onChange={row.getToggleSelectedHandler()}
/>
),
minSize: 48,
size: 48,
style: {
px: '4x',
Expand Down Expand Up @@ -101,7 +102,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 48,
minSize: 80,
},
state: {
rowSelection,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docs/pages/components/table/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
state: {
sorting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const App = () => {
data,
columns,
defaultColumn: {
minSize: 40,
minSize: 80,
},
getCoreRowModel: getCoreRowModel(),
getRowId: (originalRow, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const App = () => {
/>
);
},
minSize: 48,
size: 48,
},
{
Expand Down Expand Up @@ -133,7 +134,7 @@ const App = () => {
], [colorMode, colorStyle]); // Include both colorMode and colorStyle as dependencies to prevent memoization when the color mode changes
const tableOptions = useMemo(() => ({
defaultColumn: {
minSize: 48,
minSize: 80,
},
getExpandedRowModel: getExpandedRowModel(),
getRowCanExpand: () => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const App = () => {
onChange={row.getToggleSelectedHandler()}
/>
),
minSize: 48,
size: 48,
},
{
Expand Down Expand Up @@ -219,7 +220,7 @@ const App = () => {

const tableOptions = useMemo(() => ({
defaultColumn: {
minSize: 48,
minSize: 80,
},
state: {
rowSelection,
Expand Down

0 comments on commit 4d3e26a

Please sign in to comment.