`;
- // Create container with template styles
+ // Create container with proper layout
bannerContent = `
-
- ${imgElement}
- ${textElement}
+
+ ${imagePosition === 'left' || imagePosition === 'top' ? imgContainer : ''}
+
+ ${textElement}
+
+ ${imagePosition === 'right' || imagePosition === 'bottom' ? imgContainer : ''}
`;
// Show the image preview in the container
diff --git a/index.html b/index.html
index 7d21f65..3cc8fb9 100644
--- a/index.html
+++ b/index.html
@@ -36,63 +36,104 @@
// Apply styles to container
bannerContainer.style.borderRadius = (banner.style.borderRadius ? `${banner.style.borderRadius}px` : '8px');
- // Apply styles to content
- Object.assign(bannerContent.style, {
- backgroundColor: banner.style.backgroundColor || '#f8d7da',
- color: banner.style.textColor || '#721c24',
- textAlign: banner.style.textAlign || 'center',
- fontSize: banner.style.fontSize ? `${banner.style.fontSize}px` : '18px',
- padding: banner.style.padding ? `${banner.style.padding}px` : '20px',
- margin: banner.style.margin ? `${banner.style.margin}px 0` : '20px 0',
- borderRadius: banner.style.borderRadius ? `${banner.style.borderRadius}px` : '8px',
- boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
- display: 'block'
- });
-
// Handle image
- let content = banner.text || '';
+ let content = '';
if (banner.image) {
- // Apply the same border radius to the image as to the container
- const imageRadius = Math.max(parseInt(banner.style.borderRadius || '4'), 0);
+ const imagePosition = banner.style.imagePosition || 'right';
+ const imageWidth = banner.style.imageWidth || 300;
+ const imageHeight = banner.style.imageHeight || 200;
- // Determine image style based on position
- let imageStyle = `max-width: 100%; max-height: 200px; border-radius: ${imageRadius}px;`;
- let containerStyle = 'margin-bottom: 15px;';
+ // Create image element with styles
+ const imgStyle = `
+ max-width: 100%;
+ height: auto;
+ width: ${imageWidth}px;
+ max-height: ${imageHeight}px;
+ object-fit: contain;
+ border-radius: ${banner.style.borderRadius || '0'}px;
+ ${imagePosition === 'left' ? 'float: left; margin-right: 20px;' : ''}
+ ${imagePosition === 'right' ? 'float: right; margin-left: 20px;' : ''}
+ ${imagePosition === 'center' ? 'display: block; margin: 0 auto;' : ''}
+ `;
- // Get image position data
- const imagePosition = banner.style.imagePosition || 'center';
- const imageX = banner.style.imageX || '0';
- const imageY = banner.style.imageY || '0';
-
- console.log('Applying image position:', imagePosition, imageX, imageY);
-
- switch(imagePosition) {
- case 'left':
- containerStyle += 'text-align: left; float: left; margin-right: 15px;';
- break;
- case 'right':
- containerStyle += 'text-align: right; float: right; margin-left: 15px;';
- break;
- case 'custom':
- containerStyle += 'position: relative;';
- // For custom position, use absolute positioning to ensure exact placement
- imageStyle += `position: absolute; left: ${imageX}px; top: ${imageY}px;`;
- break;
- default: // center
- containerStyle += `text-align: ${banner.style.textAlign || 'center'};`;
+ // Create image container
+ let imgContainer = `
+
+

+
`;
+
+ // Wrap image with link if URL is provided
+ if (banner.link) {
+ imgContainer = `
+
+ ${imgContainer}
+ `;
}
- content = `
-
-

-
- ${content}
+ // Create text content with styles
+ const textStyle = `
+ font-size: ${banner.style.fontSize || '16px'};
+ color: ${banner.style.textColor || '#000'};
+ text-align: ${banner.style.textAlign || 'left'};
+ margin: 0;
+ padding: 10px 0;
+ line-height: 1.5;
`;
- }
-
- // Wrap in link if provided
- if (banner.link) {
- content = `
${content}`;
+
+ const textElement = `
+
+ ${banner.text || ''}
+
`;
+
+ // Create container with proper layout
+ content = `
+
+ ${imagePosition === 'left' || imagePosition === 'top' ? imgContainer : ''}
+
+ ${textElement}
+
+ ${imagePosition === 'right' || imagePosition === 'bottom' ? imgContainer : ''}
+
`;
+ } else {
+ // No image, just show text
+ content = `
+
+
+ ${banner.text || 'Žádný text banneru'}
+
+
`;
}
bannerContent.innerHTML = content;