Skip to content
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

Group headers styling enhancements #37

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/core/src/common/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export function makeCSSStyle(theme: Theme): Record<string, string> {
"--gdg-bg-header": theme.bgHeader,
"--gdg-bg-header-has-focus": theme.bgHeaderHasFocus,
"--gdg-bg-header-hovered": theme.bgHeaderHovered,
"--gdg-bg-group-header": theme.bgGroupHeader ?? theme.bgHeader,
"--gdg-bg-group-header-hovered": theme.bgGroupHeaderHovered ?? theme.bgHeaderHovered,
"--gdg-bg-bubble": theme.bgBubble,
"--gdg-bg-bubble-selected": theme.bgBubbleSelected,
"--gdg-bg-search-result": theme.bgSearchResult,
Expand Down Expand Up @@ -66,6 +68,8 @@ export interface Theme {
bgHeader: string;
bgHeaderHasFocus: string;
bgHeaderHovered: string;
bgGroupHeader?: string;
bgGroupHeaderHovered?: string;
bgBubble: string;
bgBubbleSelected: string;
bgSearchResult: string;
Expand Down Expand Up @@ -109,6 +113,8 @@ const dataEditorBaseTheme: Theme = {
bgHeader: "#F7F7F8",
bgHeaderHasFocus: "#E9E9EB",
bgHeaderHovered: "#EFEFF1",
bgGroupHeader: "#F7F7F8",
bgGroupHeaderHovered: "#EFEFF1",

bgBubble: "#EDEDF3",
bgBubbleSelected: "#FFFFFF",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/docs/08-theming.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ The global theme is provided by the DataEditor by default and can be overriden b
| bgCell | --gdg-bg-cell | string | The primary background color of the data grid. |
| bgCellMedium | --gdg-bg-cell-medium | string | Used for disabled or otherwise off colored cells. |
| bgHeader | --gdg-bg-header | string | The header background color |
| bgGroupHeader | --gdg-bg-group-header | string \\| undefined | The group header background color, if none provided the \`bgHeader\` is used instead. |
| bgHeaderHasFocus | --gdg-bg-header-has | string | The header background color when its column contains the selected cell |
| bgHeaderHovered | --gdg-bg-header-hovered | string | The header background color when it is hovered |
| bgGroupHeaderHovered | --gdg-bg-group-header-hovered | string \\| undefined | The group header background color when it is hovered, if none provided the \`bgHeaderHovered\` is used instead. |
| bgBubble | --gdg-bg-bubble | string | The background color used in bubbles |
| bgBubbleSelected | --gdg-bg-bubble-selected | string | The background color used in bubbles when the cell is selected |
| bgSearchResult | --gdg-bg-search-result | string | The background color used for cells which match the search string |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export function drawGroups(
group?.overrideTheme === undefined ? theme : mergeAndRealizeTheme(theme, group.overrideTheme);
const isHovered = hRow === -2 && hCol !== undefined && hCol >= span[0] && hCol <= span[1];

const fillColor = isHovered ? groupTheme.bgHeaderHovered : groupTheme.bgHeader;
const fillColor = isHovered
? groupTheme.bgGroupHeaderHovered ?? groupTheme.bgHeaderHovered
: groupTheme.bgGroupHeader ?? groupTheme.bgHeader;
if (fillColor !== theme.bgHeader) {
ctx.fillStyle = fillColor;
ctx.fill();
Expand Down Expand Up @@ -262,7 +264,7 @@ export function drawGroups(
ctx.beginPath();
ctx.moveTo(x + 0.5, 0);
ctx.lineTo(x + 0.5, groupHeaderHeight);
ctx.strokeStyle = theme.borderColor;
ctx.strokeStyle = groupTheme.borderColor ?? theme.borderColor;
ctx.lineWidth = 1;
ctx.stroke();
}
Expand Down
Loading