Skip to content

Commit a8d5a56

Browse files
authored
fix(styling): styling fixes for cell renderers (#1526)
* fix(styling): styling fixes for cell renderers
1 parent 7230275 commit a8d5a56

File tree

5 files changed

+26
-47
lines changed

5 files changed

+26
-47
lines changed

projects/components/src/table/cells/data-renderers/string-array/string-array-table-cell-renderer.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
display: flex;
88
flex-direction: row;
99
align-items: center;
10+
justify-content: space-between;
1011

1112
&.first-column {
1213
@include body-1-medium($gray-9);

projects/components/src/table/cells/data-renderers/string-array/string-array-table-cell-renderer.component.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { FormattingModule } from '@hypertrace/common';
2-
import { TableCellNoOpParser } from '@hypertrace/components';
2+
import { TableCellNoOpParser, XMoreComponent } from '@hypertrace/components';
33
import { createComponentFactory } from '@ngneat/spectator/jest';
4+
import { MockComponent } from 'ng-mocks';
45
import { tableCellDataProvider, tableCellProviders } from '../../test/cell-providers';
56
import { StringArrayTableCellRendererComponent } from './string-array-table-cell-renderer.component';
67

78
describe('String array table cell renderer component', () => {
89
const buildComponent = createComponentFactory({
910
component: StringArrayTableCellRendererComponent,
11+
declarations: [MockComponent(XMoreComponent)],
1012
imports: [FormattingModule],
1113
providers: [
1214
tableCellProviders(
@@ -26,7 +28,7 @@ describe('String array table cell renderer component', () => {
2628
});
2729

2830
expect(spectator.query('.first-item')).toHaveText('first-item');
29-
expect(spectator.query('.summary-text')).toHaveText('');
31+
expect(spectator.query(XMoreComponent)?.count).toBe(0);
3032
});
3133

3234
test('should render an empty array as expected', () => {
@@ -35,7 +37,7 @@ describe('String array table cell renderer component', () => {
3537
});
3638

3739
expect(spectator.query('.first-item')).toHaveText('-');
38-
expect(spectator.query('.summary-text')).toHaveText('');
40+
expect(spectator.query(XMoreComponent)?.count).toBe(0);
3941
});
4042

4143
test('should render array with multiple items as expected', () => {
@@ -44,6 +46,6 @@ describe('String array table cell renderer component', () => {
4446
});
4547

4648
expect(spectator.query('.first-item')).toHaveText('first-item');
47-
expect(spectator.query('.summary-text')).toHaveText('+2');
49+
expect(spectator.query(XMoreComponent)?.count).toBe(2);
4850
});
4951
});
Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
2-
import { TableColumnConfig, TableRow } from '../../../table-api';
3-
import {
4-
TABLE_CELL_DATA,
5-
TABLE_COLUMN_CONFIG,
6-
TABLE_COLUMN_INDEX,
7-
TABLE_DATA_PARSER,
8-
TABLE_ROW_DATA
9-
} from '../../table-cell-injection';
10-
import { TableCellParserBase } from '../../table-cell-parser-base';
1+
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2+
import { XMoreDisplay } from '../../../../x-more/x-more.component';
113
import { TableCellRenderer } from '../../table-cell-renderer';
124
import { TableCellRendererBase } from '../../table-cell-renderer-base';
135
import { CoreTableCellParserType } from '../../types/core-table-cell-parser-type';
@@ -20,8 +12,8 @@ import { TableCellAlignmentType } from '../../types/table-cell-alignment-type';
2012
changeDetection: ChangeDetectionStrategy.OnPush,
2113
template: `
2214
<div class="string-array-cell" [htTooltip]="summaryTooltip">
23-
<span class="first-item">{{ this.firstItem | htDisplayString }}</span>
24-
<span class="summary-text">{{ this.summaryText }}</span>
15+
<span class="first-item">{{ this.value[0] | htDisplayString }}</span>
16+
<ht-x-more [count]="(this.value | slice: 1).length" displayStyle="${XMoreDisplay.Gray}"></ht-x-more>
2517
2618
<ng-template #summaryTooltip>
2719
<div *ngFor="let value of this.value">{{ value }}</div>
@@ -34,24 +26,4 @@ import { TableCellAlignmentType } from '../../types/table-cell-alignment-type';
3426
alignment: TableCellAlignmentType.Left,
3527
parser: CoreTableCellParserType.NoOp
3628
})
37-
export class StringArrayTableCellRendererComponent extends TableCellRendererBase<string[]> implements OnInit {
38-
public firstItem!: string;
39-
public summaryText!: string;
40-
41-
public constructor(
42-
@Inject(TABLE_COLUMN_CONFIG) columnConfig: TableColumnConfig,
43-
@Inject(TABLE_COLUMN_INDEX) index: number,
44-
@Inject(TABLE_DATA_PARSER) parser: TableCellParserBase<string[], string[], unknown>,
45-
@Inject(TABLE_CELL_DATA) cellData: string[],
46-
@Inject(TABLE_ROW_DATA) rowData: TableRow
47-
) {
48-
super(columnConfig, index, parser, cellData, rowData);
49-
}
50-
51-
public ngOnInit(): void {
52-
super.ngOnInit();
53-
54-
this.firstItem = this.value[0];
55-
this.summaryText = this.value.length > 1 ? `+${this.value.length - 1}` : '';
56-
}
57-
}
29+
export class StringArrayTableCellRendererComponent extends TableCellRendererBase<string[]> implements OnInit {}

projects/components/src/table/cells/table-cells.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FilterModalModule } from '../../filtering/filter-modal/filter-modal.mod
1010
import { IconModule } from '../../icon/icon.module';
1111
import { PopoverModule } from '../../popover/popover.module';
1212
import { TooltipModule } from '../../tooltip/tooltip.module';
13+
import { XMoreModule } from '../../x-more/x-more.module';
1314
import { TableHeaderCellRendererComponent } from '../header/table-header-cell-renderer.component';
1415
import { TableCellBooleanParser } from './data-parsers/table-cell-boolean-parser';
1516
import { TableCellIconParser } from './data-parsers/table-cell-icon-parser';
@@ -53,7 +54,8 @@ export const TABLE_CELL_PARSERS = new InjectionToken<unknown[][]>('TABLE_CELL_PA
5354
FilterButtonModule,
5455
FilterModalModule,
5556
PopoverModule,
56-
CopyToClipboardModule
57+
CopyToClipboardModule,
58+
XMoreModule
5759
],
5860
exports: [
5961
TableHeaderCellRendererComponent,
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
@import 'color-palette';
1+
@import 'mixins';
22

33
.ht-x-more {
4+
@include body-2-regular($gray-7);
5+
46
.summary-text {
57
padding: 0 6px;
68
margin-left: 8px;
79
border-radius: 4px;
8-
}
910

10-
.plain {
11-
color: $gray-7;
12-
margin-left: 0px;
13-
background-color: white;
14-
}
11+
&.plain {
12+
color: $gray-7;
13+
margin-left: 0;
14+
background-color: white;
15+
}
1516

16-
.gray {
17-
background-color: $gray-2;
17+
&.gray {
18+
background-color: $gray-2;
19+
}
1820
}
1921
}

0 commit comments

Comments
 (0)