argument('key'); $parent = (string) ($this->option('parent') ?: config('themes.base')); $themesPath = rtrim((string) (config('themes.paths')[0] ?? resource_path('themes')), '/\\'); $path = "{$themesPath}/{$key}"; $folder = str_replace('\\', '/', ltrim(substr($path, strlen(base_path())), '/\\')); if (! preg_match('/^[a-z0-9]+(-[a-z0-9]+)*$/', $key)) { $this->error('Key: nur Kleinbuchstaben, Ziffern und Bindestriche, z. B. ostsee-nacht.'); return self::FAILURE; } if (File::exists($path) || isset($registry->all()[$key])) { $this->error("Theme „{$key}“ gibt es schon – es wird nichts überschrieben."); return self::FAILURE; } if (! isset($registry->all()[$parent])) { $this->error("Eltern-Theme „{$parent}“ ist nicht installiert."); return self::FAILURE; } $name = (string) ($this->option('name') ?: str($key)->replace('-', ' ')->title()); $manifest = [ 'key' => $key, 'name' => $name, 'version' => '0.1.0', 'parent' => $parent, 'description' => (string) ($this->option('description') ?: "Neues Theme auf Basis von „{$registry->get($parent)->name}“."), 'assets' => ['css' => "{$folder}/theme.css", 'js' => "{$folder}/theme.js"], 'tokens' => $registry->tokens($parent), ]; File::ensureDirectoryExists("{$path}/views/sections"); File::ensureDirectoryExists("{$path}/views/partials"); File::put("{$path}/views/sections/.gitkeep", ''); File::put("{$path}/views/partials/.gitkeep", ''); File::put("{$path}/theme.json", json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n"); File::put("{$path}/theme.css", $this->css($name, $parent, $path, $registry)); File::put("{$path}/theme.js", $this->js($name, ThemeManifest::relativePath($path, $registry->get($parent)->path).'/theme.js')); File::put("{$path}/README.md", $this->readme($name, $key, $parent)); $this->info("Theme „{$name}“ angelegt: {$folder}"); $this->line('Es erbt zunächst alles von „'.$parent.'“. Vorlagen nach views/ kopieren und umgestalten – Anleitung: docs/THEME-ERSTELLUNG.md'); $this->line("Prüfen: php artisan themes:check {$key} · Bauen: npm run build · Auswählen: Admin › System › Websites › Theme (dort „Vorschau“)."); return self::SUCCESS; } /** * Child theme CSS: Tailwind, the reusable styles of the nearest ancestor that has a theme-base.css, * and the template sources of all ancestors, the booking forms and the theme itself. */ private function css(string $name, string $parent, string $path, ThemeRegistry $registry): string { $ancestors = $registry->chain($parent); $base = collect($ancestors)->first(fn (ThemeManifest $theme): bool => is_file($theme->path.'/theme-base.css')) ?? $ancestors[0]; $import = ThemeManifest::relativePath($path, $base->path).'/theme-base.css'; $sources = collect($ancestors) ->map(fn (ThemeManifest $theme): string => "@source '".ThemeManifest::relativePath($path, $theme->viewsPath())."';") ->push("@source '".ThemeManifest::relativePath($path, resource_path('views/livewire'))."';") ->push("@source './views';") ->implode("\n"); return << und hier importieren, z. B. @import '@fontsource/fraunces/400.css'; */ /* Vorlagen, deren Klassen gebaut werden: geerbte, Buchungsformulare, eigene. */ {$sources} @theme inline { /* --font-display: 'Fraunces', Georgia, serif; */ /* --font-sans: 'Inter', ui-sans-serif, system-ui, sans-serif; */ } @layer components { } CSS; } private function js(string $name, string $import): string { return <<