tomatophp/filament-simple-theme
composer require tomatophp/filament-simple-theme
php artisan filament-simple-theme:install
npm i && npm run dev
config/app.php under providers:
Tomato\FilamentSimpleTheme\FilamentSimpleThemeServiceProvider::class,
Publish the config (optional):
php artisan vendor:publish --provider="Tomato\FilamentSimpleTheme\FilamentSimpleThemeServiceProvider"
AppServiceProvider or a Filament panel configuration:
use Tomato\FilamentSimpleTheme\Facades\FilamentSimpleTheme;
public function boot(): void
{
FilamentSimpleTheme::enable();
}
Or enable it for a specific Filament panel:
Filament::serving(function () {
FilamentSimpleTheme::enable();
});
Theme Activation:
FilamentSimpleTheme::enable() in AppServiceProvider or a Filament panel config.Filament::serving(function () {
if (auth()->user()->isAdmin()) {
FilamentSimpleTheme::enable();
}
});
Customizing the Sidebar User Menu:
php artisan vendor:publish --tag="filament-simple-theme-views"
resources/views/vendor/filament-simple-theme/partials/sidebar-user-menu.blade.php to add/remove items (e.g., profile, settings, or custom links).<div class="space-y-1">
<x-filament::dropdown-list-item icon="heroicon-o-cog-8-tooth" :label="__('Settings')" />
<x-filament::dropdown-list-item icon="heroicon-o-arrow-left-on-rectangle" :label="__('Logout')" />
<!-- Add custom items -->
<x-filament::dropdown-list-item icon="heroicon-o-bell" :label="__('Notifications')" href="{{ route('notifications.index') }}" />
</div>
Dark Mode Integration:
darkMode config is set:
Filament::make('AdminPanel', [
'darkMode' => true,
]);
php artisan vendor:publish --tag="filament-simple-theme-assets"
Then modify resources/css/filament-simple-theme.css.Integration with Filament Panels:
Filament::panel(
Panel::make('admin')
->id('admin')
->path('admin')
->middleware(['auth'])
->theme(fn () => FilamentSimpleTheme::enable())
);
Localization:
php artisan vendor:publish --tag="filament-simple-theme-lang"
resources/lang/{locale}/filament-simple-theme.php.Asset Compilation:
Ensure your vite.config.js or webpack.mix.js includes the theme’s assets. The package uses Tailwind CSS, so extend your tailwind.config.js:
module.exports = {
presets: [
require('filament/support/tailwind.config'),
],
// Add theme-specific classes if needed
theme: {
extend: {
colors: {
tomato: {
50: '#fef7f5',
100: '#fde8e3',
// ... custom colors
},
},
},
},
};
Custom CSS/JS:
Inject custom styles or scripts by hooking into Filament’s assets event:
Filament::registerViewModel(
\Tomato\FilamentSimpleTheme\FilamentSimpleTheme::class,
fn () => null
)->middleware(function ($view, $model, $operation) {
$view->with([
'filamentSimpleThemeScripts' => [
asset('custom-theme-scripts.js'),
],
]);
});
Testing: Test the theme in a staging environment first. Use Filament’s testing helpers to verify the sidebar and user menu render correctly:
use function Tomato\FilamentSimpleTheme\tests\assertThemeEnabled;
public function test_theme_is_enabled()
{
assertThemeEnabled();
}
Asset Conflicts:
npm run dev or npm run build after installing the package.php artisan cache:clear
npm run dev
Dark Mode Inconsistencies:
darkMode setting conflicts with the theme’s defaults. Explicitly set:
Filament::make('AdminPanel', [
'darkMode' => 'class', // or 'media'
]);
Sidebar Width:
/* resources/css/filament-simple-theme.css */
.filament-simple-theme-sidebar {
width: 280px; /* Adjust as needed */
}
User Menu Overrides:
x-filament::dropdown-list-item components for consistency. Avoid breaking Filament’s dropdown structure.Plugin Registration:
FilamentSimpleThemeServiceProvider) will result in the theme not loading. Verify the provider is in config/app.php.Theme Not Loading:
filament-simple-theme class on the <body> tag.enable() method is called.CSS/JS Not Compiled:
npm run dev and check the browser’s dev tools (Network tab) to ensure the theme’s CSS/JS files are loaded.Blade Views Not Found:
resources/views/vendor/filament-simple-theme/ and the namespace is correct.Dark Mode Not Working:
<html> tag for the dark class. If missing, ensure your Filament panel’s dark mode setting is correct and the theme’s dark mode toggle is functional.Extend the Theme:
cp -r vendor/tomatophp/filament-simple-theme/resources/views/vendor/filament-simple-theme resources/views/vendor/
cp -r vendor/tomatophp/filament-simple-theme/resources/css vendor/tomatophp/filament-simple-theme/resources/js resources/
Performance:
// resources/js/filament-simple-theme.js
document.addEventListener('DOMContentLoaded', () => {
const sidebar = document.querySelector('.filament-simple-theme-sidebar');
if (sidebar) {
// Lazy-load logic here
}
});
Accessibility:
<div class="sidebar" role="navigation" aria-label="Main navigation">
Version Compatibility:
Custom Icons:
<x-filament::dropdown-list-item
icon="<svg>...</svg>"
:label="__('Custom Action')"
/>
How can I help you explore Laravel packages today?