-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
308 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
Database/Migrations/2023_07_05_150102_create_menus_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Modules\Xot\Database\Migrations\XotBaseMigration; | ||
|
||
/** | ||
* Class . | ||
*/ | ||
class CreateMenusTable extends XotBaseMigration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// -- CREATE -- | ||
$this->tableCreate( | ||
static function (Blueprint $table): void { | ||
$table->id(); | ||
|
||
$table->string('name'); | ||
$table->text('items')->nullable(); | ||
// $table->timestamps(); | ||
} | ||
); | ||
// -- UPDATE -- | ||
$this->tableUpdate( | ||
function (Blueprint $table): void { | ||
// if (! $this->hasColumn('order_column')) { | ||
// $table->integer('order_column')->nullable(); | ||
// } | ||
$this->updateTimestamps(table: $table, hasSoftDeletes: false); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Modules\UI\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Menu extends Model | ||
{ | ||
protected $fillable = [ | ||
'name', | ||
'items', | ||
]; | ||
|
||
protected $casts = [ | ||
'items' => 'array', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<ul class="ml-auto flex items-center space-x-4"> | ||
@foreach ($menu->items as $item) | ||
<li> | ||
<a | ||
href="{{ $item['url'] }}" | ||
@if ($item['type'] === 'external') target="_blank" @endif | ||
> | ||
{{ $item['title'] }} | ||
</a> | ||
</li> | ||
@endforeach | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@props(['image' => '']) | ||
|
||
@php | ||
$background = $image ? 'bg-black' : 'bg-gray-100'; | ||
@endphp | ||
|
||
<div class="relative min-h-[200px] flex items-center justify-center {{ $background }}"> | ||
@if ($image) | ||
<div | ||
class="absolute inset-0 z-0 opacity-50" | ||
style="background-image: url({{ $image }}); background-size: cover; background-position: center;" | ||
></div> | ||
@endif | ||
|
||
<div class="relative z-1 p-2 text-4xl text-gray-700 lg:text-6xl"> | ||
{!! $slot !!} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@props(['label']) | ||
|
||
<button | ||
type="submit" | ||
class="inline-flex justify-center rounded-md border border-transparent bg-green-700 py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-700 focus:ring-offset-2" | ||
{{ $attributes }} | ||
> | ||
{{ $label }} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@props(['post']) | ||
|
||
<div> | ||
<a class="block text-black" href="{{ route('post.show', ['slug' => $post->slug]) }}"> | ||
<img | ||
class="h-[200px] w-full object-cover object-center bg-gray-100" | ||
src="{{ $post->getMainImage() }}" | ||
alt="" | ||
loading="lazy" | ||
> | ||
<h2 class="mt-3 text-xl">{{ $post->title }}</h2> | ||
</a> | ||
<div class="mt-1"> | ||
<x-post-meta :post="$post" /> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div {{ $attributes->merge(['class' => 'max-w-wide mx-auto p-2']) }}> | ||
{!! $slot !!} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@props([ | ||
'name', | ||
'label', | ||
'id' => '', | ||
'type' => 'text', | ||
]) | ||
|
||
@php | ||
$id = $id ?: "{$name}_input"; | ||
@endphp | ||
|
||
<div> | ||
<label for="{{ $id }}" class="block text-sm font-medium text-gray-700">{{ $label }}</label> | ||
|
||
<input | ||
type="{{ $type }}" | ||
name="{{ $name }}" | ||
id="{{ $id }}" | ||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-green-700 focus:ring-green-700 sm:text-sm" | ||
{{ $attributes }} | ||
/> | ||
|
||
@error($name) | ||
<div class="mt-1 text-red-500">{{ $message }}</div> | ||
@enderror | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@props(['name']) | ||
|
||
@if ($menu = \App\Models\Menu::whereName($name)->first()) | ||
<ul class="ml-auto flex items-center space-x-4"> | ||
@foreach ($menu->items as $item) | ||
<li> | ||
<a | ||
href="{{ $item['url'] }}" | ||
@if ($item['type'] === 'external') target="_blank" @endif | ||
> | ||
{{ $item['title'] }} | ||
</a> | ||
</li> | ||
@endforeach | ||
</ul> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@props(['blocks']) | ||
|
||
@if ($blocks) | ||
<div> | ||
<h2>See also</h2> | ||
|
||
<div class="grid gap-4 grid-cols-1 sm:grid-cols-2"> | ||
<x-render-blocks :blocks="$blocks" /> | ||
</div> | ||
</div> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@props(['post']) | ||
|
||
@if ($post->published_at) | ||
Published on {{ $post->published_at->format('M jS, Y') }} — | ||
in <a href="{{ route('post.index', ['category' => $post->category->slug]) }}">{{ $post->category->name }}</a> | ||
@else | ||
[Not published] | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@props(['block']) | ||
|
||
@component("components.blocks.{$block['type']}", $block['data'] ?? []) @endcomponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@props(['blocks']) | ||
|
||
@foreach ($blocks as $block) | ||
<x-render-block :block="$block" /> | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@props([ | ||
'name', | ||
'label' => '', | ||
'id' => '', | ||
]) | ||
|
||
@php | ||
$id = $id ?: "{$name}_input"; | ||
@endphp | ||
|
||
<div> | ||
@if ($label) | ||
<label for="{{ $id }}" class="mb-1 block text-sm font-medium text-gray-700">{{ $label }}</label> | ||
@endif | ||
|
||
<select | ||
name="{{ $name }}" | ||
id="{{ $id }}" | ||
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-green-700 focus:ring-green-700 sm:text-sm" | ||
{{ $attributes }} | ||
> | ||
{!! $slot !!} | ||
</select> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@props([ | ||
'name', | ||
'label', | ||
'id' => '', | ||
]) | ||
|
||
@php | ||
$id = $id ?: "{$name}_input"; | ||
@endphp | ||
|
||
<div> | ||
<label for="{{ $id }}" class="block text-sm font-medium text-gray-700">{{ $label }}</label> | ||
|
||
<textarea | ||
name="{{ $name }}" | ||
id="{{ $id }}" | ||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-green-700 focus:ring-green-700 sm:text-sm" | ||
{{ $attributes }} | ||
></textarea> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Modules\UI\View\Components; | ||
|
||
use Illuminate\Contracts\Support\Renderable; | ||
use Illuminate\View\Component; | ||
use Modules\UI\Models\Menu as MenuModel; | ||
use Modules\Xot\Actions\GetViewAction; | ||
|
||
// use Modules\Xot\View\Components\XotBaseComponent; | ||
|
||
/** | ||
* . | ||
*/ | ||
class Menu extends Component | ||
{ | ||
public function __construct( | ||
public string $name, | ||
public string $tpl = 'v1') | ||
{ | ||
} | ||
|
||
public function render(): Renderable | ||
{ | ||
/** | ||
* @phpstan-var view-string | ||
*/ | ||
$view = app(GetViewAction::class)->execute($this->tpl); | ||
$menu = MenuModel::firstOrCreate(['name' => $this->name]); | ||
$view_params = [ | ||
'menu' => $menu, | ||
]; | ||
if (null === $menu->items) { | ||
$menu->items = []; | ||
$menu->save(); | ||
} | ||
|
||
return view($view, $view_params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Modules\UI\View\Components; | ||
|
||
use Illuminate\Contracts\Support\Renderable; | ||
use Illuminate\View\Component; | ||
use Modules\Blog\Models\Post; | ||
use Modules\Xot\Actions\GetViewAction; | ||
|
||
// use Modules\Xot\View\Components\XotBaseComponent; | ||
|
||
/** | ||
* . | ||
*/ | ||
class Std extends Component | ||
{ | ||
public function __construct( | ||
// public Post $article, | ||
// public bool $showAuthor = false, | ||
public string $tpl = 'v1') | ||
{ | ||
} | ||
|
||
public function render(): Renderable | ||
{ | ||
/** | ||
* @phpstan-var view-string | ||
*/ | ||
$view = app(GetViewAction::class)->execute($this->tpl); | ||
|
||
$view_params = []; | ||
|
||
return view($view, $view_params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"class_name":"BreadLink","comp_name":"bread-link","comp_ns":"Modules\\UI\\View\\Components\\BreadLink"},{"class_name":"Svg","comp_name":"svg","comp_ns":"Modules\\UI\\View\\Components\\Svg"}] | ||
[{"class_name":"BreadLink","comp_name":"bread-link","comp_ns":"Modules\\UI\\View\\Components\\BreadLink"},{"class_name":"Menu","comp_name":"menu","comp_ns":"Modules\\UI\\View\\Components\\Menu"},{"class_name":"Std","comp_name":"std","comp_ns":"Modules\\UI\\View\\Components\\Std"},{"class_name":"Svg","comp_name":"svg","comp_ns":"Modules\\UI\\View\\Components\\Svg"}] |