Skip to content

Commit 64e82b0

Browse files
Merge branch 'yaelahan/master'
2 parents ea82c54 + af3867a commit 64e82b0

File tree

4 files changed

+38
-20
lines changed

4 files changed

+38
-20
lines changed

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
# Laravel 6.0+ Frontend preset for Tailwind CSS
1+
# Laravel 7.0+ Frontend preset for Tailwind CSS
22

33
A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.com) - a Utility-First CSS Framework for Rapid UI Development.
44

5-
## 1. Basic usage
5+
## Usage
66

7-
1. Run `npx use-tailwind-preset`
8-
9-
## 2. Advanced Usage
10-
11-
1. Fresh install Laravel >= 6.0 and `cd` to your app.
7+
1. Fresh install Laravel >= 7.0 and `cd` to your app.
128
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.
139

1410
### a. For Presets without Authentication
1511

16-
1. Use `php artisan preset tailwindcss` for the basic Tailwind CSS preset
12+
1. Use `php artisan ui tailwindcss` for the basic Tailwind CSS preset
1713
2. `npm install && npm run dev`
1814
3. `php artisan serve` (or equivalent) to run server and test preset.
1915

2016
### b. For Presets with Authentication
2117

22-
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`)
18+
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`)
2319
4. `npm install && npm run dev`
2420
5. Configure your favorite database (mysql, sqlite etc.)
2521
6. `php artisan migrate` to create basic user tables.

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"keywords": ["laravel", "preset", "tailwindcss"],
55
"license": "MIT",
66
"require": {
7-
"laravel/framework": "^5.5 || ^6.0"
7+
"laravel/framework": "^7.0",
8+
"laravel/ui": "^2.0"
89
},
910
"autoload": {
1011
"psr-4": {

src/TailwindCssPreset.php

+25-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace LaravelFrontendPresets\TailwindCssPreset;
44

55
use Illuminate\Support\Arr;
6+
use Illuminate\Support\Str;
67
use Illuminate\Container\Container;
78
use Illuminate\Filesystem\Filesystem;
8-
use Illuminate\Foundation\Console\Presets\Preset;
9+
use Laravel\Ui\Presets\Preset;
10+
use Symfony\Component\Finder\SplFileInfo;
911

1012
class TailwindCssPreset extends Preset
1113
{
@@ -22,6 +24,7 @@ public static function install()
2224
public static function installAuth()
2325
{
2426
static::install();
27+
static::scaffoldController();
2528
static::scaffoldAuth();
2629
}
2730

@@ -66,18 +69,35 @@ protected static function updateBootstrapping()
6669
copy(__DIR__.'/tailwindcss-stubs/resources/js/bootstrap.js', resource_path('js/bootstrap.js'));
6770
}
6871

72+
protected static function updatePagination()
73+
{
74+
(new Filesystem)->delete(resource_path('views/vendor/paginate'));
75+
76+
(new Filesystem)->copyDirectory(__DIR__.'/tailwindcss-stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination'));
77+
}
78+
6979
protected static function updateWelcomePage()
7080
{
7181
(new Filesystem)->delete(resource_path('views/welcome.blade.php'));
7282

7383
copy(__DIR__.'/tailwindcss-stubs/resources/views/welcome.blade.php', resource_path('views/welcome.blade.php'));
7484
}
7585

76-
protected static function updatePagination()
86+
protected static function scaffoldController()
7787
{
78-
(new Filesystem)->delete(resource_path('views/vendor/paginate'));
79-
80-
(new Filesystem)->copyDirectory(__DIR__.'/tailwindcss-stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination'));
88+
if (! is_dir($directory = app_path('Http/Controllers/Auth'))) {
89+
mkdir($directory, 0755, true);
90+
}
91+
92+
$filesystem = new Filesystem;
93+
94+
collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth')))
95+
->each(function (SplFileInfo $file) use ($filesystem) {
96+
$filesystem->copy(
97+
$file->getPathname(),
98+
app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename()))
99+
);
100+
});
81101
}
82102

83103
protected static function scaffoldAuth()

src/TailwindCssPresetServiceProvider.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@
44

55
use Illuminate\Pagination\Paginator;
66
use Illuminate\Support\ServiceProvider;
7-
use Illuminate\Foundation\Console\PresetCommand;
7+
use Laravel\Ui\UiCommand;
8+
use Laravel\Ui\AuthCommand;
89

910
class TailwindCssPresetServiceProvider extends ServiceProvider
1011
{
1112
public function boot()
1213
{
13-
PresetCommand::macro('tailwindcss', function ($command) {
14+
UiCommand::macro('tailwindcss', function ($command) {
1415
TailwindCssPreset::install();
1516

1617
$command->info('Tailwind CSS scaffolding installed successfully.');
17-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
18+
$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
1819
});
1920

20-
PresetCommand::macro('tailwindcss-auth', function ($command) {
21+
AuthCommand::macro('tailwindcss', function ($command) {
2122
TailwindCssPreset::installAuth();
2223

2324
$command->info('Tailwind CSS scaffolding with auth views installed successfully.');
24-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
25+
$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
2526
});
2627

2728
Paginator::defaultView('pagination::default');

0 commit comments

Comments
 (0)