zuljaman-banner-components 1.0.23 → 1.0.25
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/README.md +228 -131
- package/dist/components/BannerRenderer/BannerRenderer.d.ts +8 -0
- package/dist/components/BannerRenderer/BannerRenderer.d.ts.map +1 -0
- package/dist/components/BannerRenderer/BannerRenderer.js +325 -0
- package/dist/components/BannerRenderer/components/CopyElement.d.ts +62 -0
- package/dist/components/BannerRenderer/components/CopyElement.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/CopyElement.js +220 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.d.ts +26 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.js +172 -0
- package/dist/components/BannerRenderer/components/LogoElement.d.ts +55 -0
- package/dist/components/BannerRenderer/components/LogoElement.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/LogoElement.js +53 -0
- package/dist/components/BannerRenderer/components/VisualGuides.d.ts +43 -0
- package/dist/components/BannerRenderer/components/VisualGuides.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/VisualGuides.js +110 -0
- package/dist/components/BannerRenderer/components/index.d.ts +12 -0
- package/dist/components/BannerRenderer/components/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/index.js +14 -0
- package/dist/components/BannerRenderer/constants.d.ts +15 -0
- package/dist/components/BannerRenderer/constants.d.ts.map +1 -0
- package/dist/components/BannerRenderer/constants.js +36 -0
- package/dist/components/BannerRenderer/hooks/index.d.ts +14 -0
- package/dist/components/BannerRenderer/hooks/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/index.js +16 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts +30 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.js +87 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts +13 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.js +21 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts +73 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.js +151 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts +66 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.js +335 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts +61 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.js +180 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts +60 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.js +178 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts +8 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.js +12 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts +30 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.js +90 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts +22 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.js +70 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts +40 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.js +198 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts +43 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.js +491 -0
- package/dist/components/BannerRenderer/index.d.ts +6 -0
- package/dist/components/BannerRenderer/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/index.js +8 -0
- package/dist/components/{BannerRenderer.d.ts → BannerRenderer/types.d.ts} +29 -8
- package/dist/components/BannerRenderer/types.d.ts.map +1 -0
- package/dist/components/BannerRenderer/types.js +5 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts +38 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.js +138 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts +22 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.js +37 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts +25 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.js +56 -0
- package/dist/components/BannerRenderer/utils/fontUtils.d.ts +12 -0
- package/dist/components/BannerRenderer/utils/fontUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/fontUtils.js +26 -0
- package/dist/components/BannerRenderer/utils/graphUtils.d.ts +54 -0
- package/dist/components/BannerRenderer/utils/graphUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/graphUtils.js +138 -0
- package/dist/components/BannerRenderer/utils/index.d.ts +12 -0
- package/dist/components/BannerRenderer/utils/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/index.js +27 -0
- package/dist/components/BannerRenderer/utils/snapUtils.d.ts +38 -0
- package/dist/components/BannerRenderer/utils/snapUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/snapUtils.js +109 -0
- package/dist/components/BannerVisor.d.ts.map +1 -1
- package/dist/components/BannerVisor.js +8 -1
- package/dist/components/index.js +1 -1
- package/dist/components/shared/DraggableElement.d.ts +11 -0
- package/dist/components/shared/DraggableElement.d.ts.map +1 -1
- package/dist/components/shared/DraggableElement.js +47 -51
- package/dist/components/styles/Style1/substyleConfig.d.ts.map +1 -1
- package/dist/components/styles/Style1/substyleConfig.js +53 -54
- package/dist/components/styles/Style2/substyleConfig.js +78 -78
- package/dist/components/styles/Style3/substyleConfig.d.ts.map +1 -1
- package/dist/components/styles/Style3/substyleConfig.js +40 -37
- package/dist/components/styles/Style4/substyleConfig.js +57 -57
- package/dist/components/styles/types/substyleTypes.d.ts +32 -15
- package/dist/components/styles/types/substyleTypes.d.ts.map +1 -1
- package/dist/components/styles/utils/chainValidation.d.ts +41 -0
- package/dist/components/styles/utils/chainValidation.d.ts.map +1 -0
- package/dist/components/styles/utils/chainValidation.js +148 -0
- package/dist/components/styles/utils/positioningUtils.d.ts +207 -11
- package/dist/components/styles/utils/positioningUtils.d.ts.map +1 -1
- package/dist/components/styles/utils/positioningUtils.js +520 -19
- package/dist/constants/characterLimits.d.ts +4 -16
- package/dist/constants/characterLimits.d.ts.map +1 -1
- package/dist/constants/characterLimits.js +28 -26
- package/dist/constants/styleConfigs.js +6 -6
- package/dist/styleConfig.d.ts +4 -4
- package/dist/styleConfig.d.ts.map +1 -1
- package/dist/styleConfig.js +8 -16
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/BannerRenderer.d.ts.map +0 -1
- package/dist/components/BannerRenderer.js +0 -559
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@ Platform-agnostic banner components for Next.js and AWS Lambda platforms. This s
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
7
|
+
- **4 Banner Styles**: Each with 3 substyles (12 total variations)
|
|
8
|
+
- **Flexible Copy System**: Array-based copies with per-copy styling (color, background, padding, etc.)
|
|
9
|
+
- **Platform Agnostic**: Works with Next.js, AWS Lambda, and other React environments
|
|
10
|
+
- **TypeScript Support**: Full TypeScript definitions with enhanced type safety
|
|
11
|
+
- **Adapter Pattern**: Clean separation of platform-specific image handling
|
|
12
|
+
- **Interactive Modes**: Drag, resize, rotate, and linking modes for visual editors
|
|
13
|
+
- **Auto-Positioning**: Chain-based element positioning system
|
|
14
|
+
- **Visual Effects**: Configurable text shadows, logo shadows, and noise overlays
|
|
15
|
+
- **Responsive Design**: Automatic scaling based on container dimensions
|
|
15
16
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
@@ -24,19 +25,24 @@ npm install @zuljaman/banner-components
|
|
|
24
25
|
### Next.js Usage
|
|
25
26
|
|
|
26
27
|
```typescript
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
28
|
+
import NextImage from 'next/image';
|
|
29
|
+
import { BannerVisor, createNextJSAdapter } from '@zuljaman/banner-components';
|
|
30
|
+
|
|
31
|
+
// Create platform adapter
|
|
32
|
+
const ImageComponent = createNextJSAdapter(NextImage);
|
|
29
33
|
|
|
30
|
-
function
|
|
34
|
+
function MyBanner() {
|
|
31
35
|
return (
|
|
32
36
|
<BannerVisor
|
|
33
|
-
bannerStyle={1}
|
|
34
|
-
bannerSubstyle={1}
|
|
35
|
-
postType="POST"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
bannerStyle={1} // 1-4
|
|
38
|
+
bannerSubstyle={1} // 1-3
|
|
39
|
+
postType="POST" // "POST" or "STORY"
|
|
40
|
+
copies={[
|
|
41
|
+
{ id: 'copy-1', text: 'Primary text', styleSlot: 0 },
|
|
42
|
+
{ id: 'copy-2', text: 'Secondary text', styleSlot: 1 }
|
|
43
|
+
]}
|
|
44
|
+
logoUrl="/logo.png"
|
|
45
|
+
backgroundImageUrl="/background.jpg"
|
|
40
46
|
ImageComponent={ImageComponent}
|
|
41
47
|
/>
|
|
42
48
|
);
|
|
@@ -46,98 +52,208 @@ function MyBannerComponent() {
|
|
|
46
52
|
### AWS Lambda / SSR Usage
|
|
47
53
|
|
|
48
54
|
```typescript
|
|
49
|
-
import { BannerVisor } from '@zuljaman/banner-components';
|
|
50
|
-
import { ImageComponent } from '@zuljaman/banner-components/adapters/SSRAdapter';
|
|
55
|
+
import { BannerVisor, SSRImageComponent } from '@zuljaman/banner-components';
|
|
51
56
|
|
|
52
|
-
function
|
|
57
|
+
function LambdaBanner({ copies, logoUrl, backgroundImageUrl }) {
|
|
53
58
|
return (
|
|
54
59
|
<BannerVisor
|
|
55
60
|
bannerStyle={1}
|
|
56
61
|
bannerSubstyle={1}
|
|
57
62
|
postType="POST"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
copies={copies}
|
|
64
|
+
logoUrl={logoUrl}
|
|
65
|
+
backgroundImageUrl={backgroundImageUrl}
|
|
66
|
+
ImageComponent={SSRImageComponent}
|
|
67
|
+
sizeMultiplier={1} // Fixed size for server rendering
|
|
63
68
|
/>
|
|
64
69
|
);
|
|
65
70
|
}
|
|
66
71
|
```
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
### Legacy Props (Backward Compatible)
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
// Still supported for backward compatibility
|
|
77
|
+
<BannerVisor
|
|
78
|
+
bannerStyle={1}
|
|
79
|
+
bannerSubstyle={1}
|
|
80
|
+
postType="POST"
|
|
81
|
+
copy1="Primary text" // Legacy: use copies[] instead
|
|
82
|
+
copy2="Secondary text" // Legacy: use copies[] instead
|
|
83
|
+
logoUrl="/logo.png"
|
|
84
|
+
backgroundImageUrl="/background.jpg"
|
|
85
|
+
ImageComponent={ImageComponent}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
73
88
|
|
|
74
|
-
|
|
75
|
-
- `bannerStyle: number` - Style identifier (1-2)
|
|
76
|
-
- `bannerSubstyle: number` - Substyle identifier (1-3)
|
|
77
|
-
- `postType: PostType` - "POST" or "STORY" for different dimensions
|
|
78
|
-
- `copy1?: string` - Primary text content
|
|
79
|
-
- `copy2?: string` - Secondary text content
|
|
80
|
-
- `logoUrl?: string` - URL for logo image
|
|
81
|
-
- `backgroundImageUrl?: string` - URL for background image
|
|
82
|
-
- `sizeMultiplier?: number` - Manual size scaling (optional)
|
|
83
|
-
- `ImageComponent: React.ComponentType<ImageProps>` - Platform-specific image component
|
|
89
|
+
## Architecture
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
```
|
|
92
|
+
BannerVisor (Entry point)
|
|
93
|
+
└── BannerRenderer (Generic style-agnostic renderer)
|
|
94
|
+
├── LogoElement → DraggableElement
|
|
95
|
+
├── CopyElement → DraggableElement (one per copy)
|
|
96
|
+
├── InteractiveLines (chain visualization)
|
|
97
|
+
└── VisualGuides (alignment guides)
|
|
98
|
+
```
|
|
86
99
|
|
|
87
|
-
|
|
88
|
-
Enhanced banner style with sophisticated layout and shadow effects.
|
|
100
|
+
### Key Components
|
|
89
101
|
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
| Component | Description |
|
|
103
|
+
|-----------|-------------|
|
|
104
|
+
| `BannerVisor` | Main entry point, handles legacy prop conversion |
|
|
105
|
+
| `BannerRenderer` | Generic renderer that works with all 4 styles |
|
|
106
|
+
| `CopyElement` | Renders individual text elements with styling |
|
|
107
|
+
| `LogoElement` | Renders logo with positioning |
|
|
108
|
+
| `DraggableElement` | Reusable drag/rotate/resize wrapper |
|
|
92
109
|
|
|
93
|
-
|
|
110
|
+
## Props Reference
|
|
94
111
|
|
|
95
|
-
|
|
96
|
-
- **Substyle 1**: Logo top-left, text bottom
|
|
97
|
-
- **Substyle 2**: Logo top-left with side text, centered bottom text
|
|
98
|
-
- **Substyle 3**: Logo and text side-by-side, bottom text
|
|
112
|
+
### Core Props
|
|
99
113
|
|
|
100
|
-
|
|
114
|
+
| Prop | Type | Default | Description |
|
|
115
|
+
|------|------|---------|-------------|
|
|
116
|
+
| `bannerStyle` | `number` | `1` | Style template (1-4) |
|
|
117
|
+
| `bannerSubstyle` | `number` | required | Substyle variation (1-3) |
|
|
118
|
+
| `postType` | `'POST' \| 'STORY'` | required | Banner dimensions |
|
|
119
|
+
| `ImageComponent` | `React.ComponentType` | required | Platform image adapter |
|
|
101
120
|
|
|
102
|
-
###
|
|
103
|
-
Uses Next.js optimized Image component with automatic optimization.
|
|
121
|
+
### Copy System
|
|
104
122
|
|
|
105
123
|
```typescript
|
|
106
|
-
|
|
124
|
+
interface CopyConfig {
|
|
125
|
+
id: string; // Unique identifier
|
|
126
|
+
styleSlot?: number; // 0 = copy1 position, 1 = copy2 position
|
|
127
|
+
text: string; // Text content
|
|
128
|
+
fontSize?: number; // Size multiplier (default 1.0)
|
|
129
|
+
align?: 'left' | 'center' | 'right';
|
|
130
|
+
fontWeight?: 'thin' | 'normal' | 'bold';
|
|
131
|
+
fontFamily?: string;
|
|
132
|
+
color?: string; // Text color
|
|
133
|
+
bgColor?: string; // Background color
|
|
134
|
+
hasBg?: boolean; // Show background
|
|
135
|
+
paddingX?: string; // Horizontal padding (e.g., '1rem')
|
|
136
|
+
paddingY?: string; // Vertical padding
|
|
137
|
+
borderRadius?: string; // Corner radius
|
|
138
|
+
translateX?: number; // X offset in pixels
|
|
139
|
+
translateY?: number; // Y offset in pixels
|
|
140
|
+
rotation?: number; // Rotation in degrees
|
|
141
|
+
width?: number; // Width in pixels
|
|
142
|
+
underline?: boolean;
|
|
143
|
+
italic?: boolean;
|
|
144
|
+
textBold?: boolean;
|
|
145
|
+
hidden?: boolean; // Hide this copy
|
|
146
|
+
}
|
|
107
147
|
```
|
|
108
148
|
|
|
109
|
-
###
|
|
110
|
-
|
|
149
|
+
### Visual Effects
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
|------|------|---------|-------------|
|
|
153
|
+
| `textShadowEnabled` | `boolean` | from style | Enable text shadows |
|
|
154
|
+
| `textShadowSize` | `number` | from style | Shadow blur size |
|
|
155
|
+
| `textShadowIntensity` | `number` | from style | Shadow opacity |
|
|
156
|
+
| `logoShadowEnabled` | `boolean` | from style | Enable logo shadow |
|
|
157
|
+
| `logoShadowSize` | `number` | from style | Logo shadow size |
|
|
158
|
+
| `logoShadowIntensity` | `number` | from style | Logo shadow opacity |
|
|
159
|
+
| `noiseEnabled` | `boolean` | from style | Enable noise overlay |
|
|
160
|
+
| `noiseIntensity` | `number` | from style | Noise opacity |
|
|
161
|
+
|
|
162
|
+
### Interactive Modes
|
|
163
|
+
|
|
164
|
+
| Prop | Type | Description |
|
|
165
|
+
|------|------|-------------|
|
|
166
|
+
| `draggableMode` | `boolean` | Enable drag/rotate/resize on elements |
|
|
167
|
+
| `creationMode` | `boolean` | Show element borders, enable creation UI |
|
|
168
|
+
| `linkingModeActive` | `boolean` | Enable element linking via clicks |
|
|
169
|
+
|
|
170
|
+
### Callbacks
|
|
111
171
|
|
|
112
172
|
```typescript
|
|
113
|
-
|
|
173
|
+
// Indexed callbacks (new)
|
|
174
|
+
onCopyPositionChange?: (index: number, pos: { x: number; y: number }) => void;
|
|
175
|
+
onCopyRotationChange?: (index: number, rotation: number) => void;
|
|
176
|
+
onCopyWidthChange?: (index: number, width: number) => void;
|
|
177
|
+
|
|
178
|
+
// Logo callbacks
|
|
179
|
+
onLogoPositionChange?: (pos: { x: number; y: number }) => void;
|
|
180
|
+
onLogoRotationChange?: (rotation: number) => void;
|
|
181
|
+
onLogoWidthChange?: (width: number) => void;
|
|
182
|
+
|
|
183
|
+
// Auto-positioning callbacks
|
|
184
|
+
onApplyAutoPositioning?: (config) => void;
|
|
185
|
+
onConnectionsDeleted?: () => void;
|
|
186
|
+
onLineGapsChange?: (lineGaps: Record<string, number>) => void;
|
|
187
|
+
|
|
188
|
+
// Legacy callbacks (still supported)
|
|
189
|
+
onCopy1PositionChange?: (pos) => void;
|
|
190
|
+
onCopy2PositionChange?: (pos) => void;
|
|
114
191
|
```
|
|
115
192
|
|
|
116
|
-
##
|
|
193
|
+
## Style Guide
|
|
117
194
|
|
|
118
|
-
###
|
|
195
|
+
### Available Styles
|
|
196
|
+
|
|
197
|
+
| Style | Font | Recommended Copies | Noise | Description |
|
|
198
|
+
|-------|------|-------------------|-------|-------------|
|
|
199
|
+
| 1 | Roboto | 2 | No | Clean, modern sans-serif |
|
|
200
|
+
| 2 | Lato | 2 | No | Styled text with backgrounds |
|
|
201
|
+
| 3 | Cormorant Garamond | 1 | Yes | Elegant serif, single copy |
|
|
202
|
+
| 4 | Cormorant Garamond | 2 | No | Dual serif copies |
|
|
203
|
+
|
|
204
|
+
### Substyle Layouts
|
|
205
|
+
|
|
206
|
+
Each style has 3 substyles (1-3) with different element arrangements:
|
|
207
|
+
- **Substyle 1**: Logo top-left, text bottom
|
|
208
|
+
- **Substyle 2**: Logo + side text, centered bottom
|
|
209
|
+
- **Substyle 3**: Logo and text side-by-side
|
|
210
|
+
|
|
211
|
+
## Auto-Positioning System
|
|
212
|
+
|
|
213
|
+
The package includes a chain-based auto-positioning system for maintaining element relationships:
|
|
119
214
|
|
|
120
215
|
```typescript
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
216
|
+
// Elements are linked in chains: copy-0 → copy-1 → copy-2
|
|
217
|
+
// When an anchor element moves, linked elements adjust automatically
|
|
218
|
+
|
|
219
|
+
<BannerVisor
|
|
220
|
+
autoPositioningOverride={{
|
|
221
|
+
enabled: true,
|
|
222
|
+
config: {
|
|
223
|
+
links: [
|
|
224
|
+
{ fromElement: 'copy-0', toElement: 'copy-1', direction: 'down', gapRem: 1 }
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
gapRem: 1
|
|
228
|
+
}}
|
|
229
|
+
// ...other props
|
|
230
|
+
/>
|
|
129
231
|
```
|
|
130
232
|
|
|
131
|
-
###
|
|
233
|
+
### Element IDs
|
|
234
|
+
|
|
235
|
+
- Logo: `'logo'`
|
|
236
|
+
- Copies: `'copy-0'`, `'copy-1'`, `'copy-2'` (based on styleSlot)
|
|
237
|
+
|
|
238
|
+
## Platform Adapters
|
|
239
|
+
|
|
240
|
+
### NextJSAdapter
|
|
241
|
+
|
|
242
|
+
Uses Next.js optimized Image component with automatic optimization.
|
|
132
243
|
|
|
133
244
|
```typescript
|
|
134
|
-
import
|
|
245
|
+
import NextImage from 'next/image';
|
|
246
|
+
import { createNextJSAdapter } from '@zuljaman/banner-components';
|
|
247
|
+
|
|
248
|
+
const ImageComponent = createNextJSAdapter(NextImage);
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### SSRAdapter
|
|
252
|
+
|
|
253
|
+
Uses standard HTML img tags for server-side rendering environments.
|
|
135
254
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
size: "70%",
|
|
139
|
-
intensity: 0.8
|
|
140
|
-
});
|
|
255
|
+
```typescript
|
|
256
|
+
import { SSRImageComponent } from '@zuljaman/banner-components';
|
|
141
257
|
```
|
|
142
258
|
|
|
143
259
|
## TypeScript Support
|
|
@@ -145,59 +261,61 @@ const shadowStyle = createAbstractShadowStyle({
|
|
|
145
261
|
Full TypeScript definitions are included:
|
|
146
262
|
|
|
147
263
|
```typescript
|
|
148
|
-
import type {
|
|
264
|
+
import type {
|
|
149
265
|
BannerVisorProps,
|
|
150
|
-
|
|
266
|
+
CopyConfig,
|
|
151
267
|
PostType,
|
|
152
268
|
ImageProps,
|
|
153
|
-
|
|
269
|
+
CustomSubstyleConfig,
|
|
270
|
+
CustomStyle
|
|
154
271
|
} from '@zuljaman/banner-components';
|
|
155
272
|
```
|
|
156
273
|
|
|
157
|
-
##
|
|
274
|
+
## Advanced Hooks
|
|
158
275
|
|
|
159
|
-
|
|
160
|
-
import {
|
|
161
|
-
DEFAULT_BANNER_WIDTH,
|
|
162
|
-
DEFAULT_BANNER_HEIGHT,
|
|
163
|
-
DEFAULT_STORY_WIDTH,
|
|
164
|
-
DEFAULT_STORY_HEIGHT,
|
|
165
|
-
STYLE_FONT_CONFIGS
|
|
166
|
-
} from '@zuljaman/banner-components/constants';
|
|
167
|
-
```
|
|
276
|
+
The package includes several hooks for advanced use cases:
|
|
168
277
|
|
|
169
|
-
|
|
278
|
+
| Hook | Purpose |
|
|
279
|
+
|------|---------|
|
|
280
|
+
| `useAutoPositioning` | Manages element positioning chains |
|
|
281
|
+
| `useDragSnap` | Provides rotation and position snapping |
|
|
282
|
+
| `useLineDrawing` | Handles chain drawing interactions |
|
|
283
|
+
| `useProximityDetection` | Detects element proximity for linking |
|
|
170
284
|
|
|
171
|
-
|
|
285
|
+
## Migration Guide
|
|
172
286
|
|
|
173
|
-
|
|
287
|
+
### From Legacy copy1/copy2 Props
|
|
174
288
|
|
|
175
289
|
```typescript
|
|
176
290
|
// Before
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
291
|
+
<BannerVisor
|
|
292
|
+
copy1="Primary text"
|
|
293
|
+
copy2="Secondary text"
|
|
294
|
+
copy1FontSizeMultiplier={1.2}
|
|
295
|
+
copy2FontSizeMultiplier={1.0}
|
|
296
|
+
// ...
|
|
297
|
+
/>
|
|
298
|
+
|
|
299
|
+
// After (recommended)
|
|
300
|
+
<BannerVisor
|
|
301
|
+
copies={[
|
|
302
|
+
{ id: 'c1', text: 'Primary text', styleSlot: 0, fontSize: 1.2 },
|
|
303
|
+
{ id: 'c2', text: 'Secondary text', styleSlot: 1, fontSize: 1.0 }
|
|
304
|
+
]}
|
|
305
|
+
// ...
|
|
306
|
+
/>
|
|
185
307
|
```
|
|
186
308
|
|
|
187
|
-
### From
|
|
188
|
-
|
|
189
|
-
Replace existing imports:
|
|
309
|
+
### From Old Adapter Imports
|
|
190
310
|
|
|
191
311
|
```typescript
|
|
192
|
-
// Before
|
|
193
|
-
import {
|
|
194
|
-
|
|
195
|
-
// After
|
|
196
|
-
import { BannerVisor } from '@zuljaman/banner-components';
|
|
197
|
-
import { ImageComponent } from '@zuljaman/banner-components/adapters/SSRAdapter';
|
|
312
|
+
// Before (incorrect)
|
|
313
|
+
import { ImageComponent } from '@zuljaman/banner-components/adapters/NextJSAdapter';
|
|
198
314
|
|
|
199
|
-
//
|
|
200
|
-
|
|
315
|
+
// After (correct)
|
|
316
|
+
import NextImage from 'next/image';
|
|
317
|
+
import { createNextJSAdapter } from '@zuljaman/banner-components';
|
|
318
|
+
const ImageComponent = createNextJSAdapter(NextImage);
|
|
201
319
|
```
|
|
202
320
|
|
|
203
321
|
## Development
|
|
@@ -209,7 +327,7 @@ npm install
|
|
|
209
327
|
# Build the package
|
|
210
328
|
npm run build
|
|
211
329
|
|
|
212
|
-
#
|
|
330
|
+
# Run playground (development)
|
|
213
331
|
npm run dev
|
|
214
332
|
|
|
215
333
|
# Clean build artifacts
|
|
@@ -219,24 +337,3 @@ npm run clean
|
|
|
219
337
|
## License
|
|
220
338
|
|
|
221
339
|
MIT
|
|
222
|
-
|
|
223
|
-
## Contributing
|
|
224
|
-
|
|
225
|
-
This package consolidates banner components from multiple Zuljaman projects. When contributing:
|
|
226
|
-
|
|
227
|
-
1. Ensure changes maintain backward compatibility
|
|
228
|
-
2. Update TypeScript definitions
|
|
229
|
-
3. Test with both Next.js and AWS Lambda adapters
|
|
230
|
-
4. Follow existing code patterns and styling
|
|
231
|
-
|
|
232
|
-
## Architecture
|
|
233
|
-
|
|
234
|
-
The package uses an adapter pattern to handle platform-specific image components while maintaining shared logic for:
|
|
235
|
-
|
|
236
|
-
- Font size calculations
|
|
237
|
-
- Shadow effect generation
|
|
238
|
-
- Layout and styling
|
|
239
|
-
- Type definitions
|
|
240
|
-
- Constants and configurations
|
|
241
|
-
|
|
242
|
-
This approach ensures 100% code reuse while supporting platform-specific optimizations.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BannerRenderer component - Generic platform-agnostic banner renderer
|
|
3
|
+
* Unified component that handles all banner styles based on configuration
|
|
4
|
+
*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import type { BannerRendererProps } from "./types";
|
|
7
|
+
export declare const BannerRenderer: React.FC<BannerRendererProps>;
|
|
8
|
+
//# sourceMappingURL=BannerRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BannerRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/BannerRenderer/BannerRenderer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAA+C,MAAM,OAAO,CAAC;AASpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMnD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8gBxD,CAAC"}
|