@hunterchen/canvas 0.4.1 → 0.6.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.
package/src/index.ts CHANGED
@@ -1,41 +1,59 @@
1
1
  // Components
2
- export { default as Canvas } from './components/canvas/canvas';
3
- export { CanvasComponent } from './components/canvas/component';
4
- export { Draggable, DraggableImage } from './components/canvas/draggable';
5
- export { CanvasWrapper, growTransition } from './components/canvas/wrapper';
6
- export { default as CanvasToolbar } from './components/canvas/toolbar';
7
- export { default as CanvasNavbar } from './components/canvas/navbar';
2
+ export { default as Canvas } from "./components/canvas/canvas";
3
+ export { CanvasComponent } from "./components/canvas/component";
4
+ export { Draggable, DraggableImage } from "./components/canvas/draggable";
5
+ export { CanvasWrapper, growTransition } from "./components/canvas/wrapper";
6
+ export { default as CanvasToolbar } from "./components/canvas/toolbar";
7
+ export { default as CanvasNavbar } from "./components/canvas/navbar";
8
8
 
9
9
  // Background Components
10
10
  export {
11
- DefaultCanvasBackground,
12
- DefaultWrapperBackground,
13
- DefaultIntroContent,
14
- DEFAULT_CANVAS_GRADIENT,
15
- DEFAULT_INTRO_GRADIENT,
16
- DEFAULT_CANVAS_BOX_GRADIENT,
17
- } from './components/canvas/backgrounds';
11
+ DefaultCanvasBackground,
12
+ DefaultWrapperBackground,
13
+ DefaultIntroContent,
14
+ DEFAULT_CANVAS_GRADIENT,
15
+ DEFAULT_INTRO_GRADIENT,
16
+ DEFAULT_CANVAS_BOX_GRADIENT,
17
+ } from "./components/canvas/backgrounds";
18
18
  export type {
19
- DefaultCanvasBackgroundProps,
20
- DefaultWrapperBackgroundProps,
21
- DefaultIntroContentProps,
22
- } from './components/canvas/backgrounds';
19
+ DefaultCanvasBackgroundProps,
20
+ DefaultWrapperBackgroundProps,
21
+ DefaultIntroContentProps,
22
+ } from "./components/canvas/backgrounds";
23
23
 
24
24
  // Contexts
25
- export { CanvasContext, CanvasProvider, useCanvasContext } from './contexts/CanvasContext';
26
- export type { CanvasContextState } from './contexts/CanvasContext';
27
- export { PerformanceProvider, usePerformanceMode, usePerformance } from './contexts/PerformanceContext';
28
- export type { PerformanceMode, PerformanceConfig } from './contexts/PerformanceContext';
25
+ export {
26
+ CanvasContext,
27
+ CanvasProvider,
28
+ useCanvasContext,
29
+ } from "./contexts/CanvasContext";
30
+ export type { CanvasContextState } from "./contexts/CanvasContext";
31
+ export {
32
+ PerformanceProvider,
33
+ usePerformanceMode,
34
+ usePerformance,
35
+ } from "./contexts/PerformanceContext";
36
+ export type {
37
+ PerformanceMode,
38
+ PerformanceConfig,
39
+ } from "./contexts/PerformanceContext";
29
40
 
30
41
  // Hooks
31
- export { default as useWindowDimensions } from './hooks/useWindowDimensions';
32
- export { usePerformanceMode as usePerformanceModeLegacy } from './hooks/usePerformanceMode';
42
+ export { default as useWindowDimensions } from "./hooks/useWindowDimensions";
43
+ export { usePerformanceMode as usePerformanceModeLegacy } from "./hooks/usePerformanceMode";
33
44
 
34
45
  // Utilities
35
- export * from './lib/canvas';
36
- export * from './lib/constants';
37
- export * from './lib/utils';
38
- export * from './utils/performance';
46
+ export * from "./lib/canvas";
47
+ export * from "./lib/constants";
48
+ export * from "./lib/utils";
49
+ export * from "./utils/performance";
39
50
 
40
51
  // Types
41
- export type { SectionCoordinates, NavItem, CanvasSection } from './types';
52
+ export type {
53
+ SectionCoordinates,
54
+ NavItem,
55
+ CanvasSection,
56
+ ToolbarConfig,
57
+ ToolbarPosition,
58
+ ToolbarDisplayMode,
59
+ } from "./types";
@@ -38,3 +38,62 @@ export interface NavItem {
38
38
  /** If true, clicking this section triggers the reset/home behavior */
39
39
  isHome?: boolean;
40
40
  }
41
+
42
+ /**
43
+ * Preset positions for the toolbar
44
+ */
45
+ export type ToolbarPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
46
+
47
+ /**
48
+ * What to display in the toolbar
49
+ */
50
+ export type ToolbarDisplayMode = 'coordinates' | 'scale' | 'both';
51
+
52
+ /**
53
+ * Configuration options for the canvas toolbar
54
+ */
55
+ export interface ToolbarConfig {
56
+ // === Visibility ===
57
+ /** Hide the toolbar entirely. Default: false */
58
+ hidden?: boolean;
59
+
60
+ // === Display Mode ===
61
+ /** What to show: 'coordinates', 'scale', or 'both'. Default: 'both' */
62
+ display?: ToolbarDisplayMode;
63
+
64
+ // === Positioning ===
65
+ /** Preset position. Default: 'top-left' */
66
+ position?: ToolbarPosition;
67
+
68
+ // === Auto-hide Behavior ===
69
+ /** Disable auto-hide when at home position. Default: false */
70
+ disableAutoHide?: boolean;
71
+
72
+ // === Styling (Tailwind-friendly) ===
73
+ /** Additional className for the container */
74
+ className?: string;
75
+ /** Additional className for the coordinates text */
76
+ coordinatesClassName?: string;
77
+ /** Additional className for the scale text */
78
+ scaleClassName?: string;
79
+ /** Additional className for the separator */
80
+ separatorClassName?: string;
81
+
82
+ // === Styling (non-Tailwind / inline styles) ===
83
+ /** Inline styles for the container */
84
+ style?: React.CSSProperties;
85
+ /** Inline styles for the coordinates */
86
+ coordinatesStyle?: React.CSSProperties;
87
+ /** Inline styles for the scale */
88
+ scaleStyle?: React.CSSProperties;
89
+
90
+ // === Content Customization ===
91
+ /** Custom separator between coordinates and scale. Default: ' | ' */
92
+ separator?: string;
93
+ /** Gap around the separator in pixels or CSS value. Default: undefined (uses inline spacing) */
94
+ separatorGap?: number | string;
95
+ /** Format for coordinates. Default: '(x, y)' */
96
+ coordinatesFormat?: (x: number, y: number) => string;
97
+ /** Format for scale. Default: '1.00x' */
98
+ scaleFormat?: (scale: number) => string;
99
+ }