Skip to content

Commit d171cd4

Browse files
committed
refactor: move theme config to root level and improve menu UX
- Move theme configuration from menu.theme to root-level theme in config - Update all components to use new getTheme() method instead of getMenuTheme() - Remove deprecated getMenuTheme() method from config class - Add redirect to list view after saving menus in MenuResource - Clean up unused manage-menu-items-old.blade.php backup file
1 parent 0cfb50c commit d171cd4

24 files changed

+577
-294
lines changed

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,38 +81,40 @@
8181

8282
'route_helper' => \Statikbe\FilamentFlexibleContentBlockPages\Routes\LocalisedPageRouteHelper::class,
8383

84+
/*
85+
|--------------------------------------------------------------------------
86+
| Theme
87+
|--------------------------------------------------------------------------
88+
|
89+
| It is possible to create different themes for templates (pages, layouts,
90+
| menus, language switch components). Creating a new theme is done by
91+
| publishing the views and then creating a new directory under
92+
| resources/views/components/{theme}. You should then specify the name
93+
| of your theme below.
94+
|
95+
*/
96+
'theme' => 'tailwind',
97+
8498
'page_templates' => [
8599
// Page::HOME_PAGE => 'pages.home',
86100
],
87101

88102
'menu' => [
89-
/*
90-
|--------------------------------------------------------------------------
91-
| Menu Theme
92-
|--------------------------------------------------------------------------
93-
|
94-
| 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
96-
| a new directory under resources/views/components/{theme}/menu.
97-
| You should then specify the name of your theme below.
98-
|
99-
*/
100-
'theme' => 'tailwind',
101103

102104
'max_depth' => 2,
103105
'linkable_models' => [
104106
// Models that can be linked in menu items
105107
// These models must implement HasMenuLabel interface
106108
\Statikbe\FilamentFlexibleContentBlockPages\Models\Page::class,
107-
109+
108110
// Add your own models here:
109111
// \App\Models\Category::class,
110112
// \App\Models\Product::class,
111113
],
112114
'model_icons' => [
113115
// Configure icons for different model types based on their morph class
114116
'filament-flexible-content-block-pages::page' => 'heroicon-o-document-text',
115-
117+
116118
// Add custom icons for your models:
117119
// 'category' => 'heroicon-o-tag',
118120
// 'product' => 'heroicon-o-shopping-bag',
@@ -124,7 +126,7 @@
124126
'horizontal',
125127
'vertical',
126128
'dropdown',
127-
129+
128130
// Add your custom styles here:
129131
// 'mega',
130132
// 'mobile',

resources/lang/en/filament-flexible-content-block-pages.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@
128128
'delete_failed' => 'Failed to delete menu item: :error',
129129
'reorder_failed' => 'Failed to reorder menu items: :error',
130130
'move_failed' => 'Failed to move menu item: :error',
131+
'create_failed' => 'Failed to create menu item: :error',
132+
'update_failed' => 'Failed to update menu item: :error',
131133
'general_error' => 'An error occurred: :error',
132134
],
133135
'messages' => [
134136
'item_deleted' => 'Menu item successfully deleted.',
135137
'item_and_children_deleted' => 'Menu item and all children successfully deleted.',
136138
'items_reordered' => 'Menu items successfully reordered.',
137139
'item_moved' => 'Menu item successfully moved.',
140+
'item_created' => 'Menu item successfully created.',
141+
'item_updated' => 'Menu item successfully updated.',
138142
],
139143
'form' => [
140144
'link_type_lbl' => 'Link Type',

resources/lang/nl/filament-flexible-content-block-pages.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@
128128
'delete_failed' => 'Verwijderen van menu-item mislukt: :error',
129129
'reorder_failed' => 'Herordenen van menu-items mislukt: :error',
130130
'move_failed' => 'Verplaatsen van menu-item mislukt: :error',
131+
'create_failed' => 'Aanmaken van menu-item mislukt: :error',
132+
'update_failed' => 'Bijwerken van menu-item mislukt: :error',
131133
'general_error' => 'Er is een fout opgetreden: :error',
132134
],
133135
'messages' => [
134136
'item_deleted' => 'Menu-item succesvol verwijderd.',
135137
'item_and_children_deleted' => 'Menu-item en alle subitems succesvol verwijderd.',
136138
'items_reordered' => 'Menu-items succesvol herordend.',
137139
'item_moved' => 'Menu-item succesvol verplaatst.',
140+
'item_created' => 'Menu-item succesvol aangemaakt.',
141+
'item_updated' => 'Menu-item succesvol bijgewerkt.',
138142
],
139143
'form' => [
140144
'link_type_lbl' => 'Link Type',

resources/views/filament/resources/menu-resource/pages/manage-menu-items.blade.php

Lines changed: 11 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,6 @@
88
x-init="init()"
99
class="space-y-6"
1010
>
11-
<!-- Header Actions -->
12-
<div class="flex items-center justify-between">
13-
<div>
14-
<h2 class="text-lg font-medium text-gray-900 dark:text-white">
15-
{{ flexiblePagesTrans('menu_items.manage.subtitle') }}
16-
</h2>
17-
<p class="text-sm text-gray-500 dark:text-gray-400">
18-
{{ flexiblePagesTrans('menu_items.manage.description') }}
19-
</p>
20-
</div>
21-
<x-filament::button
22-
@click="addMenuItem(null)"
23-
icon="heroicon-o-plus"
24-
color="primary"
25-
>
26-
{{ flexiblePagesTrans('menu_items.tree.add_item') }}
27-
</x-filament::button>
28-
</div>
29-
3011
<!-- Tree Container -->
3112
<x-filament::section>
3213
<div class="min-h-[400px]">
@@ -41,15 +22,6 @@ class="space-y-6"
4122
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
4223
{{ flexiblePagesTrans('menu_items.manage.empty_description') }}
4324
</p>
44-
<div class="mt-6">
45-
<x-filament::button
46-
@click="addMenuItem(null)"
47-
icon="heroicon-o-plus"
48-
color="primary"
49-
>
50-
{{ flexiblePagesTrans('menu_items.tree.add_item') }}
51-
</x-filament::button>
52-
</div>
5325
</div>
5426

5527
<!-- Tree Items -->
@@ -89,7 +61,6 @@ function menuItemsManager(config) {
8961
9062
init() {
9163
this.initSortable();
92-
this.listenForUpdates();
9364
},
9465
9566
initSortable() {
@@ -110,12 +81,6 @@ function menuItemsManager(config) {
11081
}
11182
},
11283
113-
listenForUpdates() {
114-
this.$wire.on('menu-items-updated', () => {
115-
this.refreshItems();
116-
});
117-
},
118-
11984
renderTreeItem(item, depth) {
12085
const canHaveChildren = depth < this.maxDepth;
12186
const hasChildren = item.children && item.children.length > 0;
@@ -149,31 +114,19 @@ function menuItemsManager(config) {
149114
<!-- Actions -->
150115
<div class="flex items-center space-x-2 opacity-0 group-hover:opacity-100 transition-opacity">
151116
${canHaveChildren ? `
152-
<x-filament::button
153-
@click="addMenuItem(${item.id})"
154-
size="xs"
155-
color="gray"
156-
outlined
157-
>
117+
<button onclick="$wire.addMenuItem(${item.id})"
118+
class="inline-flex items-center px-2 py-1 border border-gray-300 rounded text-xs font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
158119
{{ flexiblePagesTrans('menu_items.tree.add_child') }}
159-
</x-filament::button>
120+
</button>
160121
` : ''}
161-
<x-filament::button
162-
@click="editMenuItem(${item.id})"
163-
size="xs"
164-
color="primary"
165-
outlined
166-
>
122+
<button onclick="$wire.editMenuItem(${item.id})"
123+
class="inline-flex items-center px-2 py-1 border border-primary-300 rounded text-xs font-medium text-primary-700 bg-primary-50 hover:bg-primary-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
167124
{{ flexiblePagesTrans('menu_items.tree.edit') }}
168-
</x-filament::button>
169-
<x-filament::button
170-
@click="deleteMenuItem(${item.id})"
171-
size="xs"
172-
color="danger"
173-
outlined
174-
>
125+
</button>
126+
<button onclick="$wire.deleteMenuItem(${item.id})"
127+
class="inline-flex items-center px-2 py-1 border border-red-300 rounded text-xs font-medium text-red-700 bg-red-50 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
175128
{{ flexiblePagesTrans('menu_items.tree.delete') }}
176-
</x-filament::button>
129+
</button>
177130
</div>
178131
</div>
179132
</div>
@@ -204,23 +157,6 @@ function menuItemsManager(config) {
204157
return '{{ flexiblePagesTrans('menu_items.tree.no_link') }}';
205158
},
206159
207-
addMenuItem(parentId) {
208-
this.$wire.call('addMenuItem', parentId);
209-
},
210-
211-
editMenuItem(itemId) {
212-
this.$wire.call('editMenuItem', itemId);
213-
},
214-
215-
deleteMenuItem(itemId) {
216-
if (confirm('{{ flexiblePagesTrans('menu_items.tree.delete_confirm') }}')) {
217-
this.loading = true;
218-
this.$wire.call('deleteMenuItem', itemId).then(() => {
219-
this.loading = false;
220-
});
221-
}
222-
},
223-
224160
reorderItems(oldIndex, newIndex) {
225161
// Move item in array
226162
const item = this.items.splice(oldIndex, 1)[0];
@@ -231,17 +167,9 @@ function menuItemsManager(config) {
231167
this.loading = true;
232168
this.$wire.call('reorderMenuItems', orderedIds).then(() => {
233169
this.loading = false;
170+
// Refresh items to get updated structure
171+
location.reload();
234172
});
235-
},
236-
237-
async refreshItems() {
238-
this.loading = true;
239-
try {
240-
const response = await this.$wire.call('getMenuItems');
241-
this.items = response;
242-
} finally {
243-
this.loading = false;
244-
}
245173
}
246174
}
247175
}

src/Components/LanguageSwitch.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class LanguageSwitch extends Component
1010
{
1111
public function render()
1212
{
13-
$theme = FilamentFlexibleContentBlockPages::config()->getMenuTheme();
13+
$theme = FilamentFlexibleContentBlockPages::config()->getTheme();
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
}

0 commit comments

Comments
 (0)