Skip to content

Commit

Permalink
Extracted table class calculation to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
makaroni4 committed Oct 8, 2024
1 parent b7ad274 commit de93783
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Visualizer/components/TableNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ export const TableNode: FC<NodeProps> = ({ data }) => {
}, false);
}, []);

const tableClass = ({ schema, tableName}: { schema: string, tableName: string }) => {
const classes = ["table"]

if (isTableHighlighted({ schema, tableName })) {
classes.push("table--highlighted")
} else if (tableHighlightsPresent()) {
classes.push("table--dimmed")
}

return classes.join(" ")
}

const columnClass = ({ selectedColumn, columnName }: { selectedColumn: string, columnName: string }) => {
const classes = ["column-name"]

Expand All @@ -43,7 +55,7 @@ export const TableNode: FC<NodeProps> = ({ data }) => {

return (
<div
className={`table ${isTableHighlighted({ schema: data.schema, tableName: data.name }) ? 'table--highlighted' : ''}`}>
className={tableClass({ schema: data.schema, tableName: data.name })}>
<div
style={isTableHighlighted({ schema: data.schema, tableName: data.name }) ? {} : { backgroundColor: data.schemaColor }}
className="table__name"
Expand Down
12 changes: 12 additions & 0 deletions src/Visualizer/style/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@
border-top: 0;
}
}

&:hover {
#{$root}__name {
opacity: 1;
}
}

&--dimmed {
#{$root}__name {
opacity: 0.4;
}
}
}

0 comments on commit de93783

Please sign in to comment.