diff --git a/starrynight/config/starrynight.php b/starrynight/config/starrynight.php new file mode 100644 index 0000000..b625128 --- /dev/null +++ b/starrynight/config/starrynight.php @@ -0,0 +1,4 @@ +ensureCssPublished(); + } + + public function boot(): void + { + $sourceDark = __DIR__.'/../../css/starry-night.css'; + $destDark = public_path('plugins/starrynight/css/starry-night.css'); + + $sourceLight = __DIR__.'/../../css/starry-night-light.css'; + $destLight = public_path('plugins/starrynight/css/starry-night-light.css'); + + $this->publishes([ + $sourceDark => $destDark, + $sourceLight => $destLight, + ], 'starrynight-assets'); + } + + private function ensureCssPublished(): void + { + $pairs = [ + [__DIR__.'/../../css/starry-night.css', public_path('plugins/starrynight/css/starry-night.css')], + [__DIR__.'/../../css/starry-night-light.css', public_path('plugins/starrynight/css/starry-night-light.css')], + ]; + + foreach ($pairs as [$source, $destination]) { + if (! File::exists($destination) && File::exists($source)) { + $dir = dirname($destination); + if (! File::isDirectory($dir)) { + File::makeDirectory($dir, 0755, true); + } + File::copy($source, $destination); + } + } + } +} diff --git a/starrynight/src/StarryNightPlugin.php b/starrynight/src/StarryNightPlugin.php new file mode 100644 index 0000000..7279ae5 --- /dev/null +++ b/starrynight/src/StarryNightPlugin.php @@ -0,0 +1,318 @@ +colors([ + 'danger' => Color::Rose, + 'gray' => Color::Slate, + 'info' => Color::Pink, + 'primary' => Color::Purple, + 'success' => Color::Emerald, + 'warning' => Color::Amber, + ]); + + $panel->renderHook('panels::head.end', function () { + $dark = asset('plugins/starrynight/css/starry-night.css'); + $light = asset('plugins/starrynight/css/starry-night-light.css'); + + return << + +HTML; + }); + + $panel->renderHook('panels::body.start', function () { + $meteorHtml = '
+ + + + + + + + + + +
'; + $meteorCss = <<<'CSS' + + CSS; + $starDiv = '
'; + $starStyle = <<<'CSS' + +CSS; + $starJs = <<<'JS' + +JS; + + return $meteorCss.$meteorHtml.$starDiv.$starStyle.$starJs; + }); + } + + public function boot(Panel $panel): void {} +}