-
Notifications
You must be signed in to change notification settings - Fork 351
feat: draw grid lines for selected rows cols #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -499,7 +499,7 @@ export interface DataEditorProps extends Props, Pick<DataGridSearchProps, "image | |||||||||||
readonly gridSelection?: GridSelection; | ||||||||||||
/** | ||||||||||||
* Emitted whenever the grid selection changes. Specifying | ||||||||||||
* this function will make the grid’s selection controlled, so | ||||||||||||
* this function will make the grid's selection controlled, so | ||||||||||||
* so you will need to specify {@link gridSelection} as well. See | ||||||||||||
* the "Controlled Selection" example for details. | ||||||||||||
* | ||||||||||||
|
@@ -686,6 +686,22 @@ export interface DataEditorProps extends Props, Pick<DataGridSearchProps, "image | |||||||||||
* Allows overriding the default portal element. | ||||||||||||
*/ | ||||||||||||
readonly portalElementRef?: React.RefObject<HTMLElement>; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* When true (default) draws accent-coloured grid lines around selected columns in the header. Set to false to | ||||||||||||
* revert to the original behaviour where only the header background is accented. | ||||||||||||
* @group Style | ||||||||||||
* @defaultValue true | ||||||||||||
*/ | ||||||||||||
readonly columnSelectionGridLines?: boolean; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* When true (default) draws accent-coloured grid lines around selected rows in the header. Set to false to | ||||||||||||
* revert to the original behaviour where only the header background is accented. | ||||||||||||
* @group Style | ||||||||||||
* @defaultValue true | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation incorrectly states 'true (default)' but the actual default value is false as shown in line 912. The comment should say 'When true draws accent-coloured grid lines...' and '@DefaultValue false'.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
*/ | ||||||||||||
readonly rowSelectionGridLines?: boolean; | ||||||||||||
} | ||||||||||||
|
||||||||||||
type ScrollToFn = ( | ||||||||||||
|
@@ -892,6 +908,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr | |||||||||||
scrollToActiveCell = true, | ||||||||||||
drawFocusRing: drawFocusRingIn = true, | ||||||||||||
portalElementRef, | ||||||||||||
columnSelectionGridLines = false, | ||||||||||||
rowSelectionGridLines = false, | ||||||||||||
} = p; | ||||||||||||
|
||||||||||||
const drawFocusRing = drawFocusRingIn === "no-editor" ? overlay === undefined : drawFocusRingIn; | ||||||||||||
|
@@ -4264,6 +4282,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr | |||||||||||
gridRef={gridRef} | ||||||||||||
getCellRenderer={getCellRenderer} | ||||||||||||
resizeIndicator={resizeIndicator} | ||||||||||||
columnSelectionGridLines={columnSelectionGridLines} | ||||||||||||
rowSelectionGridLines={rowSelectionGridLines} | ||||||||||||
/> | ||||||||||||
{renameGroupNode} | ||||||||||||
{overlay !== undefined && ( | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||
import React from "react"; | ||||||
import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; | ||||||
import { | ||||||
BeautifulWrapper, | ||||||
Description, | ||||||
MoreInfo, | ||||||
useMockDataGenerator, | ||||||
defaultProps, | ||||||
} from "../../data-editor/stories/utils.js"; | ||||||
import { SimpleThemeWrapper } from "../../stories/story-utils.js"; | ||||||
|
||||||
export default { | ||||||
title: "Glide-Data-Grid/DataEditor Demos", | ||||||
|
||||||
decorators: [ | ||||||
(Story: React.ComponentType) => ( | ||||||
<SimpleThemeWrapper> | ||||||
<BeautifulWrapper | ||||||
title="Column & Row Selection Grid Lines" | ||||||
description={ | ||||||
<> | ||||||
<Description> | ||||||
Demonstrates the <code>columnSelectionGridLines</code> and | ||||||
<code>rowSelectionGridLines</code> props which control whether accent-coloured grid | ||||||
lines are drawn around selected columns and rows. | ||||||
</Description> | ||||||
<MoreInfo> | ||||||
Use the story controls to toggle the behaviours on and off. | ||||||
</MoreInfo> | ||||||
</> | ||||||
}> | ||||||
<Story /> | ||||||
</BeautifulWrapper> | ||||||
</SimpleThemeWrapper> | ||||||
), | ||||||
], | ||||||
}; | ||||||
|
||||||
interface SelectionGridLineProps { | ||||||
columnSelectionGridLines: boolean; | ||||||
rowSelectionGridLines: boolean; | ||||||
} | ||||||
|
||||||
export const SelectionGridLine: React.FC<SelectionGridLineProps> = p => { | ||||||
const { cols, getCellContent } = useMockDataGenerator(10); | ||||||
return ( | ||||||
<DataEditor | ||||||
{...defaultProps} | ||||||
getCellContent={getCellContent} | ||||||
columns={cols} | ||||||
rows={1000} | ||||||
columnSelectionGridLines={p.columnSelectionGridLines} | ||||||
rowSelectionGridLines={p.rowSelectionGridLines} | ||||||
rowMarkers="both" | ||||||
/> | ||||||
); | ||||||
}; | ||||||
|
||||||
(SelectionGridLine as any).args = { | ||||||
columnSelectionGridLines: true, | ||||||
rowSelectionGridLines: true, | ||||||
}; | ||||||
|
||||||
(SelectionGridLine as any).argTypes = { | ||||||
columnSelectionGridLines: { | ||||||
control: { | ||||||
type: "boolean", | ||||||
}, | ||||||
}, | ||||||
rowSelectionGridLines: { | ||||||
control: { | ||||||
type: "boolean", | ||||||
}, | ||||||
}, | ||||||
}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Trailing whitespace at the end of the file. Consider removing the space after the semicolon.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly states 'true (default)' but the actual default value is false as shown in line 911. The comment should say 'When true draws accent-coloured grid lines...' and '@DefaultValue false'.
Copilot uses AI. Check for mistakes.