mirror of
https://github.com/filamentphp/plugin-skeleton.git
synced 2025-12-06 21:48:53 +08:00
wip 3.x updates
This commit is contained in:
@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Facade;
|
||||
*/
|
||||
class Skeleton extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return \VendorName\Skeleton\Skeleton::class;
|
||||
}
|
||||
|
||||
36
src/SkeletonPlugin.php
Normal file
36
src/SkeletonPlugin.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Panel;
|
||||
|
||||
class SkeletonPlugin implements Plugin
|
||||
{
|
||||
protected static string $name = 'skeleton-plugin';
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return static::$name;
|
||||
}
|
||||
|
||||
public function register(Panel $panel): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot(Panel $panel): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public static function make(): static
|
||||
{
|
||||
return app(static::class);
|
||||
}
|
||||
|
||||
public static function get(): static
|
||||
{
|
||||
return filament(app(static::class)->getId());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
|
||||
use Filament\Context;
|
||||
use Filament\Panel;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Support\Assets\AlpineComponent;
|
||||
use Filament\Support\Assets\Asset;
|
||||
@@ -58,52 +58,50 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
public function packageRegistered(): void
|
||||
public function register(): void
|
||||
{
|
||||
// Facade Registration
|
||||
$this->app->bind('skeleton', function (): Skeleton {
|
||||
parent::register();
|
||||
|
||||
// Facade Registration
|
||||
app()->bind('skeleton', function (): Skeleton {
|
||||
return new Skeleton();
|
||||
});
|
||||
|
||||
// Context Registration
|
||||
$this->app->resolving('skeleton', function () {
|
||||
foreach ($this->getContexts() as $context) {
|
||||
Filament::registerContext($context);
|
||||
}
|
||||
});
|
||||
|
||||
// Asset Registration
|
||||
$this->app->resolving(AssetManager::class, function () {
|
||||
FilamentAsset::register($this->getAssets(), $this->getAssetPackage());
|
||||
FilamentAsset::registerScriptData($this->getScriptData(), $this->getAssetPackage());
|
||||
});
|
||||
|
||||
// Icon Registration
|
||||
$this->app->resolving(IconManager::class, function () {
|
||||
FilamentIcon::register($this->getIcons());
|
||||
});
|
||||
}
|
||||
|
||||
public function packageBooted(): void
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerMacros();
|
||||
parent::boot();
|
||||
|
||||
// Handle Stubs
|
||||
if ($this->app->runningInConsole()) {
|
||||
// Asset Registration
|
||||
FilamentAsset::register(
|
||||
$this->getAssets(),
|
||||
$this->getAssetPackage()
|
||||
);
|
||||
|
||||
FilamentAsset::registerScriptData(
|
||||
$this->getScriptData(),
|
||||
$this->getAssetPackage()
|
||||
);
|
||||
|
||||
// Icon Registration
|
||||
FilamentIcon::register($this->getIcons());
|
||||
|
||||
// Handle Stubs
|
||||
if (app()->runningInConsole()) {
|
||||
foreach (app(Filesystem::class)->files(__DIR__.'/../stubs/') as $file) {
|
||||
$this->publishes([
|
||||
$file->getRealPath() => base_path("stubs/skeleton/{$file->getFilename()}"),
|
||||
], 'forms-stubs');
|
||||
], 'skeleton-stubs');
|
||||
}
|
||||
}
|
||||
|
||||
// Testing
|
||||
// Testing
|
||||
TestableLivewire::mixin(new TestsSkeleton());
|
||||
}
|
||||
|
||||
protected function getAssetPackage(): ?string
|
||||
{
|
||||
return static::$name ?? null;
|
||||
return ':vendor_slug/:package_slug';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +110,7 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
protected function getAssets(): array
|
||||
{
|
||||
return [
|
||||
// AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'),
|
||||
// AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'),
|
||||
Css::make('skeleton-styles', __DIR__.'/../resources/dist/skeleton.js'),
|
||||
Js::make('skeleton-scripts', __DIR__.'/../resources/dist/skeleton.js'),
|
||||
];
|
||||
@@ -128,14 +126,6 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Context>
|
||||
*/
|
||||
protected function getContexts(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Icon>
|
||||
*/
|
||||
@@ -169,8 +159,4 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
'create_skeleton_table',
|
||||
];
|
||||
}
|
||||
|
||||
protected function registerMacros(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace VendorName;
|
||||
|
||||
use Filament\Context;
|
||||
use Filament\Panel;
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Support\Assets\Theme;
|
||||
use Filament\Support\Color;
|
||||
@@ -15,26 +15,24 @@ class Skeleton implements Plugin
|
||||
return 'skeleton-theme';
|
||||
}
|
||||
|
||||
public function register(Context $context): void
|
||||
public function register(Panel $panel): void
|
||||
{
|
||||
FilamentAsset::register([
|
||||
Theme::make('skeleton', __DIR__.'/../resources/dist/skeleton.css'),
|
||||
]);
|
||||
|
||||
$context
|
||||
$panel
|
||||
->font('DM Sans')
|
||||
->primaryColor(Color::Amber)
|
||||
->secondaryColor(Color::Gray)
|
||||
->warningColor(Color::Amber)
|
||||
->dangerColor(Color::Rose)
|
||||
->successColor(Color::Green)
|
||||
->grayColor(Color::Slate)
|
||||
->sidebarWidth('20rem')
|
||||
->collapsedSidebarWidth('5.4rem')
|
||||
->grayColor(Color::Gray)
|
||||
->theme('skeleton');
|
||||
}
|
||||
|
||||
public function boot(Context $context): void
|
||||
public function boot(Panel $panel): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user