Skip to content

Commit fe87597

Browse files
authored
Merge pull request #64 from Gustavinho/release/2.1.0
Release/2.1.0
2 parents 3b93521 + 1bcff81 commit fe87597

33 files changed

+2878
-11401
lines changed

.travis.yml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
1-
anguage: php
1+
language: php
2+
3+
php:
4+
- 7.2
5+
- 7.3
6+
- 7.4
27

38
env:
9+
jobs:
10+
- LARAVEL=7.0.* TESTBENCH=5.*
11+
- LARAVEL=8.0.* TESTBENCH=6.*
412
global:
513
- DB_CONNECTION=sqlite
614
- DB_DATABASE=":memory:"
715
- APP_ENV=testing
8-
matrix:
9-
- LARAVEL='5.5.*' TESTBENCH='3.5.*'
10-
- LARAVEL='5.6.*' TESTBENCH='3.6.*'
11-
- LARAVEL='5.7.*' TESTBENCH='3.7.*'
12-
- LARAVEL='5.8.*' TESTBENCH='3.8.*'
13-
- LARAVEL='6.*' TESTBENCH='4.*'
14-
- LARAVEL='7.*' TESTBENCH='5.*'
15-
- LARAVEL='8.*' TESTBENCH='6.*'
16-
17-
php:
18-
- 7.2
19-
- 7.3
2016

2117
matrix:
2218
fast_finish: true
19+
exclude:
20+
- php: 7.2
21+
env: LARAVEL=8.0.* TESTBENCH=6.*
2322

2423
branches:
2524
only:
2625
- master
2726
- dev
2827
- /^release-.*$/
28+
- /^release/.*$/
2929

3030
before_script:
3131
- composer config discard-changes true
32-
- mkdir vendor/orchestra/testbench-core/laravel/app/Http
3332
- mkdir vendor/orchestra/testbench-core/laravel/app/Http/Livewire
33+
3434
before_install:
3535
- travis_retry composer self-update
36-
- travis_retry composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update --dev
36+
- rm -rf composer.lock
37+
- travis_retry composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-update
38+
- if [ "$LARAVEL" = "8.0.*" ]; then composer require "laravel/legacy-factories" --no-update; fi;
3739
- cat composer.json
40+
3841
install:
39-
- travis_retry composer install --prefer-dist --no-interaction --no-suggest
42+
- travis_retry composer install --prefer-dist --no-interaction --no-dev --ignore-platform-reqs
43+
4044
script:
4145
- phpunit --testdox
4246

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [2.1] - 2021-01-10
4+
### Added
5+
- Option to customize which assets will be imported
6+
- The current view instance is passed as a param to the action to be executed
7+
8+
### Changed
9+
- The filter button was changed by an icon button
10+
- Updated documentation
11+
- Added how to purge `laravel-views` styles
12+
- Added how to render components using `Livewire`
13+
14+
315
## [2.0] - 2020-09-13
416
### Added
517
- Added compatibility for Laravel Livewire 2.x

README.md

Lines changed: 46 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Laravel views
22

3+
[See live example](http://laravel-views.herokuapp.com)
4+
35
Laravel package to create beautiful common views like tables using only PHP code, inspired by [Laravel Nova](https://nova.laravel.com/), these views are built with [Laravel Livewire](https://laravel-livewire.com/) and styled using [Tailwind CSS](https://tailwindcss.com/)
46

57
## Table View example
@@ -8,20 +10,16 @@ Laravel package to create beautiful common views like tables using only PHP code
810

911
- [Version compatibility](#version-compatibility)
1012
- [Installation and basic usage](#installation-and-basic-usage)
11-
- [Installing laravel views](#installing-laravel-views)
12-
- [Publishing assets](#publishing-assets)
13-
- [Including assets](#including-assets)
13+
- [Installing laravel views](#installing-laravel-views)
14+
- [Publishing assets](#publishing-assets)
15+
- [Including assets](#including-assets)
1416
- [First table view](#first-table-view)
15-
- [Rendering the table view](#rendering-the-table-view)
17+
- [Rendering the table view](#rendering-the-table-view)
1618
- [Rendering a view](#rendering-a-view)
17-
- [From a controller](#from-a-controller)
18-
- [Specifying a layout and section](#specifying-a-layout-and-section)
19-
- [Send extra data](send-extra-data)
20-
- [Components customization](#components-customization)
21-
- [Component variants using tailwindcss](#component-variants-using-tailwindcss)
22-
- [Components full customization](#components-full-customization)
23-
- [Table view](doc/table-view.md)
24-
- [Grid view](doc/grid-view.md)
19+
- [Advanced usage](doc/laravel-views.md)
20+
- [Views available](#views-available)
21+
- [Table view](#table-view)
22+
- [Grid view](#grid-view)
2523
- [Contributing](#contributing)
2624
- [Roadmap](#roadmap)
2725

@@ -40,15 +38,9 @@ composer require laravel-views/laravel-views
4038

4139
## Publishing assets
4240
```bash
43-
php artisan vendor:publish --tag=public --force
44-
```
45-
or you can specify the provider
46-
```bash
4741
php artisan vendor:publish --tag=public --provider='LaravelViews\LaravelViewsServiceProvider' --force
4842
```
4943

50-
If you are updating this package you might need to republish these assets.
51-
5244
## Including assets
5345
Add the following Blade directives in the *head* tag, and before the end *body* tag in your template
5446

@@ -65,10 +57,11 @@ Add the following Blade directives in the *head* tag, and before the end *body*
6557
</html>
6658
```
6759

68-
These blade directives are also including [Laravel livewire](https://laravel-livewire.com/) styles and scripts, after that you may need to clear the view cache
60+
These blade directives are also including [Laravel livewire](https://laravel-livewire.com/) and [Tailwindcss](https://tailwindcss.com/) styles and scripts, after that you may need to clear the view cache
6961
```bash
7062
php artisan view:clear
7163
```
64+
If you are already using your own Tailwindcss setup you can set `laravel-views` to not importing Tailwindcss by default. ([Importing assets](./doc/laravel-views#including-assets))
7265

7366
# First table view
7467
This is a basic usage of a table view, you can [read the full table view documentation ](doc/table-view.md)
@@ -78,7 +71,7 @@ Once you have installed the package and included the assets you can start to cre
7871
```bash
7972
php artisan make:table-view UsersTableView
8073
```
81-
With this artisan command a UsersTableView.php file will be created inside `app/Http/Livewire` directory.
74+
With this artisan command a UsersTableView.php file will be created inside the `app/Http/Livewire` directory.
8275

8376
The basic usage needs a data repository (Eloquent query), headers and rows, you can customize the items to be shown, and the headers and data for each row like this example
8477
```php
@@ -99,20 +92,36 @@ class UsersTableView extends TableView
9992

10093
public function headers(): array
10194
{
102-
return ['Name', 'Email', 'Created', 'Updated'];
95+
return [
96+
'Name',
97+
'Email',
98+
'Created',
99+
'Updated'
100+
];
103101
}
104102

105103
public function row($model)
106104
{
107-
return [$model->name, $model->email, $model->created_at, $model->updated_at];
105+
return [
106+
$model->name,
107+
$model->email,
108+
$model->created_at,
109+
$model->updated_at
110+
];
108111
}
109112
}
110113
```
111114

112115
## Rendering the table view
113-
The easiest way to render the view is using the facade directly with a blade file
116+
You can render this view in the same way as you would do it for a livewire component ([Rendering components](https://laravel-livewire.com/docs/2.x/rendering-components)).
117+
The easiest way to render the view is using the livewire tag syntax:
114118
```blade
115-
{!! LaravelViews::create(App\Http\Livewire\UsersTableView::class)->render() !!}
119+
<livewire:users-table-view />
120+
```
121+
122+
You could also use the `@livewire` blade directive.
123+
```blade
124+
@livewire('users-table-view')
116125
```
117126

118127
At this point, you would be able to see a table with some data, the table view doesn't have any styled container or title as the image example, you can render the table view inside any container you want.
@@ -123,89 +132,22 @@ This is the basic usage of the table view, but you can customize it with more fe
123132

124133
[Read the full table view documentation ](doc/table-view.md)
125134

126-
# Rendering a view
135+
## Advanced usage
127136

128-
## From a controller
137+
[Read the advanced laravel-views documentation ](doc/laravel-views.md)
129138

130-
The easiest way to render a view is using the facade directly on the blade file as the example above,
131-
but it is a better practice if you inject a `LaravelViews` instance as a dependency in your controller.
139+
## Views available
140+
### [Table view](doc/table-view.md)
132141

133-
```php
134-
use use LaravelViews\LaravelViews;
142+
Dynamic data table with some features like filters, pagination and search input, you can customize the headers, the data to be displayed for each row
135143

136-
public function index(LaravelViews $laravelViews)
137-
{
138-
$laravelViews->create(App\Http\Livewire\UsersTableView::class);
144+
![](doc/table.png)
139145

140-
return view('my-view', [
141-
'view' => $laravelViews
142-
]);
143-
}
144-
```
145-
And render it in your blade file
146-
```blade
147-
{!! $view->render() !!}
148-
```
149-
150-
## Specifying a layout and section
151-
You can also return the view directly from your controller and specify the layout and section of your layout
152-
```php
153-
use use LaravelViews\LaravelViews;
154-
155-
public function index(LaravelViews $laravelViews)
156-
{
157-
$laravelViews->create(App\Http\Livewire\UsersTableView::class)
158-
->layout('layout', 'section-name');
146+
### [Grid view](doc/grid-view.md)
159147

160-
return $laravelViews->render();
161-
}
162-
```
163-
164-
## Send extra data
165-
In the same way that you would send data to your views, you can send more data to the layout file
166-
```php
167-
use use LaravelViews\LaravelViews;
168-
169-
public function index(LaravelViews $laravelViews)
170-
{
171-
$laravelViews->create(App\Http\Livewire\UsersTableView::class)
172-
->layout('layout', 'section-name', [
173-
'title' => 'My layout title'
174-
]);
175-
176-
return $laravelViews->render();
177-
}
178-
```
179-
180-
# Components customization
181-
These views are build with [Tailwind CSS](https://tailwindcss.com/) and you can either change the colors of the components following tailwindcss utilities or fully customize all the html of the components
182-
183-
## Component variants using tailwindcss
184-
If you are using [Tailwind CSS](https://tailwindcss.com/) or if you don't have issues using Tailwindcss and your own css styles, you can customize some utilities to change the color for each variant of the components publishing a config file
185-
186-
```bash
187-
php artisan vendor:publish --tag=config
188-
```
189-
or you can specify the provider
190-
```bash
191-
php artisan vendor:publish --tag=config --provider='LaravelViews\LaravelViewsServiceProvider'
192-
```
193-
194-
Inside this config file you can change the colors for each component variant. If you are updating this package you might need to republish this config file.
195-
196-
## Components full customization
197-
198-
If you are not using taildwindcss, or if you want to have a full customization over the html components, you can publish all the blade files used for these views.
199-
200-
```bash
201-
php artisan vendor:publish --tag=views
202-
```
203-
or you can specify the provider
204-
```bash
205-
php artisan vendor:publish --tag=views --provider='LaravelViews\LaravelViewsServiceProvider'
206-
```
148+
Dynamic grid view using card data, same as a TableView this view has features like filters, pagination and a search input, you can also customize the card data as you need
207149

208-
If you are updating this package you might need to republish these views.
150+
![](doc/grid.png)
209151

210152
## Contributing
211153

@@ -217,10 +159,11 @@ Laravel Views is still under heavy development so I will be adding more awesome
217159

218160
Here's the plan for what's coming:
219161

220-
- *New grid view* to display data as a grid instead of as a table
162+
- **New list view**
163+
- **New detail view**
164+
- **New form view**
165+
- **New layout view**
221166
- Add tooltips to actions buttons
222-
- Add confirmation message on actions
223167
- Add a download action
224168
- Add translations
225-
- Add sortable columns
226169
- Add links as a UI helpers

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"livewire/livewire": "^2.0"
13+
"livewire/livewire": "2.*"
1414
},
1515
"autoload": {
1616
"psr-4": {
@@ -19,8 +19,9 @@
1919
}
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "6.0.*|7.0.*|8.5.*",
23-
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*|4.*|5.*|6.*"
22+
"phpunit/phpunit": "7.0.*|8.5.*|9.5.*",
23+
"orchestra/testbench": "4.*|5.*|6.*",
24+
"laravel/legacy-factories": "^1.1"
2425
},
2526
"extra": {
2627
"laravel": {

0 commit comments

Comments
 (0)