Implemented a block editor for changing the layout of the page
This commit is contained in:
30
resources/views/components/blocks/text.blade.php
Normal file
30
resources/views/components/blocks/text.blade.php
Normal file
@@ -0,0 +1,30 @@
|
||||
@props(['block'])
|
||||
|
||||
@php
|
||||
/** @var \App\Models\PageBlock $block */
|
||||
$c = $block->content ?? [];
|
||||
$size = (string) data_get($c, 'text_size', 'base');
|
||||
$align = (string) data_get($c, 'text_alignment', 'center');
|
||||
$sizeClass = match ($size) {
|
||||
'sm' => 'text-sm sm:text-[15px]',
|
||||
'lg' => 'text-lg sm:text-xl',
|
||||
default => 'text-[15px] sm:text-base',
|
||||
};
|
||||
$alignClass = match ($align) {
|
||||
'left' => 'text-left',
|
||||
'right' => 'text-right',
|
||||
default => 'text-center',
|
||||
};
|
||||
$bodyRaw = data_get($c, 'body');
|
||||
$body = is_string($bodyRaw) ? trim($bodyRaw) : '';
|
||||
@endphp
|
||||
|
||||
{{-- Body must be on one line inside the div: whitespace-pre-line turns indentation/newlines around {{ $body }} into visible gaps. --}}
|
||||
<div class="w-full space-y-3" x-show="phase !== 'thanks'" x-cloak>
|
||||
@if (filled(data_get($c, 'title')))
|
||||
<h2 class="{{ $alignClass }} text-lg font-semibold text-white sm:text-xl">{{ data_get($c, 'title') }}</h2>
|
||||
@endif
|
||||
@if ($body !== '')
|
||||
<div class="{{ $alignClass }} {{ $sizeClass }} whitespace-pre-line leading-relaxed text-white/90">{{ $body }}</div>
|
||||
@endif
|
||||
</div>
|
||||
Reference in New Issue
Block a user