Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsam726 authored and github-actions[bot] committed Apr 19, 2024
1 parent 5ddb4fd commit 35bdd93
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/Commands/ModuleMakeFilamentThemeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function handle(): int
'yarn' => 'yarn add',
default => "{$pm} install",
};
$cdCommand = 'cd '.$module->getPath();
$cdCommand = 'cd ' . $module->getPath();

exec("$cdCommand && {$installCommand} tailwindcss @tailwindcss/forms @tailwindcss/typography postcss postcss-nesting autoprefixer --save-dev");

Expand All @@ -66,17 +66,17 @@ public function handle(): int
'viewPathPrefix' => $viewPathPrefix,
]);

$this->components->info('Filament theme [resources/css/filament/theme.css] and [resources/css/filament/tailwind.config.js] created successfully in '.$module->getStudlyName().' module.');
$this->components->info('Filament theme [resources/css/filament/theme.css] and [resources/css/filament/tailwind.config.js] created successfully in ' . $module->getStudlyName() . ' module.');

$buildDirectory = 'build-'.$module->getLowerName();
$buildDirectory = 'build-' . $module->getLowerName();
$moduleStudlyName = $module->getStudlyName();

if (empty(glob($module->getExtraPath('vite.config.*s')))) {
$this->components->warn('Action is required to complete the theme setup:');
$this->components->bulletList([
"It looks like you don't have Vite installed in your module. Please use your asset bundling system of choice to compile `resources/css/filament/theme.css` into `public/$buildDirectory/css/filament/theme.css`.",
"If you're not currently using a bundler, we recommend using Vite. Alternatively, you can use the Tailwind CLI with the following command inside the $moduleStudlyName module:",
'npx tailwindcss --input ./resources/css/filament/theme.css --output ./public/'.$buildDirectory.'/css/filament/theme.css --config ./resources/css/filament/tailwind.config.js --minify',
'npx tailwindcss --input ./resources/css/filament/theme.css --output ./public/' . $buildDirectory . '/css/filament/theme.css --config ./resources/css/filament/tailwind.config.js --minify',
"Make sure to register the theme in the {$moduleStudlyName} module plugin under the afterRegister() function using `->theme(asset('css/filament/theme.css'))`",
]);

Expand All @@ -103,7 +103,7 @@ public function handle(): int

protected function getDefaultStubPath(): string
{
return __DIR__.'/stubs';
return __DIR__ . '/stubs';
}

private function getModule(): Module
Expand Down
8 changes: 4 additions & 4 deletions src/Concerns/ModuleFilamentPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public function register(Panel $panel): void
$module = $this->getModule();
$useClusters = config('filament-modules.clusters.enabled', false);
$panel->discoverPages(
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Pages'),
in: $module->appPath('Filament' . DIRECTORY_SEPARATOR . 'Pages'),
for: $module->appNamespace('\\Filament\\Pages')
);
$panel->discoverResources(
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Resources'),
in: $module->appPath('Filament' . DIRECTORY_SEPARATOR . 'Resources'),
for: $module->appNamespace('\\Filament\\Resources')
);
$panel->discoverWidgets(
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Widgets'),
in: $module->appPath('Filament' . DIRECTORY_SEPARATOR . 'Widgets'),
for: $module->appNamespace('\\Filament\\Widgets')
);

Expand All @@ -37,7 +37,7 @@ public function register(Panel $panel): void
);

if ($useClusters) {
$path = $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Clusters');
$path = $module->appPath('Filament' . DIRECTORY_SEPARATOR . 'Clusters');
$namespace = $module->appNamespace('\\Filament\\Clusters');
$panel->discoverClusters(
in: $path,
Expand Down
21 changes: 11 additions & 10 deletions src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ public function packageRegistered(): void
public function attemptToRegisterModuleProviders(): void
{
// It is necessary to register them here to avoid late registration (after Panels have already been booted)
$providers = glob(config('modules.paths.modules').'/*/*/Providers/*ServiceProvider.php');
$providers = glob(config('modules.paths.modules') . '/*/*/Providers/*ServiceProvider.php');
foreach ($providers as $provider) {
$namespace = FilamentModules::convertPathToNamespace($provider);
$module = str($namespace)->before('\Providers\\')->afterLast('\\')->toString();
$className = str($namespace)->afterLast('\\')->toString();
if (str($className)->startsWith($module)){
if (str($className)->startsWith($module)) {
// register the module service provider
$this->app->register($namespace);
}
}
}

public function packageBooted(): void
{
$this->attemptToRegisterModuleProviders();
Expand All @@ -94,7 +95,7 @@ public function packageBooted(): void

// Handle Stubs
if (app()->runningInConsole()) {
foreach (app(Filesystem::class)->files(__DIR__.'/../stubs/') as $file) {
foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) {
$this->publishes([
$file->getRealPath() => base_path("stubs/modules/{$file->getFilename()}"),
], 'modules-stubs');
Expand Down Expand Up @@ -187,44 +188,44 @@ protected function registerModuleMacros(): void
$relativeNamespace = str_replace('App\\', '', $relativeNamespace);
$relativeNamespace = str_replace('App', '', $relativeNamespace);
$relativeNamespace = trim($relativeNamespace, '\\');
$relativeNamespace = '\\'.$relativeNamespace;
$relativeNamespace = '\\' . $relativeNamespace;

return $this->namespace($relativeNamespace);
});
Module::macro('appPath', function (string $relativePath = '') {
$appPath = $this->getExtraPath('app');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});

Module::macro('databasePath', function (string $relativePath = '') {
$appPath = $this->getExtraPath('database');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});

Module::macro('resourcesPath', function (string $relativePath = '') {
$appPath = $this->getExtraPath('resources');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});

Module::macro('migrationsPath', function (string $relativePath = '') {
$appPath = $this->databasePath('migrations');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});

Module::macro('seedersPath', function (string $relativePath = '') {
$appPath = $this->databasePath('seeders');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});

Module::macro('factoriesPath', function (string $relativePath = '') {
$appPath = $this->databasePath('factories');

return $appPath.($relativePath ? DIRECTORY_SEPARATOR.$relativePath : '');
return $appPath . ($relativePath ? DIRECTORY_SEPARATOR . $relativePath : '');
});
}
}

0 comments on commit 35bdd93

Please sign in to comment.