Skip to content

Commit 0275fc5

Browse files
authored
Merge pull request #3156 from perspective-dev/label-bar
Add `LabelBar` datagrid mode
2 parents 41250b2 + 8247970 commit 0275fc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1103
-1058
lines changed

packages/viewer-d3fc/src/ts/plugin/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class HTMLPerspectiveViewerD3fcPluginElement extends HTMLElement {
524524
* causes non-cleared redraws duplicate column labels when calculating column name
525525
* resize/repositions - see `treemapLabel.js`.
526526
*/
527-
async resize(view) {
527+
async resize(_view) {
528528
if (this.offsetParent !== null) {
529529
if (this._settings?.data !== undefined) {
530530
this._draw();
@@ -536,13 +536,13 @@ class HTMLPerspectiveViewerD3fcPluginElement extends HTMLElement {
536536
}
537537
}
538538

539-
async restyle(view, _end_col, _end_row) {
539+
async restyle(view) {
540540
let settings = this._settings;
541541
if (settings) {
542542
delete settings["colorStyles"];
543543
delete settings["textStyles"];
544544
if (this.isConnected) {
545-
initialiseStyles(this._container, this._settings);
545+
initialiseStyles(this._container, settings);
546546
this.resize(view);
547547
}
548548
}

packages/viewer-d3fc/src/ts/tooltip/selectionEvent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ export const raiseEvent = (node, data, settings) => {
2727
[],
2828
[{ filter }],
2929
);
30+
31+
if (node.tagName !== "PERSPECTIVE-VIEWER") {
32+
node = node.getRootNode().host.parentElement;
33+
}
34+
3035
node.dispatchEvent(
31-
new CustomEvent("perspective-select", {
36+
new CustomEvent("perspective-global-filter", {
3237
bubbles: true,
3338
composed: true,
3439
detail,

packages/viewer-datagrid/src/css/regular_table.css

Lines changed: 72 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,18 @@ perspective-viewer,
9797
cursor: pointer;
9898
}
9999

100-
.psp-row-selected,
101-
:hover .psp-row-selected,
102-
:hover th.psp-tree-leaf.psp-row-selected,
103-
:hover th.psp-tree-label.psp-row-selected {
104-
color: white !important;
105-
background-color: var(--selected-row--background-color, #ea7319) !important;
106-
border-color: var(--selected-row--background-color, #ea7319) !important;
107-
}
108-
109100
regular-table.flat-group-rollup-mode.vertical-row-headers
110101
th.psp-tree-label:not(:last-of-type) {
111102
writing-mode: vertical-lr;
112103
}
113104

114-
.psp-row-selected.psp-tree-label:not(:hover):before {
115-
color: white;
116-
}
117-
118-
regular-table:not(.flat-group-rollup-mode)
119-
.psp-row-selected.psp-tree-label:not(:hover):before {
120-
color: white;
121-
}
122-
123-
.psp-row-subselected,
124-
:hover .psp-row-subselected,
125-
:hover th.psp-tree-leaf.psp-row-subselected,
126-
:hover th.psp-tree-label.psp-row-subselected {
127-
background: rgba(234, 115, 25, 0.2) !important;
105+
.psp-select-region-inactive,
106+
:hover .psp-select-region-inactive,
107+
:hover th.psp-tree-leaf.psp-select-region-inactive,
108+
:hover th.psp-tree-label.psp-select-region-inactive {
109+
background-color: var(--psp-inactive--color) !important;
110+
color: var(--psp--background-color) !important;
111+
border-color: var(--psp--background-color) !important;
128112
}
129113

130114
.psp-error {
@@ -265,6 +249,7 @@ tbody th:last-of-type {
265249
overflow: hidden;
266250
text-overflow: ellipsis;
267251
}
252+
268253
tbody th:empty {
269254
background-image: linear-gradient(
270255
to right,
@@ -316,12 +301,68 @@ regular-table:not(.flat-group-rollup-mode) {
316301
.psp-align-right {
317302
text-align: right;
318303
}
304+
305+
.psp-color-mode-bar {
306+
padding: 0 2px;
307+
}
308+
309+
.psp-color-mode-label-bar {
310+
position: relative;
311+
padding: 0 2px;
312+
313+
.psp-bar {
314+
isolation: isolate;
315+
position: unset;
316+
}
317+
318+
.psp-bar:after {
319+
color: var(--psp-label-bar-bg);
320+
content: var(--label);
321+
mix-blend-mode: difference;
322+
position: absolute;
323+
top: 0;
324+
bottom: 0;
325+
left: 0;
326+
right: 0;
327+
display: inline-flex;
328+
justify-content: flex-end;
329+
align-items: center;
330+
padding: 0 5px;
331+
}
332+
}
333+
334+
.psp-label-bar {
335+
inset: 0;
336+
pointer-events: none;
337+
display: flex;
338+
align-items: center;
339+
justify-content: flex-end;
340+
padding: 0px;
341+
}
342+
343+
.psp-label-bar-fill {
344+
position: absolute;
345+
top: 10%;
346+
height: 80%;
347+
background: var(--psp-label-bar-color);
348+
pointer-events: none;
349+
}
350+
351+
.psp-label-bar-text {
352+
position: relative;
353+
color: var(--psp-label-bar-bg);
354+
mix-blend-mode: difference;
355+
pointer-events: none;
356+
}
357+
319358
.psp-align-left {
320359
text-align: left;
321360
}
361+
322362
.psp-positive:not(:focus) {
323363
color: var(--psp-datagrid--pos-cell--color);
324364
}
365+
325366
.psp-negative:not(:focus) {
326367
color: var(--psp-datagrid--neg-cell--color);
327368
}
@@ -363,6 +404,7 @@ regular-table table {
363404

364405
th.psp-header-leaf {
365406
border-bottom-width: 0px;
407+
366408
span {
367409
height: 23px;
368410
min-height: 23px;
@@ -395,18 +437,18 @@ regular-table table {
395437
regular-table
396438
tbody
397439
tr:hover
398-
td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected),
440+
td.psp-select-region:not(.psp-select-region-inactive),
399441
regular-table
400442
tbody
401443
tr:hover
402444
+ tr
403-
td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected) {
445+
td.psp-select-region:not(.psp-select-region-inactive) {
404446
border-color: var(--psp--background-color) !important;
405447
}
406448

407449
regular-table tbody tr:hover {
408450
td.psp-select-region.psp-menu-open {
409-
&:not(.psp-row-selected):not(.psp-row-subselected) {
451+
&:not(.psp-select-region-inactive) {
410452
box-shadow:
411453
inset -2px 0px 0px var(--psp--background-color),
412454
inset 2px 0px 0px var(--psp--background-color);
@@ -479,6 +521,7 @@ regular-table table tbody tr:hover + tr:after {
479521
rgba(0, 128, 255, 0.5)
480522
);
481523
}
524+
482525
100% {
483526
background-color: var(
484527
--pulse--background-color-end,
@@ -494,6 +537,7 @@ regular-table table tbody tr:hover + tr:after {
494537
rgba(0, 128, 255, 0.5)
495538
);
496539
}
540+
497541
100% {
498542
background-color: var(
499543
--pulse--background-color-end,
@@ -509,6 +553,7 @@ regular-table table tbody tr:hover + tr:after {
509553
rgba(255, 25, 0, 0.5)
510554
);
511555
}
556+
512557
100% {
513558
background-color: var(
514559
--pulse--background-color-end,
@@ -524,6 +569,7 @@ regular-table table tbody tr:hover + tr:after {
524569
rgba(255, 25, 0, 0.5)
525570
);
526571
}
572+
527573
100% {
528574
background-color: var(
529575
--pulse--background-color-end,

packages/viewer-datagrid/src/css/row-hover.css

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
regular-table {
1515
tbody {
1616
tr:hover
17-
th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),
17+
th.psp-tree-leaf:not(.psp-select-region):not(
18+
.psp-select-region-inactive
19+
),
1820
tr:hover
19-
th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),
20-
tr:hover td:not(.psp-row-selected):not(.psp-row-subselected),
21+
th.psp-tree-label:not(.psp-select-region):not(
22+
.psp-select-region-inactive
23+
),
24+
tr:hover td:not(.psp-select-region):not(.psp-select-region-inactive),
2125
tr:hover:after {
2226
border-color: var(
2327
--psp-datagrid--hover--border-color,
@@ -36,7 +40,9 @@ regular-table {
3640
}
3741

3842
tr:last-child:hover
39-
td:not(.psp-row-selected):not(.psp-row-subselected).psp-menu-open {
43+
td:not(.psp-select-region):not(
44+
.psp-select-region-inactive
45+
).psp-menu-open {
4046
box-shadow:
4147
inset -2px 0px 0px var(--psp--color),
4248
inset 2px 0px 0px var(--psp--color),
@@ -46,11 +52,17 @@ regular-table {
4652

4753
tr:hover
4854
+ tr
49-
th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),
55+
th.psp-tree-leaf:not(.psp-select-region):not(
56+
.psp-select-region-inactive
57+
),
5058
tr:hover
5159
+ tr
52-
th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),
53-
tr:hover + tr td:not(.psp-row-selected):not(.psp-row-subselected) {
60+
th.psp-tree-label:not(.psp-select-region):not(
61+
.psp-select-region-inactive
62+
),
63+
tr:hover
64+
+ tr
65+
td:not(.psp-select-region):not(.psp-select-region-inactive) {
5466
border-top-color: transparent;
5567
}
5668

@@ -72,6 +84,7 @@ regular-table {
7284

7385
tr:hover {
7486
color: inherit;
87+
7588
th:first-child:not(:empty),
7689
th:first-child:empty + th:not(:empty),
7790
th:first-child:empty ~ th:empty + th:not(:empty),

packages/viewer-datagrid/src/css/toolbar.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
-webkit-mask-image: var(--psp-toolbar-edit-mode-select-region--content);
9595
}
9696

97+
#edit_mode[data-edit-mode="SELECT_ROW_TREE"]:before {
98+
-webkit-mask-image: var(--psp-toolbar-edit-mode-select-row-tree--content);
99+
}
100+
97101
/* #edit_mode span:before { */
98102
/* content: var(--edit-mode-toggle--content, "N/A"); */
99103
/* } */
@@ -124,6 +128,13 @@
124128
);
125129
}
126130

131+
#edit_mode[data-edit-mode="SELECT_ROW_TREE"] span:before {
132+
content: var(
133+
--psp-label--edit-mode-select-row-tree--content,
134+
"Tree Select"
135+
);
136+
}
137+
127138
#scroll_lock span:before {
128139
content: var(--psp-label--scroll-lock-toggle--content, "Free Scroll");
129140
}

packages/viewer-datagrid/src/ts/custom_elements/datagrid.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class HTMLPerspectiveViewerDatagridPluginElement
210210
return out.trim();
211211
}
212212

213-
async resize(): Promise<void> {
213+
async resize(_view: View): Promise<void> {
214214
if (!this.isConnected || this.offsetParent == null) {
215215
return;
216216
}
@@ -225,25 +225,22 @@ export class HTMLPerspectiveViewerDatagridPluginElement
225225
this.regular_table.clear();
226226
}
227227

228-
async save(): Promise<any> {
228+
save(): any {
229229
return save.call(this);
230230
}
231231

232-
async restore(
233-
token: DatagridPluginConfig,
234-
columns_config?: ColumnsConfig,
235-
): Promise<any> {
232+
restore(token: DatagridPluginConfig, columns_config?: ColumnsConfig): void {
236233
return restore.call(this, token, columns_config ?? {});
237234
}
238235

239-
async restyle(): Promise<void> {
236+
async restyle(view: View): Promise<void> {
240237
// Get view from model if available, otherwise no-op
241238
if (this.model?._view) {
242-
await this.draw(this.model._view);
239+
await this.draw(view);
243240
}
244241
}
245242

246-
async delete(): Promise<void> {
243+
delete(): void {
247244
this.disconnectedCallback();
248245
this._toolbar = undefined;
249246
if ((this.regular_table as any).table_model) {

packages/viewer-datagrid/src/ts/custom_elements/toolbar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class HTMLPerspectiveViewerDatagridToolbarElement extends HTMLElement {
6666
plugin._edit_button = this.shadowRoot!.querySelector(
6767
"#edit_mode",
6868
) as HTMLElement;
69+
6970
plugin._edit_button.addEventListener("click", () => {
7071
toggle_edit_mode.call(plugin);
7172
plugin.regular_table.draw();

0 commit comments

Comments
 (0)