Skip to content

Commit 76ab773

Browse files
committed
adjust node look
1 parent 48c5ef1 commit 76ab773

File tree

5 files changed

+132
-88
lines changed

5 files changed

+132
-88
lines changed

web/common/src/components/Lineage/help.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,39 +113,45 @@ export function createNode<TNodeData extends LineageNodeData = LineageNodeData>(
113113
}
114114

115115
export function calculateNodeBaseHeight({
116-
hasNodeFooter = false,
117-
hasCeiling = false,
118-
hasFloor = false,
119-
nodeOptionsCount = 0,
116+
includeNodeFooterHeight = false,
117+
includeCeilingHeight = false,
118+
includeFloorHeight = false,
120119
}: {
121-
hasNodeFooter?: boolean
122-
hasCeiling?: boolean
123-
hasFloor?: boolean
124-
nodeOptionsCount?: number
120+
includeNodeFooterHeight?: boolean
121+
includeCeilingHeight?: boolean
122+
includeFloorHeight?: boolean
125123
}) {
126124
const border = 2
127125
const footerHeight = 20 // tailwind h-5
128126
const base = 28 // tailwind h-7
129127
const ceilingHeight = 20 // tailwind h-5
130128
const floorHeight = 20 // tailwind h-5
131-
const nodeOptionHeight = 24 // tailwind h-6
132-
133-
const nodeOptionsSeparator = 1
134-
const nodeOptionsSeparators = nodeOptionsCount > 1 ? nodeOptionsCount - 1 : 0
135129

136130
const ceilingGap = 4
137131
const floorGap = 4
138132

139133
return [
140134
border * 2,
141135
base,
142-
hasNodeFooter ? footerHeight : 0,
136+
includeNodeFooterHeight ? footerHeight : 0,
137+
includeCeilingHeight ? ceilingHeight + ceilingGap : 0,
138+
includeFloorHeight ? floorHeight + floorGap : 0,
139+
].reduce((acc, h) => acc + h, 0)
140+
}
143141

144-
hasCeiling ? ceilingHeight + ceilingGap : 0,
145-
hasFloor ? floorHeight + floorGap : 0,
142+
export function calculateNodeDetailsHeight({
143+
nodeDetailsCount = 0,
144+
}: {
145+
nodeDetailsCount?: number
146+
}) {
147+
const nodeOptionHeight = 24 // tailwind h-6
146148

149+
const nodeOptionsSeparator = 1
150+
const nodeOptionsSeparators = nodeDetailsCount > 1 ? nodeDetailsCount - 1 : 0
151+
152+
return [
147153
nodeOptionsSeparators * nodeOptionsSeparator,
148-
nodeOptionsCount * nodeOptionHeight,
154+
nodeDetailsCount * nodeOptionHeight,
149155
].reduce((acc, h) => acc + h, 0)
150156
}
151157

web/common/src/components/Lineage/layout/dagreLayout.worker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ self.onmessage = <
3535

3636
g.setGraph({
3737
rankdir: 'LR',
38-
nodesep: 24,
39-
ranksep: DEFAULT_NODE_WIDTH / 2,
38+
nodesep: 0,
39+
ranksep: 48,
4040
edgesep: 0,
4141
ranker: 'longest-path',
4242
})
4343

4444
g.setDefaultEdgeLabel(() => ({}))
4545

46+
// Building layout already heavy operation, so trying to optimize it a bit
4647
for (let i = 0; i < maxCount; i++) {
4748
if (i < edgeCount) {
4849
g.setEdge(edges[i].source, edges[i].target)
@@ -58,14 +59,15 @@ self.onmessage = <
5859

5960
dagre.layout(g)
6061

62+
// Building layout already heavy operation, so trying to optimize it a bit
6163
for (let i = 0; i < nodeCount; i++) {
6264
const node = nodes[i]
6365
const width = node.width || DEFAULT_NODE_WIDTH
6466
const height = node.height || 0
6567
const nodeId = node.id as NodeId
6668
const nodeWithPosition = g.node(nodeId)
67-
const halfWidth = width >> 1
68-
const halfHeight = height >> 1
69+
const halfWidth = width / 2
70+
const halfHeight = height / 2
6971

7072
nodesMap[nodeId] = {
7173
...node,

web/common/src/components/Lineage/stories/ModelLineage.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { FactoryEdgeWithGradient } from '../edge/FactoryEdgeWithGradient'
2323
import { toNodeID, toPortID } from '../utils'
2424
import {
2525
calculateNodeBaseHeight,
26+
calculateNodeDetailsHeight,
2627
createEdge,
2728
createNode,
2829
getOnlySelectedNodes,
@@ -133,29 +134,31 @@ export const ModelLineage = ({
133134
tags: detail.tags || [],
134135
columns,
135136
})
136-
137-
const hasNodeFooter = false
138137
const selectedColumnsCount = new Set(
139138
Object.keys(columns).map(k => toPortID(detail.name, k)),
140139
).intersection(selectedColumns).size
141-
const hasColumnsFilter =
142-
Object.keys(columns).length > MAX_COLUMNS_TO_DISPLAY
143-
144-
const baseNodeHeight = calculateNodeBaseHeight({
145-
hasNodeFooter,
146-
hasCeiling: true,
147-
hasFloor: false,
148-
nodeOptionsCount: 0,
140+
// We are trying to project the node hight so we are including the ceiling and floor height
141+
const nodeBaseHeight = calculateNodeBaseHeight({
142+
includeNodeFooterHeight: false,
143+
includeCeilingHeight: true,
144+
includeFloorHeight: true,
145+
})
146+
const nodeDetailsHeight = calculateNodeDetailsHeight({
147+
nodeDetailsCount: 0,
149148
})
150149
const selectedColumnsHeight =
151150
calculateSelectedColumnsHeight(selectedColumnsCount)
152151

153152
const columnsHeight = calculateColumnsHeight({
154153
columnsCount: calculateNodeColumnsCount(Object.keys(columns).length),
155-
hasColumnsFilter,
154+
hasColumnsFilter: Object.keys(columns).length > MAX_COLUMNS_TO_DISPLAY,
156155
})
157156

158-
node.height = baseNodeHeight + selectedColumnsHeight + columnsHeight
157+
node.height =
158+
nodeBaseHeight +
159+
nodeDetailsHeight +
160+
selectedColumnsHeight +
161+
columnsHeight
159162

160163
return node
161164
},

web/common/src/components/Lineage/stories/ModelNode.tsx

Lines changed: 82 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
calculateSelectedColumnsHeight,
1313
} from '../LineageColumnLevel/help'
1414
import { useColumns, type Column } from '../LineageColumnLevel/useColumns'
15-
import { calculateNodeBaseHeight } from '../help'
15+
import { calculateNodeBaseHeight, calculateNodeDetailsHeight } from '../help'
1616
import { NodeAppendix } from '../node/NodeAppendix'
1717
import { NodeBadge } from '../node/NodeBadge'
1818
import { NodeBase } from '../node/NodeBase'
@@ -39,6 +39,7 @@ import { Tooltip } from '@/components/Tooltip/Tooltip'
3939
import type { ColumnLevelLineageAdjacencyList } from '../LineageColumnLevel/ColumnLevelLineageContext'
4040
import { ModelName } from '@/components/ModelName/ModelName'
4141
import { Metadata } from '@/components/Metadata/Metadata'
42+
import { Badge } from '@/components/Badge/Badge'
4243

4344
export const ModelNode = React.memo(function ModelNode({
4445
id,
@@ -90,21 +91,35 @@ export const ModelNode = React.memo(function ModelNode({
9091
const modelType = data.model_type.toLowerCase() as NodeType
9192
const hasColumnsFilter =
9293
shouldShowColumns && columns.length > MAX_COLUMNS_TO_DISPLAY
93-
94-
const baseNodeHeight = calculateNodeBaseHeight({
95-
nodeOptionsCount: 0,
94+
// We are not including the footer, because we need actual height to dynamically adjust node container height
95+
const nodeBaseHeight = calculateNodeBaseHeight({
96+
includeNodeFooterHeight: false,
97+
includeCeilingHeight: false,
98+
includeFloorHeight: false,
9699
})
100+
const nodeDetailsHeight =
101+
zoom > ZOOM_TRESHOLD
102+
? calculateNodeDetailsHeight({
103+
nodeDetailsCount: 0,
104+
})
105+
: 0
97106
const selectedColumnsHeight = calculateSelectedColumnsHeight(
98107
modelSelectedColumns.length,
99108
)
100-
const columnsHeight = calculateColumnsHeight({
101-
columnsCount: shouldShowColumns
102-
? calculateNodeColumnsCount(columns.length)
103-
: 0,
104-
hasColumnsFilter,
105-
})
109+
const columnsHeight =
110+
zoom > ZOOM_TRESHOLD && shouldShowColumns
111+
? calculateColumnsHeight({
112+
columnsCount: calculateNodeColumnsCount(columns.length),
113+
hasColumnsFilter,
114+
})
115+
: 0
106116

107-
const nodeHeight = baseNodeHeight + selectedColumnsHeight + columnsHeight
117+
// If zoom is less than ZOOM_TRESHOLD, we are making node looks bigger
118+
const nodeHeight =
119+
(zoom > ZOOM_TRESHOLD ? nodeBaseHeight : nodeBaseHeight * 2) +
120+
nodeDetailsHeight +
121+
selectedColumnsHeight +
122+
columnsHeight
108123

109124
return (
110125
<NodeContainer
@@ -124,7 +139,7 @@ export const ModelNode = React.memo(function ModelNode({
124139
position="top"
125140
className="bg-lineage-node-appendix-background"
126141
>
127-
<HorizontalContainer className="gap-1 items-center h-5">
142+
<HorizontalContainer className="gap-1 items-center overflow-visible h-5">
128143
{zoom > ZOOM_TRESHOLD && (
129144
<>
130145
<NodeBadge>{data.kind.toUpperCase()}</NodeBadge>
@@ -165,7 +180,7 @@ export const ModelNode = React.memo(function ModelNode({
165180
)}
166181
>
167182
<NodeHeader
168-
className="shrink-0 h-7"
183+
className={cn(zoom > ZOOM_TRESHOLD ? 'shrink-0 h-7' : 'h-full')}
169184
onClick={toggleSelectedNode}
170185
>
171186
<NodeHandles
@@ -193,60 +208,50 @@ export const ModelNode = React.memo(function ModelNode({
193208
>
194209
<HorizontalContainer
195210
className={cn(
196-
'items-center px-1 w-auto shrink-0',
197-
leftId ? 'pl-2' : 'pl-1',
198-
getNodeTypeColor(modelType),
199-
)}
200-
>
201-
<NodeBadge
202-
size="2xs"
203-
className="bg-[transparent] text-[white]"
204-
>
205-
{modelType.toUpperCase()}
206-
</NodeBadge>
207-
</HorizontalContainer>
208-
<HorizontalContainer
209-
className={cn(
210-
'gap-2 items-center px-2',
211-
rightId ? 'pr-3' : 'pr-2',
211+
'gap-2 items-center pl-4 pr-2',
212212
getNodeTypeBorderColor(modelType),
213213
)}
214214
>
215215
<ModelName
216+
showTooltip
216217
hideCatalog
217-
showTooltip={zoom > ZOOM_TRESHOLD}
218+
hideSchema={zoom <= ZOOM_TRESHOLD}
218219
hideIcon
219220
name={data.displayName}
220221
grayscale
221-
showCopy
222-
className="w-full text-xs overflow-hidden cursor-default truncate"
222+
className={cn(
223+
'w-full overflow-hidden cursor-default truncate',
224+
zoom > ZOOM_TRESHOLD ? ' text-xs' : 'text-2xl justify-center',
225+
)}
223226
/>
224227
</HorizontalContainer>
225228
</NodeHandles>
226229
</NodeHeader>
227230
{shouldShowColumns && (
228-
<VerticalContainer className="border-t border-lineage-node-border">
229-
<VerticalContainer className="h-auto shrink-0">
230-
{modelSelectedColumns.map(column => (
231-
<ModelNodeColumn
232-
key={column.id}
233-
id={column.id}
234-
nodeId={nodeId}
235-
modelName={data.name}
236-
name={column.name}
237-
description={column.description}
238-
type={column.data_type}
239-
className="p-1 first:border-t-0 h-6"
240-
columnLineageData={
241-
(
242-
column as Column & {
243-
columnLineageData?: ColumnLevelLineageAdjacencyList
244-
}
245-
).columnLineageData
246-
}
247-
/>
248-
))}
249-
</VerticalContainer>
231+
<>
232+
{modelSelectedColumns.length > 0 && (
233+
<VerticalContainer className="h-auto shrink-0 border-t border-lineage-node-border">
234+
{modelSelectedColumns.map(column => (
235+
<ModelNodeColumn
236+
key={column.id}
237+
id={column.id}
238+
nodeId={nodeId}
239+
modelName={data.name}
240+
name={column.name}
241+
description={column.description}
242+
type={column.data_type}
243+
className="p-1 first:border-t-0 h-6"
244+
columnLineageData={
245+
(
246+
column as Column & {
247+
columnLineageData?: ColumnLevelLineageAdjacencyList
248+
}
249+
).columnLineageData
250+
}
251+
/>
252+
))}
253+
</VerticalContainer>
254+
)}
250255
{columns.length > 0 && (
251256
<NodePorts
252257
ports={columns}
@@ -275,11 +280,33 @@ export const ModelNode = React.memo(function ModelNode({
275280
}
276281
/>
277282
)}
283+
className="border-t border-lineage-node-border"
278284
/>
279285
)}
280-
</VerticalContainer>
286+
</>
281287
)}
282288
</NodeBase>
289+
<NodeAppendix
290+
position="bottom"
291+
className="bg-lineage-node-appendix-background"
292+
>
293+
<HorizontalContainer
294+
className={cn(
295+
'gap-1 items-center overflow-visible',
296+
zoom > ZOOM_TRESHOLD ? 'h-5' : 'h-8',
297+
)}
298+
>
299+
<Badge
300+
size={zoom > ZOOM_TRESHOLD ? '2xs' : 'm'}
301+
className={cn(
302+
'text-[white] font-black',
303+
getNodeTypeColor(modelType),
304+
)}
305+
>
306+
{modelType.toUpperCase()}
307+
</Badge>
308+
</HorizontalContainer>
309+
</NodeAppendix>
283310
</NodeContainer>
284311
)
285312
})

web/common/src/components/ModelName/ModelName.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ export const ModelName = React.forwardRef<HTMLDivElement, ModelNameProps>(
144144
: 'text-model-name-model',
145145
)}
146146
>
147-
{truncate(model, truncateMaxCharsModel, 15)}
147+
{truncate(
148+
model,
149+
truncateMaxCharsModel,
150+
truncateLimitBefore * 2,
151+
'...',
152+
truncateLimitBefore * 2,
153+
)}
148154
</span>
149155
</span>
150156
)

0 commit comments

Comments
 (0)