Skip to content

Commit

Permalink
Merge pull request #5 from mansoorkhan96/feat/add-support-for-filamen…
Browse files Browse the repository at this point in the history
…t-v3

Feat/add support for filament v3
  • Loading branch information
mansoorkhan96 authored Aug 8, 2023
2 parents 8eed51a + 7868744 commit c001540
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ phpstan.neon
testbench.yaml
vendor
node_modules
**/.DS_Store
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ To install, require the package from composer:
composer require mansoor/filament-torchlight
```

### ⚠️ Use version `0.0.2` for Filament 2 support ⚠️

```bash
composer require "creagia/filament-code-field:^0.0.2"
```

## Setup Torchlight

You must follow the Torchlight documentation to [Add Torchlight Middleware](https://torchlight.dev/docs/clients/laravel#middleware) and [Publish the Torchlight configuration file](https://torchlight.dev/docs/clients/laravel#configuration)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
],
"require": {
"php": "^8.1",
"filament/filament": "*",
"filament/filament": "^3.0",
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.14.0",
"spatie/laravel-package-tools": "^1.15.0",
"torchlight/torchlight-laravel": "^0.5.13"
},
"require-dev": {
Expand Down
19 changes: 6 additions & 13 deletions resources/views/torchlight-code.blade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
:field="$field"
>
<pre>
<pre
x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref('filament-torchlight', package: 'mansoor/filament-torchlight'))]"
>
<x-torchlight-code
id="{{ $getId() }}"
dusk="filament.forms.{{ $getStatePath() }}"
language="{{ $getLanguage() ?? '' }}"
theme="{{ $getTheme() ?? '' }}"
language="{{ $field->getLanguage() ?? '' }}"
theme="{{ $field->getTheme() ?? '' }}"
{{ $attributes }}
>{!! $getState() !!}</x-torchlight-code>
</pre>
Expand Down
20 changes: 14 additions & 6 deletions src/FilamentTorchlightServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@

namespace Mansoor\FilamentTorchlight;

use Filament\PluginServiceProvider;
use Filament\Support\Assets\Css;
use Filament\Support\Facades\FilamentAsset;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentTorchlightServiceProvider extends PluginServiceProvider
class FilamentTorchlightServiceProvider extends PackageServiceProvider
{
protected array $styles = [
'filament-torchlight' => __DIR__.'/../resources/dist/css/filament-torchlight.css',
];
public static string $name = 'filament-torchlight';

public function configurePackage(Package $package): void
{
$package
->name('filament-torchlight')
->name(static::$name)
->hasAssets()
->hasViews();
}

public function packageBooted(): void
{
FilamentAsset::register(
[Css::make(static::$name, __DIR__.'/../resources/dist/css/filament-torchlight.css')->loadedOnRequest()],
'mansoor/filament-torchlight'
);
}
}

0 comments on commit c001540

Please sign in to comment.