|
11 | 11 | import { portLabelsStore } from '$lib/stores/portLabels'; |
12 | 12 | import { iconModeStore } from '$lib/stores/iconMode'; |
13 | 13 | import BlockIcon, { hasBlockIcon } from '$lib/components/icons/BlockIcon.svelte'; |
| 14 | + import { PREVIEW_GAP, previewSideForRotation } from '$lib/utils/previewBounds'; |
14 | 15 | import { hoveredHandle, selectedNodeHighlight } from '$lib/stores/hoveredHandle'; |
15 | 16 | import { showTooltip, hideTooltip } from '$lib/components/Tooltip.svelte'; |
16 | 17 | import { paramInput } from '$lib/actions/paramInput'; |
|
215 | 216 | // Port is horizontal (left/right) or vertical (top/bottom) |
216 | 217 | const isVertical = $derived(rotation === 1 || rotation === 3); |
217 | 218 |
|
218 | | - // Preview position: opposite side of inputs |
219 | | - // rotation 0: inputs left → preview right |
220 | | - // rotation 1: inputs top → preview bottom |
221 | | - // rotation 2: inputs right → preview left |
222 | | - // rotation 3: inputs bottom → preview top |
223 | | - const previewPosition = $derived(() => { |
224 | | - switch (rotation) { |
225 | | - case 1: return 'bottom'; |
226 | | - case 2: return 'left'; |
227 | | - case 3: return 'top'; |
228 | | - default: return 'right'; |
229 | | - } |
230 | | - }); |
| 219 | + // Preview position: opposite side of inputs (rotation → side mapping is in utils) |
| 220 | + const previewPosition = $derived(() => previewSideForRotation(rotation)); |
231 | 221 |
|
232 | 222 | const maxPortsOnSide = $derived(Math.max(data.inputs.length, data.outputs.length)); |
233 | 223 | const pinnedCount = $derived(validPinnedParams().length); |
|
485 | 475 | class:show-labels={showPortLabels} |
486 | 476 | class:missing-type={!typeDef && data.type !== NODE_TYPES.SUBSYSTEM && data.type !== NODE_TYPES.INTERFACE} |
487 | 477 | data-rotation={rotation} |
488 | | - style="width: {nodeDimensions.width}px; height: {nodeDimensions.height}px; --node-color: {nodeColor};" |
| 478 | + style="width: {nodeDimensions.width}px; height: {nodeDimensions.height}px; --node-color: {nodeColor}; --preview-gap: {PREVIEW_GAP}px;" |
489 | 479 | ondblclick={handleDoubleClick} |
490 | 480 | onmouseenter={handleMouseEnter} |
491 | 481 | onmouseleave={handleMouseLeave} |
|
799 | 789 | .node-icon { |
800 | 790 | flex: 1; |
801 | 791 | min-height: 0; |
802 | | - max-height: 42px; |
803 | 792 | margin-top: 1px; |
804 | 793 | display: flex; |
805 | 794 | align-items: center; |
|
1057 | 1046 |
|
1058 | 1047 | /* Preview position: right (default, inputs on left) */ |
1059 | 1048 | .plot-preview-popup.preview-right { |
1060 | | - left: calc(100% + 12px); |
| 1049 | + left: calc(100% + var(--preview-gap)); |
1061 | 1050 | top: 50%; |
1062 | 1051 | transform: translateY(-50%); |
1063 | 1052 | } |
1064 | 1053 |
|
1065 | 1054 | /* Preview position: left (inputs on right) */ |
1066 | 1055 | .plot-preview-popup.preview-left { |
1067 | | - right: calc(100% + 12px); |
| 1056 | + right: calc(100% + var(--preview-gap)); |
1068 | 1057 | top: 50%; |
1069 | 1058 | transform: translateY(-50%); |
1070 | 1059 | } |
1071 | 1060 |
|
1072 | 1061 | /* Preview position: top (inputs on bottom) */ |
1073 | 1062 | .plot-preview-popup.preview-top { |
1074 | | - bottom: calc(100% + 12px); |
| 1063 | + bottom: calc(100% + var(--preview-gap)); |
1075 | 1064 | left: 50%; |
1076 | 1065 | transform: translateX(-50%); |
1077 | 1066 | } |
1078 | 1067 |
|
1079 | 1068 | /* Preview position: bottom (inputs on top) */ |
1080 | 1069 | .plot-preview-popup.preview-bottom { |
1081 | | - top: calc(100% + 12px); |
| 1070 | + top: calc(100% + var(--preview-gap)); |
1082 | 1071 | left: 50%; |
1083 | 1072 | transform: translateX(-50%); |
1084 | 1073 | } |
|
0 commit comments