@classic-homes/theme-svelte 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
DEFAULT_CARD_CONFIG,
|
|
20
20
|
DEFAULT_TAB_WIDTH,
|
|
21
21
|
CARD_HEADER_HEIGHT,
|
|
22
|
-
CARD_EXPANDED_RATIO,
|
|
23
22
|
CARD_MIN_WIDTH,
|
|
24
23
|
loadPanelState,
|
|
25
24
|
savePanelState,
|
|
@@ -166,6 +165,20 @@
|
|
|
166
165
|
const resolvedConstraints = $derived({ ...DEFAULT_CONSTRAINTS, ...constraints });
|
|
167
166
|
const resolvedCardConfig = $derived({ ...DEFAULT_CARD_CONFIG, ...cardConfig });
|
|
168
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Default left offset for the card sheet, honoring cardConfig.align.
|
|
170
|
+
* Drag/resize bounds derive from the same offset so existing
|
|
171
|
+
* interactions are unaffected by non-center alignment.
|
|
172
|
+
*/
|
|
173
|
+
function cardDefaultLeftOffset(width: number): number {
|
|
174
|
+
const margin = resolvedCardConfig.horizontalMargin;
|
|
175
|
+
if (resolvedCardConfig.align === 'left') return margin;
|
|
176
|
+
if (resolvedCardConfig.align === 'right') {
|
|
177
|
+
return Math.max(margin, viewportWidth - width - margin);
|
|
178
|
+
}
|
|
179
|
+
return Math.max(margin, (viewportWidth - width) / 2);
|
|
180
|
+
}
|
|
181
|
+
|
|
169
182
|
// Internal state - initialized from props or persistence
|
|
170
183
|
let internalMode = $state<PanelMode>(DEFAULT_PANEL_STATE.mode);
|
|
171
184
|
let internalVariant = $state<PanelVariant>(DEFAULT_PANEL_STATE.variant);
|
|
@@ -295,13 +308,13 @@
|
|
|
295
308
|
viewportHeight = window.innerHeight;
|
|
296
309
|
|
|
297
310
|
// Initialize card expanded height
|
|
298
|
-
cardExpandedHeight = viewportHeight *
|
|
311
|
+
cardExpandedHeight = viewportHeight * resolvedCardConfig.expandedRatio;
|
|
299
312
|
|
|
300
313
|
// Listen for resize
|
|
301
314
|
const handleResize = () => {
|
|
302
315
|
viewportWidth = window.innerWidth;
|
|
303
316
|
viewportHeight = window.innerHeight;
|
|
304
|
-
cardExpandedHeight = viewportHeight *
|
|
317
|
+
cardExpandedHeight = viewportHeight * resolvedCardConfig.expandedRatio;
|
|
305
318
|
};
|
|
306
319
|
window.addEventListener('resize', handleResize);
|
|
307
320
|
|
|
@@ -583,10 +596,7 @@
|
|
|
583
596
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
584
597
|
resolvedCardConfig.maxWidth
|
|
585
598
|
);
|
|
586
|
-
const defaultLeftOffset =
|
|
587
|
-
resolvedCardConfig.horizontalMargin,
|
|
588
|
-
(viewportWidth - cardWidth) / 2
|
|
589
|
-
);
|
|
599
|
+
const defaultLeftOffset = cardDefaultLeftOffset(cardWidth);
|
|
590
600
|
// Calculate bounds: can move from left margin to right margin
|
|
591
601
|
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
592
602
|
const maxOffset =
|
|
@@ -898,10 +908,7 @@
|
|
|
898
908
|
cardWidthResizeStartWidth = currentWidth;
|
|
899
909
|
|
|
900
910
|
// Calculate current left position
|
|
901
|
-
const defaultLeftOffset =
|
|
902
|
-
resolvedCardConfig.horizontalMargin,
|
|
903
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
904
|
-
);
|
|
911
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
905
912
|
cardWidthResizeStartLeft = defaultLeftOffset + cardHorizontalPosition;
|
|
906
913
|
|
|
907
914
|
document.body.style.cursor = 'ew-resize';
|
|
@@ -940,10 +947,7 @@
|
|
|
940
947
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
941
948
|
resolvedCardConfig.maxWidth
|
|
942
949
|
);
|
|
943
|
-
const defaultLeftOffset =
|
|
944
|
-
resolvedCardConfig.horizontalMargin,
|
|
945
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
946
|
-
);
|
|
950
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
947
951
|
cardHorizontalPosition = newLeft - defaultLeftOffset;
|
|
948
952
|
}
|
|
949
953
|
}
|
|
@@ -1087,10 +1091,7 @@
|
|
|
1087
1091
|
);
|
|
1088
1092
|
// Use custom cardWidth if set, otherwise use default
|
|
1089
1093
|
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
1090
|
-
const defaultLeftOffset =
|
|
1091
|
-
resolvedCardConfig.horizontalMargin,
|
|
1092
|
-
(viewportWidth - defaultCardWidth) / 2
|
|
1093
|
-
);
|
|
1094
|
+
const defaultLeftOffset = cardDefaultLeftOffset(defaultCardWidth);
|
|
1094
1095
|
|
|
1095
1096
|
// Height based on expanded state or drag
|
|
1096
1097
|
let height: number;
|