From 62f7ac7301f161c836cdab178523dbdd057743c6 Mon Sep 17 00:00:00 2001 From: Jakub Dorfman Date: Wed, 20 May 2026 16:49:55 +0200 Subject: [PATCH] Refactored SegmentedControl Visual Changes --- app/src/lib/admin/blockDefaults.ts | 2 +- app/src/lib/admin/editors/BlockEditor.svelte | 225 ++++++++++-------- .../lib/admin/editors/ImageUploader.svelte | 4 +- .../lib/admin/editors/SegmentedControl.svelte | 38 +++ 4 files changed, 164 insertions(+), 105 deletions(-) create mode 100644 app/src/lib/admin/editors/SegmentedControl.svelte diff --git a/app/src/lib/admin/blockDefaults.ts b/app/src/lib/admin/blockDefaults.ts index 5e48599..c3e86de 100644 --- a/app/src/lib/admin/blockDefaults.ts +++ b/app/src/lib/admin/blockDefaults.ts @@ -45,6 +45,6 @@ export function createBlock(type: BlockType): ContentBlock { base.data = { height: 64 }; break; } - base.data._background = { type: 'none', color: '', imageUrl: '', attachment: 'scroll', overlay: false, overlayOpacity: 40 }; + base.data._background = { type: 'none', color: '', attachment: 'scroll', overlay: false, overlayOpacity: 40 }; return base; } diff --git a/app/src/lib/admin/editors/BlockEditor.svelte b/app/src/lib/admin/editors/BlockEditor.svelte index d3677de..4de5800 100644 --- a/app/src/lib/admin/editors/BlockEditor.svelte +++ b/app/src/lib/admin/editors/BlockEditor.svelte @@ -3,6 +3,8 @@ import { blockLabels } from '$lib/admin/blockDefaults'; import RichTextEditor from './RichTextEditor.svelte'; import ImageUploader from './ImageUploader.svelte'; + import SegmentedControl from './SegmentedControl.svelte'; + import SpacerBlock from '../../blocks/SpacerBlock.svelte'; let { block, onChange = (block: ContentBlock) => {} } = $props<{ block: ContentBlock | null; @@ -62,12 +64,22 @@ {/each} {:else if block.type === 'hero'} - {#each ['heading', 'subheading', 'buttonLabel', 'buttonUrl', 'backgroundImage'] as field} - - {/each} + + + + {:else if block.type === 'button'}
-
- Variant -
- - -
-
+ updateData({ variant: v })} + />
-
- Alignment -
- - - -
-
+ updateData({ alignment: v })} + formatLabel={(v) => v.charAt(0).toUpperCase() + v.slice(1)} + />
-
- Size -
- - - - -
-
+ updateData({ size: v })} + formatLabel={(v) => ({ xs: 'Extra Small', sm: 'Small', md: 'Medium', lg: 'Large' }[v] || v)} + />
@@ -127,80 +135,93 @@
{/if} -
+
-
- Background settings -
- - - {#if (block.data._background?.type) === 'color'} - - - {/if} - - {#if (block.data._background?.type) === 'image'} - - - - {#if block.data._background?.overlay} - - {/if} - {/if} + +
+ updateData({ _background: { ...(block.data._background || {}), type: v } })} + />
-
-
- Foreground settings -
- - - - -
-
+ {#if block.data._background?.type === 'color'} +
+ +
+ {/if} + + {#if block.data._background?.type === 'image'} +
+ updateData({ _background: { ...(block.data._background || {}), imageUrl: image.url, imageAlt: image.alt } })} /> + + updateData({ _background: { ...(block.data._background || {}), attachment: v } })} + /> + + updateData({ _background: { ...(block.data._background || {}), overlay: true, overlayOpacity: v } })} + formatLabel={(v) => `${v}%`} + /> +
+ {/if} + +
+ + updateData({ _foreground: { ...(block.data._foreground || {}), mode: v } })} + /> + + {#if block.data._foreground?.mode === 'custom'} +
+
+
+ Heading +
+ updateData({ _foreground: { ...(block.data._foreground || {}), headingColor: e.currentTarget.value } })} /> + updateData({ _foreground: { ...(block.data._foreground || {}), headingColor: e.currentTarget.value } })} /> +
+
+
+
+
+ Sub heading +
+ updateData({ _foreground: { ...(block.data._foreground || {}), subheadingColor: e.currentTarget.value } })} /> + updateData({ _foreground: { ...(block.data._foreground || {}), subheadingColor: e.currentTarget.value } })} /> +
+
+
+
+
+ Text +
+ updateData({ _foreground: { ...(block.data._foreground || {}), textColor: e.currentTarget.value } })} /> + updateData({ _foreground: { ...(block.data._foreground || {}), textColor: e.currentTarget.value } })} /> +
+
+
+
+ {/if} +
{/if} diff --git a/app/src/lib/admin/editors/ImageUploader.svelte b/app/src/lib/admin/editors/ImageUploader.svelte index 42da314..3eed305 100644 --- a/app/src/lib/admin/editors/ImageUploader.svelte +++ b/app/src/lib/admin/editors/ImageUploader.svelte @@ -50,7 +50,7 @@
fileInput?.click()} @@ -61,7 +61,7 @@

Uploading…

{:else if localUrl}
- {localAlt} + {localAlt} + {/each} +
+
+
\ No newline at end of file