Skip to content

Commit 28096cb

Browse files
ibdafnagaborbernat
authored andcommitted
Fix FeatherGrid styling
Signed-off-by: Itay Dafna <[email protected]>
1 parent 11b83fc commit 28096cb

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

js/feathergrid.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
150150
const isMenuRow =
151151
(hit.region === 'column-header' &&
152152
hit.row ==
153-
this._grid.grid.dataModel!.rowCount('column-header') - 1) ||
153+
this._grid.grid.dataModel!.rowCount('column-header') - 1) ||
154154
(hit.region === 'corner-header' && hit.row === 0);
155155

156156
const isMenuClick =
@@ -559,11 +559,6 @@ export class FeatherGrid extends Widget {
559559
}
560560

561561
public setGridStyle(): void {
562-
// Resetting grid style if theme changes.
563-
if (this.backboneModel) {
564-
this.grid.style = this.backboneModel.get('grid_style');
565-
}
566-
567562
// Setting up theme.
568563
const scrollShadow = {
569564
size: 4,
@@ -572,6 +567,30 @@ export class FeatherGrid extends Widget {
572567
color3: Theme.getBorderColor(1, 0.0),
573568
};
574569

570+
// Resetting grid style if theme changes.
571+
if (this.backboneModel) {
572+
this.grid.style = this.backboneModel.get('grid_style');
573+
}
574+
// Always apply FeatherGrid Theme
575+
// if not rendered in ipydatagrid.
576+
else {
577+
this.grid.style = {
578+
voidColor: Theme.getBackgroundColor(),
579+
backgroundColor: Theme.getBackgroundColor(),
580+
gridLineColor: Theme.getBorderColor(),
581+
headerGridLineColor: Theme.getBorderColor(1),
582+
selectionFillColor: Theme.getBrandColor(2, 0.4),
583+
selectionBorderColor: Theme.getBrandColor(1),
584+
headerSelectionFillColor: Theme.getBackgroundColor(3, 0.4),
585+
headerSelectionBorderColor: Theme.getBorderColor(1),
586+
cursorFillColor: Theme.getBrandColor(3, 0.4),
587+
cursorBorderColor: Theme.getBrandColor(1),
588+
scrollShadow,
589+
};
590+
// Terminate call here if rendering outside ipydatagrid.
591+
return;
592+
}
593+
575594
this.grid.style = {
576595
voidColor: this.grid.style.voidColor || Theme.getBackgroundColor(),
577596
backgroundColor:
@@ -609,7 +628,9 @@ export class FeatherGrid extends Widget {
609628
public updateGridStyle(): void {
610629
this.setGridStyle();
611630

612-
if (!this._defaultRendererSet) {
631+
// If we are not rendering with ipydatagrid,
632+
// defaultRenderer needs to be set each time.
633+
if (!this._defaultRendererSet || !this.backboneModel) {
613634
this.defaultRenderer = new TextRenderer({
614635
font: '12px sans-serif',
615636
textColor: Theme.getFontColor(),
@@ -887,8 +908,8 @@ export class FeatherGrid extends Widget {
887908
return this._renderers.hasOwnProperty(columnName)
888909
? this._renderers[columnName]
889910
: cellRegion === 'row-header'
890-
? this._rowHeaderRenderer
891-
: this._defaultRenderer;
911+
? this._rowHeaderRenderer
912+
: this._defaultRenderer;
892913
}
893914

894915
private _updateGridRenderers() {

0 commit comments

Comments
 (0)