From 671405dd7409ae07495a5e4e40e78b6738a187ea Mon Sep 17 00:00:00 2001 From: yaelahan Date: Wed, 4 Mar 2020 20:16:00 +0700 Subject: [PATCH 1/4] support for laravel 7 --- README.md | 14 +++++--------- composer.json | 3 ++- src/TailwindCssPreset.php | 24 ++++++++++++++++++------ src/TailwindCssPresetServiceProvider.php | 15 +++++---------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d2c3a7af..2ccfaee2 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,21 @@ -# Laravel 6.0+ Frontend preset for Tailwind CSS +# Laravel 7.0+ Frontend preset for Tailwind CSS A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.com) - a Utility-First CSS Framework for Rapid UI Development. -## 1. Basic usage +## Usage -1. Run `npx use-tailwind-preset` - -## 2. Advanced Usage - -1. Fresh install Laravel >= 6.0 and `cd` to your app. +1. Fresh install Laravel >= 7.0 and `cd` to your app. 2. Install this preset via `composer require laravel-frontend-presets/tailwindcss --dev`. Laravel will automatically discover this package. No need to register the service provider. ### a. For Presets without Authentication -1. Use `php artisan preset tailwindcss` for the basic Tailwind CSS preset +1. Use `php artisan ui tailwindcss` for the basic Tailwind CSS preset 2. `npm install && npm run dev` 3. `php artisan serve` (or equivalent) to run server and test preset. ### b. For Presets with Authentication -1. Use `php artisan preset tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) +1. Use `php artisan ui tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) 4. `npm install && npm run dev` 5. Configure your favorite database (mysql, sqlite etc.) 6. `php artisan migrate` to create basic user tables. diff --git a/composer.json b/composer.json index e368ac6d..7cf25a74 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "keywords": ["laravel", "preset", "tailwindcss"], "license": "MIT", "require": { - "laravel/framework": "^5.5 || ^6.0" + "laravel/framework": "^7.0", + "laravel/ui": "^2.0" }, "autoload": { "psr-4": { diff --git a/src/TailwindCssPreset.php b/src/TailwindCssPreset.php index 4f2a22bf..38fdf923 100644 --- a/src/TailwindCssPreset.php +++ b/src/TailwindCssPreset.php @@ -3,9 +3,11 @@ namespace LaravelFrontendPresets\TailwindCssPreset; use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; -use Illuminate\Foundation\Console\Presets\Preset; +use Laravel\Ui\Presets\Preset; +use Symfony\Component\Finder\SplFileInfo; class TailwindCssPreset extends Preset { @@ -15,13 +17,13 @@ public static function install() static::updateStyles(); static::updateBootstrapping(); static::updateWelcomePage(); - static::updatePagination(); static::removeNodeModules(); } public static function installAuth() { static::install(); + static::scaffoldController(); static::scaffoldAuth(); } @@ -73,11 +75,21 @@ protected static function updateWelcomePage() copy(__DIR__.'/tailwindcss-stubs/resources/views/welcome.blade.php', resource_path('views/welcome.blade.php')); } - protected static function updatePagination() + protected static function scaffoldController() { - (new Filesystem)->delete(resource_path('views/vendor/paginate')); - - (new Filesystem)->copyDirectory(__DIR__.'/tailwindcss-stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination')); + if (! is_dir($directory = app_path('Http/Controllers/Auth'))) { + mkdir($directory, 0755, true); + } + + $filesystem = new Filesystem; + + collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth'))) + ->each(function (SplFileInfo $file) use ($filesystem) { + $filesystem->copy( + $file->getPathname(), + app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename())) + ); + }); } protected static function scaffoldAuth() diff --git a/src/TailwindCssPresetServiceProvider.php b/src/TailwindCssPresetServiceProvider.php index 470690eb..7b3ff1c8 100644 --- a/src/TailwindCssPresetServiceProvider.php +++ b/src/TailwindCssPresetServiceProvider.php @@ -2,30 +2,25 @@ namespace LaravelFrontendPresets\TailwindCssPreset; -use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; -use Illuminate\Foundation\Console\PresetCommand; +use Laravel\Ui\UiCommand; class TailwindCssPresetServiceProvider extends ServiceProvider { public function boot() { - PresetCommand::macro('tailwindcss', function ($command) { + UiCommand::macro('tailwindcss', function ($command) { TailwindCssPreset::install(); $command->info('Tailwind CSS scaffolding installed successfully.'); - $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); + $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }); - PresetCommand::macro('tailwindcss-auth', function ($command) { + UiCommand::macro('tailwindcss-auth', function ($command) { TailwindCssPreset::installAuth(); $command->info('Tailwind CSS scaffolding with auth views installed successfully.'); - $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); + $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }); - - Paginator::defaultView('pagination::default'); - - Paginator::defaultSimpleView('pagination::simple-default'); } } From bcd4b39735ee78d9914d55bb3c21d0fba9bf7c46 Mon Sep 17 00:00:00 2001 From: yaelahan <35204891+yaelahan@users.noreply.github.com> Date: Thu, 5 Mar 2020 07:56:57 +0700 Subject: [PATCH 2/4] Update TailwindCssPresetServiceProvider.php --- src/TailwindCssPresetServiceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TailwindCssPresetServiceProvider.php b/src/TailwindCssPresetServiceProvider.php index 7b3ff1c8..ad6fee64 100644 --- a/src/TailwindCssPresetServiceProvider.php +++ b/src/TailwindCssPresetServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Support\ServiceProvider; use Laravel\Ui\UiCommand; +use Laravel\Ui\AuthCommand; class TailwindCssPresetServiceProvider extends ServiceProvider { @@ -16,7 +17,7 @@ public function boot() $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }); - UiCommand::macro('tailwindcss-auth', function ($command) { + AuthCommand::macro('tailwindcss', function ($command) { TailwindCssPreset::installAuth(); $command->info('Tailwind CSS scaffolding with auth views installed successfully.'); From 61c253aea783cd10287c972f0451759723011615 Mon Sep 17 00:00:00 2001 From: yaelahan <35204891+yaelahan@users.noreply.github.com> Date: Thu, 5 Mar 2020 07:57:31 +0700 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ccfaee2..c17030b9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.co ### b. For Presets with Authentication -1. Use `php artisan ui tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) +1. Use `php artisan ui tailwindcss --auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) 4. `npm install && npm run dev` 5. Configure your favorite database (mysql, sqlite etc.) 6. `php artisan migrate` to create basic user tables. From af3867ac98901d735fd47f94b86fa05fe73aa6e5 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Fri, 6 Mar 2020 06:28:51 +1030 Subject: [PATCH 4/4] restore pagination functionality Closes #87 --- src/TailwindCssPreset.php | 8 ++++++++ src/TailwindCssPresetServiceProvider.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/TailwindCssPreset.php b/src/TailwindCssPreset.php index 38fdf923..b169316d 100644 --- a/src/TailwindCssPreset.php +++ b/src/TailwindCssPreset.php @@ -17,6 +17,7 @@ public static function install() static::updateStyles(); static::updateBootstrapping(); static::updateWelcomePage(); + static::updatePagination(); static::removeNodeModules(); } @@ -68,6 +69,13 @@ protected static function updateBootstrapping() copy(__DIR__.'/tailwindcss-stubs/resources/js/bootstrap.js', resource_path('js/bootstrap.js')); } + protected static function updatePagination() + { + (new Filesystem)->delete(resource_path('views/vendor/paginate')); + + (new Filesystem)->copyDirectory(__DIR__.'/tailwindcss-stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination')); + } + protected static function updateWelcomePage() { (new Filesystem)->delete(resource_path('views/welcome.blade.php')); diff --git a/src/TailwindCssPresetServiceProvider.php b/src/TailwindCssPresetServiceProvider.php index ad6fee64..d6cf6f72 100644 --- a/src/TailwindCssPresetServiceProvider.php +++ b/src/TailwindCssPresetServiceProvider.php @@ -2,6 +2,7 @@ namespace LaravelFrontendPresets\TailwindCssPreset; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; use Laravel\Ui\UiCommand; use Laravel\Ui\AuthCommand; @@ -23,5 +24,9 @@ public function boot() $command->info('Tailwind CSS scaffolding with auth views installed successfully.'); $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }); + + Paginator::defaultView('pagination::default'); + + Paginator::defaultSimpleView('pagination::simple-default'); } }