Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Refactoring and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ro committed Aug 1, 2023
1 parent eada8d2 commit ff02868
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to `filament-page-blocks` will be documented in this file.

## 1.0.2 - 2023-08-01

- Renamed command to create blocks
- Improved README
- Renamed form component to `PageBlockBuilder`

## 1.0.1 - 2023-08-01

- Added configuration to collapse block builder

## 1.0.0 - 2023-08-01

- initial release
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,69 @@ This is basically a lightweight version of [Z3d0X's](https://github.com/z3d0x) e
It only provides the blocks functionality without layouts, pages, routing, etc.

## Installation

You can install this package via composer:
```bash
composer require martin-ro/filament-page-blocks
```

## Creating a block
## Documentation
Documentation can be viewed at: https://filamentphp.com/plugins/fabricator


## Creating a Page Block

```bash
php artisan make:page-block
php artisan make:filament-page-block MyPageBlock
```

This will create the following Page Block class:

```php
use Filament\Forms\Components\Builder\Block;
use MartinRo\FilamentPageBlocks\PageBlock;

class MyBlock extends PageBlock
{
public static function getBlockSchema(): Block
{
return Block::make('my-page-block')
->label('My Page Block')
->icon('heroicon-o-rectangle-stack')
->schema([
//
]);
}

public static function mutateData(array $data): array
{
return $data;
}
}
```

and its corresponding blade component view:
```html
<div>
//
</div>
```

## Using blocks in your template
## Using Page Blocks in your template

```html
<x-filament-page-blocks::page-blocks :blocks="$page->blocks" />
```
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Credits

- [Ziyaan Hassan](https://github.com/Z3d0X)
- [Martin Ro](https://github.com/martin-ro)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
2 changes: 1 addition & 1 deletion src/Commands/MakePageBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MakePageBlockCommand extends Command
use CanManipulateFiles;
use CanValidateInput;

protected $signature = 'make:page-block {name?} {--F|force}';
protected $signature = 'make:filament-page-block {name?} {--F|force}';

protected $description = 'Create a new filament page block';

Expand Down
4 changes: 2 additions & 2 deletions src/FilamentPageBlockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Filament\Contracts\Plugin;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use MartinRo\FilamentPageBlocks\Forms\Components\PageBuilder;
use MartinRo\FilamentPageBlocks\Forms\Components\PageBlockBuilder;

class FilamentPageBlockPlugin implements Plugin
{
Expand All @@ -28,7 +28,7 @@ public function register(Panel $panel): void

public function boot(Panel $panel): void
{
PageBuilder::configureUsing(function (PageBuilder $builder) {
PageBlockBuilder::configureUsing(function (PageBlockBuilder $builder) {
$builder->collapsible($this->shouldBeCollapsible())
->collapsed($this->shouldBeCollapsed());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
use Illuminate\Support\HtmlString;
use MartinRo\FilamentPageBlocks\Facades\FilamentPageBlocks;

class PageBuilder extends Builder
class PageBlockBuilder extends Builder
{
protected function setUp(): void
{
parent::setUp();

$this->blocks(FilamentPageBlocks::getPageBlocks());

$this->label(fn () => new HtmlString('<h1 class="fi-header-heading text-xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-2xl">Content Blocks</h1>'));
$this->label(fn () => new HtmlString('<h1 class="fi-header-heading text-xl font-bold tracking-tight text-gray-950 dark:text-white sm:text-2xl">Page Blocks</h1>'));

$this->addActionLabel('Add Block');

Expand Down

0 comments on commit ff02868

Please sign in to comment.