Skip to content

Commit 3dbc278

Browse files
initial commit
0 parents  commit 3dbc278

18 files changed

Lines changed: 1338 additions & 0 deletions

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Michael Dyrynda
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Tailwind CSS preset for the Laravel framework
2+
3+
### Installing
4+
```bash
5+
$ npm install
6+
```
7+
8+
### Setting up the new preset
9+
```bash
10+
$ php artisan preset tailwind
11+
```
12+
13+
### Auth scaffolding
14+
```bash
15+
$ php artisan preset tailwind-auth
16+
```
17+
18+
### Compiling assets
19+
```bash
20+
$ npm run dev
21+
```
22+
23+
Enjoy!

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "dyrynda/laravel-preset-tailwind",
3+
"description": "Laravel 5.5 frontend preset for Tailwind",
4+
"keywords": ["laravel", "preset", "tailwind"],
5+
"license": "MIT",
6+
"require": {
7+
"laravel/framework": "5.5.*"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Dyrynda\\LaravelPresets\\Tailwind\\": "src/"
12+
}
13+
},
14+
"extra": {
15+
"laravel": {
16+
"providers": [
17+
"Dyrynda\\LaravelPresets\\Tailwind\\TailwindPresetServiceProvider"
18+
]
19+
}
20+
}
21+
}

src/TailwindPreset.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Dyrynda\LaravelPresets\Tailwind;
4+
5+
use Illuminate\Support\Arr;
6+
use Illuminate\Container\Container;
7+
use Illuminate\Filesystem\Filesystem;
8+
use Illuminate\Foundation\Console\Presets\Preset;
9+
10+
class TailwindPreset extends Preset
11+
{
12+
public static function install()
13+
{
14+
static::updatePackages();
15+
static::updateStyles();
16+
static::updateBootstrapping();
17+
static::updateWelcomePage();
18+
static::removeNodeModules();
19+
}
20+
21+
protected static function updatePackageArray(array $packages)
22+
{
23+
return [
24+
'tailwindcss' => '^0.1.0',
25+
] + Arr::except($packages, ['bootstrap-sass', 'jquery']);
26+
}
27+
28+
protected static function updateStyles()
29+
{
30+
(new Filesystem)->deleteDirectory(resource_path('assets/sass'));
31+
32+
copy(__DIR__.'/tailwind-stubs/main.css', resource_path('assets/css/app.css'));
33+
}
34+
35+
protected static function updateBootstrapping()
36+
{
37+
copy(__DIR__.'/tailwind-stubs/tailwind.js', base_path('tailwind.js'));
38+
copy(__DIR__.'/tailwind-stubs/bootstrap.js', resource_path('assets/js/bootstrap.js'));
39+
}
40+
41+
protected static function updateWelcomePage()
42+
{
43+
(new Filesystem)->delete(resource_path('views/welcome.blade.php'));
44+
45+
copy(__DIR__.'/tailwind-stubs/views/welcome.blade.php', resource_path('views/welcome.blade.php'));
46+
}
47+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Dyrynda\LaravelPresets\Tailwind;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Illuminate\Foundation\Console\PresetCommand;
7+
8+
class TailwindPresetServiceProvider extends ServiceProvider
9+
{
10+
public function boot()
11+
{
12+
PresetCommand::macro('tailwind', function ($command) {
13+
TailwindPreset::install();
14+
15+
$command->info('Tailwind scaffolding installed successfully.');
16+
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
17+
});
18+
19+
PresetCommand::macro('tailwind-auth', function ($command) {
20+
TailwindPreset::installAuth();
21+
22+
$command->info('Tailwind scaffolding with auth views installed successfully.');
23+
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
24+
});
25+
}
26+
}

src/tailwind-stubs/app.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
// Tachyons
3+
@import "node_modules/tachyons-sass/tachyons";

src/tailwind-stubs/bootstrap.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
window._ = require('lodash');
3+
4+
/**
5+
* We'll load the axios HTTP library which allows us to easily issue requests
6+
* to our Laravel back-end. This library automatically handles sending the
7+
* CSRF token as a header based on the value of the "XSRF" token cookie.
8+
*/
9+
10+
window.axios = require('axios');
11+
12+
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
13+
14+
/**
15+
* Next we will register the CSRF Token as a common header with Axios so that
16+
* all outgoing HTTP requests automatically have it attached. This is just
17+
* a simple convenience so we don't have to attach every token manually.
18+
*/
19+
20+
let token = document.head.querySelector('meta[name="csrf-token"]');
21+
22+
if (token) {
23+
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
24+
} else {
25+
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
26+
}
27+
28+
/**
29+
* Echo exposes an expressive API for subscribing to channels and listening
30+
* for events that are broadcast by Laravel. Echo and event broadcasting
31+
* allows your team to easily build robust real-time web applications.
32+
*/
33+
34+
// import Echo from 'laravel-echo'
35+
36+
// window.Pusher = require('pusher-js');
37+
38+
// window.Echo = new Echo({
39+
// broadcaster: 'pusher',
40+
// key: 'your-pusher-key'
41+
// });
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace {{namespace}}Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class HomeController extends Controller
8+
{
9+
/**
10+
* Create a new controller instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct()
15+
{
16+
$this->middleware('auth');
17+
}
18+
19+
/**
20+
* Show the application dashboard.
21+
*
22+
* @return \Illuminate\Http\Response
23+
*/
24+
public function index()
25+
{
26+
return view('home');
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This injects Tailwind's base styles, which is a combination of
3+
* Normalize.css and some additional base styles.
4+
*
5+
* You can see the styles here:
6+
* https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css
7+
*/
8+
@tailwind preflight;
9+
10+
/**
11+
* Here you would import any custom component classes; stuff that you'd
12+
* want loaded *before* the utilities so that the utilities can still
13+
* override them.
14+
*/
15+
// @import "my-components/foo";
16+
// @import "my-components/bar";
17+
18+
/**
19+
* This injects all of Tailwind's utility classes, generated based on your
20+
* config file.
21+
*/
22+
@tailwind utilities;
23+
24+
/**
25+
* Here you would add any custom utilities you need that don't come out of the box with Tailwind.
26+
*/
27+
// .bg-hero-image {
28+
// background-image: url('/some/image/file.png');
29+
// }

0 commit comments

Comments
 (0)