Skip to content

Commit b7ad274

Browse files
committed
Added highlights for selected columns
1 parent a53c15a commit b7ad274

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

src/Visualizer/components/TableNode.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState, FC, useEffect } from "react";
22
import { Handle, Position, NodeProps } from "reactflow";
33
import { KeyIcon } from "../components";
44
import { markdown } from "../helpers";
5-
import { isTableHighlighted, isColumnHighlighted } from "../helpers/tableHighlights";
5+
import { tableHighlightsPresent, isTableHighlighted, isColumnHighlighted } from "../helpers/tableHighlights";
66

77
import "@reactflow/node-resizer/dist/style.css";
88

@@ -34,6 +34,8 @@ export const TableNode: FC<NodeProps> = ({ data }) => {
3434

3535
if (isColumnHighlighted({ schema: data.schema, tableName: data.name, columnName })) {
3636
classes.push("column-name--highlighted")
37+
} else if (tableHighlightsPresent()) {
38+
classes.push("column-name--dimmed")
3739
}
3840

3941
return classes.join(" ")
@@ -43,7 +45,7 @@ export const TableNode: FC<NodeProps> = ({ data }) => {
4345
<div
4446
className={`table ${isTableHighlighted({ schema: data.schema, tableName: data.name }) ? 'table--highlighted' : ''}`}>
4547
<div
46-
style={{ backgroundColor: data.schemaColor }}
48+
style={isTableHighlighted({ schema: data.schema, tableName: data.name }) ? {} : { backgroundColor: data.schemaColor }}
4749
className="table__name"
4850
onMouseEnter={() => {
4951
if(descriptionOnHoverActive) {

src/Visualizer/helpers/tableHighlights.ts

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const highlights = (urlParams.get("highlights") || "").split(";").reduce((acc: {
1010
return acc;
1111
}, {} as { [key: string]: string[] });
1212

13+
export const tableHighlightsPresent = () => {
14+
return Object.keys(highlights).length > 0
15+
}
16+
1317
export const isTableHighlighted = ({ schema, tableName }: { schema: string | undefined, tableName: string }) => {
1418
const fullTableName = schema ? `${schema}.${tableName}` : tableName
1519

src/Visualizer/style/column-name.scss

+20-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@
6262

6363
content: "";
6464
}
65-
66-
#{$root}--selected & {
67-
display: block;
68-
}
6965
}
7066

7167
&__inner {
@@ -83,5 +79,25 @@
8379

8480
&:hover {
8581
background-color: #EFEFEF;
82+
83+
opacity: 1;
84+
}
85+
86+
&--highlighted {
87+
border-color: #FADB5F;
88+
89+
background-color: #FADB5F;
90+
}
91+
92+
&--dimmed {
93+
opacity: 0.4;
94+
}
95+
96+
&--selected {
97+
#{$root}__description {
98+
display: block;
99+
100+
opacity: 1;
101+
}
86102
}
87103
}

src/Visualizer/style/table.scss

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.table {
2+
$root: &;
3+
24
background-color: #FFF;
35

46
&__name {
@@ -66,4 +68,17 @@
6668
display: block;
6769
}
6870
}
71+
72+
&--highlighted {
73+
#{$root}__name {
74+
background-color: #FADB5F;
75+
}
76+
77+
#{$root}__columns {
78+
border-color: #FADB5F;
79+
border-style: dashed;
80+
border-width: 2px;
81+
border-top: 0;
82+
}
83+
}
6984
}

0 commit comments

Comments
 (0)