Skip to content

Commit e268bb7

Browse files
stengithub-actions[bot]
authored andcommitted
Fix styling
1 parent 0cfb50c commit e268bb7

21 files changed

+189
-154
lines changed

config/filament-flexible-content-block-pages.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
|--------------------------------------------------------------------------
9393
|
9494
| It is possible to create different themes for the menu templates.
95-
| Creating a new theme is done by publishing the views and then creating
95+
| Creating a new theme is done by publishing the views and then creating
9696
| a new directory under resources/views/components/{theme}/menu.
9797
| You should then specify the name of your theme below.
9898
|
@@ -104,15 +104,15 @@
104104
// Models that can be linked in menu items
105105
// These models must implement HasMenuLabel interface
106106
\Statikbe\FilamentFlexibleContentBlockPages\Models\Page::class,
107-
107+
108108
// Add your own models here:
109109
// \App\Models\Category::class,
110110
// \App\Models\Product::class,
111111
],
112112
'model_icons' => [
113113
// Configure icons for different model types based on their morph class
114114
'filament-flexible-content-block-pages::page' => 'heroicon-o-document-text',
115-
115+
116116
// Add custom icons for your models:
117117
// 'category' => 'heroicon-o-tag',
118118
// 'product' => 'heroicon-o-shopping-bag',
@@ -124,7 +124,7 @@
124124
'horizontal',
125125
'vertical',
126126
'dropdown',
127-
127+
128128
// Add your custom styles here:
129129
// 'mega',
130130
// 'mobile',

src/Components/LanguageSwitch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public function render()
1212
{
1313
$theme = FilamentFlexibleContentBlockPages::config()->getMenuTheme();
1414
$template = "filament-flexible-content-block-pages::components.{$theme}.language-switch";
15-
15+
1616
// Check if the themed template exists, otherwise fallback to tailwind theme
1717
if (view()->exists($template)) {
1818
return view($template);
1919
}
20-
20+
2121
// Final fallback to tailwind theme
2222
return view('filament-flexible-content-block-pages::components.tailwind.language-switch');
2323
}

src/Components/Menu.php

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
class Menu extends Component
1010
{
1111
public $menu;
12+
1213
public $items;
14+
1315
public $locale;
16+
1417
public string $style;
1518

1619
public function __construct(
@@ -20,7 +23,7 @@ public function __construct(
2023
) {
2124
$this->menu = $this->getMenuByCode($code);
2225
$this->locale = $locale ?: app()->getLocale();
23-
26+
2427
// Determine the style to use with proper fallback chain
2528
if ($style) {
2629
$this->style = $style;
@@ -29,39 +32,39 @@ public function __construct(
2932
} else {
3033
$this->style = FilamentFlexibleContentBlockPages::config()->getDefaultMenuStyle();
3134
}
32-
35+
3336
$this->items = $this->menu ? $this->getMenuItems($this->menu, $this->locale) : [];
3437
}
3538

3639
public function render()
3740
{
3841
$theme = FilamentFlexibleContentBlockPages::config()->getMenuTheme();
3942
$template = "filament-flexible-content-block-pages::components.{$theme}.menu.{$this->style}";
40-
43+
4144
// Check if the themed style template exists, otherwise try default style in theme
4245
if (view()->exists($template)) {
4346
return view($template);
4447
}
45-
48+
4649
$defaultTemplate = "filament-flexible-content-block-pages::components.{$theme}.menu.default";
4750
if (view()->exists($defaultTemplate)) {
4851
return view($defaultTemplate);
4952
}
50-
53+
5154
// Final fallback to tailwind theme default
5255
return view('filament-flexible-content-block-pages::components.tailwind.menu.default');
5356
}
5457

5558
protected function getMenuByCode(string $code)
5659
{
5760
$menuModel = FilamentFlexibleContentBlockPages::config()->getMenuModel();
58-
61+
5962
return $menuModel::getByCode($code);
6063
}
6164

6265
protected function getMenuItems($menu, ?string $locale = null): array
6366
{
64-
if (!$menu) {
67+
if (! $menu) {
6568
return [];
6669
}
6770

@@ -76,33 +79,33 @@ protected function getMenuItems($menu, ?string $locale = null): array
7679
protected function buildMenuTree(array $items, ?string $locale = null, $parentId = null): array
7780
{
7881
$tree = [];
79-
82+
8083
foreach ($items as $item) {
8184
if ($item['parent_id'] == $parentId) {
8285
$processedItem = $this->processMenuItem($item, $locale);
8386
$children = $this->buildMenuTree($items, $locale, $item['id']);
84-
85-
if (!empty($children)) {
87+
88+
if (! empty($children)) {
8689
$processedItem['children'] = $children;
8790
$processedItem['has_children'] = true;
8891
} else {
8992
$processedItem['has_children'] = false;
9093
}
91-
94+
9295
$tree[] = $processedItem;
9396
}
9497
}
95-
98+
9699
return $tree;
97100
}
98101

99102
protected function processMenuItem(array $item, ?string $locale = null): array
100103
{
101104
$locale = $locale ?: app()->getLocale();
102-
105+
103106
// Get the display label
104107
$label = $item['label'][$locale] ?? $item['label'][config('app.fallback_locale', 'en')] ?? '';
105-
108+
106109
// If use_model_title is true and we have a linkable model, use its label
107110
if ($item['use_model_title'] && $item['linkable']) {
108111
$linkableModel = $this->getLinkableModel($item['linkable_type'], $item['linkable_id']);
@@ -113,10 +116,10 @@ protected function processMenuItem(array $item, ?string $locale = null): array
113116

114117
// Generate the URL
115118
$url = $this->generateMenuItemUrl($item);
116-
119+
117120
// Check if current page matches this menu item
118121
$isCurrent = $this->isCurrentMenuItem($item);
119-
122+
120123
return [
121124
'id' => $item['id'],
122125
'label' => $label,
@@ -134,14 +137,15 @@ protected function getLinkableModel(string $type, int $id)
134137
{
135138
try {
136139
$morphMap = FilamentFlexibleContentBlockPages::config()->getMorphMap();
137-
138-
if (!isset($morphMap[$type])) {
140+
141+
if (! isset($morphMap[$type])) {
139142
return null;
140143
}
141-
144+
142145
$modelClass = $morphMap[$type];
146+
143147
return $modelClass::find($id);
144-
148+
145149
} catch (\Exception $e) {
146150
return null;
147151
}
@@ -152,28 +156,30 @@ protected function generateMenuItemUrl(array $item): string
152156
switch ($item['link_type']) {
153157
case 'url':
154158
return $item['url'] ?? '#';
155-
159+
156160
case 'route':
157161
try {
158162
$routeName = $item['route'] ?? '';
159163
if (empty($routeName)) {
160164
return '#';
161165
}
162-
166+
163167
$parameters = $item['route_parameters'] ?? [];
168+
164169
return route($routeName, $parameters);
165-
170+
166171
} catch (\Exception $e) {
167172
return '#';
168173
}
169-
174+
170175
case 'model':
171176
$linkableModel = $this->getLinkableModel($item['linkable_type'], $item['linkable_id']);
172177
if ($linkableModel && method_exists($linkableModel, 'getUrl')) {
173178
return $linkableModel->getUrl();
174179
}
180+
175181
return '#';
176-
182+
177183
default:
178184
return '#';
179185
}
@@ -183,15 +189,15 @@ protected function isCurrentMenuItem(array $item): bool
183189
{
184190
$currentUrl = request()->url();
185191
$itemUrl = $this->generateMenuItemUrl($item);
186-
192+
187193
// Remove trailing slashes for comparison
188194
$currentUrl = rtrim($currentUrl, '/');
189195
$itemUrl = rtrim($itemUrl, '/');
190-
196+
191197
if ($itemUrl === '#' || empty($itemUrl)) {
192198
return false;
193199
}
194-
200+
195201
return $currentUrl === $itemUrl;
196202
}
197203

@@ -200,13 +206,13 @@ public function hasActiveChildren(array $item): bool
200206
if (empty($item['children'])) {
201207
return false;
202208
}
203-
209+
204210
foreach ($item['children'] as $child) {
205211
if ($child['is_current'] || $this->hasActiveChildren($child)) {
206212
return true;
207213
}
208214
}
209-
215+
210216
return false;
211217
}
212-
}
218+
}

src/Components/MenuItem.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class MenuItem extends Component
99
{
1010
public array $item;
11+
1112
public string $style;
1213

1314
public function __construct(
@@ -22,17 +23,17 @@ public function render()
2223
{
2324
$theme = FilamentFlexibleContentBlockPages::config()->getMenuTheme();
2425
$template = "filament-flexible-content-block-pages::components.{$theme}.menu.{$this->style}-item";
25-
26+
2627
// Check if the themed style item template exists, otherwise try default item in theme
2728
if (view()->exists($template)) {
2829
return view($template);
2930
}
30-
31+
3132
$defaultTemplate = "filament-flexible-content-block-pages::components.{$theme}.menu.default-item";
3233
if (view()->exists($defaultTemplate)) {
3334
return view($defaultTemplate);
3435
}
35-
36+
3637
// Final fallback to tailwind theme default
3738
return view('filament-flexible-content-block-pages::components.tailwind.menu.default-item');
3839
}
@@ -45,9 +46,9 @@ public function getDataAttributes(): string
4546

4647
$attributes = '';
4748
foreach ($this->item['data_attributes'] as $key => $value) {
48-
$attributes .= ' data-' . e($key) . '="' . e($value) . '"';
49+
$attributes .= ' data-'.e($key).'="'.e($value).'"';
4950
}
50-
51+
5152
return $attributes;
5253
}
53-
}
54+
}

src/Filament/Form/Components/MenuTreeBuilder.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Statikbe\FilamentFlexibleContentBlockPages\Filament\Form\Components;
44

55
use Filament\Forms\Components\Field;
6-
use Filament\Forms\Components\Component;
76
use Filament\Support\Concerns\HasExtraAlpineAttributes;
87
use Statikbe\FilamentFlexibleContentBlockPages\Facades\FilamentFlexibleContentBlockPages;
98

@@ -43,13 +42,13 @@ public function getMenuId(): ?int
4342

4443
public function getMenuItems(): array
4544
{
46-
if (!$this->menuId) {
45+
if (! $this->menuId) {
4746
return [];
4847
}
4948

5049
$menu = FilamentFlexibleContentBlockPages::config()->getMenuModel()::find($this->menuId);
5150

52-
if (!$menu) {
51+
if (! $menu) {
5352
return [];
5453
}
5554

@@ -68,7 +67,7 @@ protected function buildTree(array $items, $parentId = null): array
6867
foreach ($items as $item) {
6968
if ($item['parent_id'] == $parentId) {
7069
$children = $this->buildTree($items, $item['id']);
71-
if (!empty($children)) {
70+
if (! empty($children)) {
7271
$item['children'] = $children;
7372
}
7473
$tree[] = $item;

0 commit comments

Comments
 (0)