Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysLees committed Mar 21, 2024
1 parent fd19707 commit f9a539f
Show file tree
Hide file tree
Showing 25 changed files with 372 additions and 215 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelog

All notable changes to `filament-codemirror` will be documented in this file.
All notable changes to `filament-json-field` will be documented in this file.
135 changes: 108 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,139 @@
# This is my package filament-codemirror
<img src="https://banners.beyondco.de/Filament%20Json%20Field.png?theme=light&packageManager=composer+require&packageName=codebar-ag%2Ffilament-json-field&pattern=circuitBoard&style=style_2&description=A+Laravel+Filament Json Field+integration.&md=1&showWatermark=1&fontSize=150px&images=home&widths=500&heights=500">

[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/filament-codemirror.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-codemirror)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-codemirror/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/codebar-ag/filament-codemirror/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-codemirror/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/codebar-ag/filament-codemirror/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/filament-codemirror.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-codemirror)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/filament-json-field.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-json-field)
[![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/filament-json-field.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-json-field)
[![run-tests](https://github.com/codebar-ag/filament-json-field/actions/workflows/run-tests.yml/badge.svg)](https://github.com/codebar-ag/filament-json-field/actions/workflows/run-tests.yml)
[![PHPStan](https://github.com/codebar-ag/filament-json-field/actions/workflows/phpstan.yml/badge.svg)](https://github.com/codebar-ag/filament-json-field/actions/workflows/phpstan.yml)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
This package was developed to give you a quick start to creating tickets via the Filament Json Field API.

## Support us
## 💡 What is Filament Json Field?

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/filament-codemirror.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/filament-codemirror)
Filament Json Field is a Filament wrapper for Codemirror.

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
## 🛠 Requirements

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
| Package | PHP | Laravel | Filament Infolists | Filament Support | Filament Tables |
|-----------|-------|------------|--------------------|------------------|-----------------|
| v1.0 | 8.2 | 10.0, 11.0 | 3.2 | 3.2 | 3.2 |

## Installation

## ⚙️ Installation

You can install the package via composer:

```bash
composer require codebar-ag/filament-codemirror

composer require codebar-ag/filament-json-field
php artisan filament:assets
```

## To compile the assets for distribution

## Usage

Forms:
```php
use CodebarAg\FilamentJsonField\Forms\Components\JsonInput;

...

public function form(Form $form): Form
{
return $form
->schema([
JsonInput::make('json')
->label('JSON')
->lineNumbers(true)
->autoCloseBrackets(true)
->darkTheme(true)
->foldingCode(true),
]);
}
...
````

Infolists:
```php
use CodebarAg\FilamentJsonField\Forms\Components\JsonEntry;

...

public function form(Form $form): Form
{
return $form
->schema([
JsonEntry::make('json')
->label('JSON')
->lineNumbers(true)
->autoCloseBrackets(true)
->darkTheme(true)
->foldingCode(true),
]);
}
...
````

### Options

The following options are currently supported:

| Request | Supported |
|---------------------|:-----------:|
| Line Numbers | ✅ |
| Auto Close Brackets | ✅ |
| Dark Theme | ✅ |
| Folding Code | ✅ |

## 🚧 Testing

Copy your own phpunit.xml-file.

```bash
node bin/build
cp phpunit.xml.dist phpunit.xml
```

## Testing
Run the tests:

```bash
composer test
./vendor/bin/pest
```

## Changelog
## 🚧 Building

```bash
node bin/build
```

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
Note: there is no output, but the build will be in the `dist` directory.

## Contributing
## 📝 Changelog

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Please see [CHANGELOG](CHANGELOG.md) for recent changes.

## Security Vulnerabilities
## ✏️ Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

```bash
composer test
```

### Code Style

```bash
./vendor/bin/pint
```

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## 🧑‍💻 Security Vulnerabilities

## Credits
Please review [our security policy](.github/SECURITY.md) on reporting security vulnerabilities.

- [Rhys Lees](https://github.com/43909932+RhysLees)
## 🙏 Credits
- [Rhys Lees](https://github.com/RhysLees)
- [Sebastian Fix](https://github.com/StanBarrows)
- [All Contributors](../../contributors)
- [Skeleton Repository from Spatie](https://github.com/spatie/package-skeleton-laravel)
- [Laravel Package Training from Spatie](https://spatie.be/videos/laravel-package-training)

## License
## 🎭 License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
The MIT License (MIT). Please have a look at [License File](LICENSE.md) for more information.
4 changes: 2 additions & 2 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as esbuild from 'esbuild';

esbuild.build({
entryPoints: ['./resources/js/codemirror.js'],
outfile: './dist/codemirror.js',
entryPoints: ['./resources/js/filament-json-field.js'],
outfile: './dist/filament-json-field.js',
bundle: true,
mainFields: ['module', 'main'],
platform: 'browser',
Expand Down
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "codebar-ag/filament-codemirror",
"description": "This is my package filament-codemirror",
"name": "codebar-ag/filament-json-field",
"description": "This is my package filament-json-field",
"keywords": [
"CodebarAg",
"laravel",
"filament-codemirror"
"filament-json-field"
],
"homepage": "https://github.com/codebar-ag/filament-codemirror",
"homepage": "https://github.com/codebar-ag/filament-json-field",
"license": "MIT",
"authors": [
{
Expand All @@ -26,6 +26,7 @@
"filament/support": "^3.2",
"filament/tables": "^3.2",
"illuminate/contracts": "^10.0||^11.0",
"livewire/livewire": "^3.4",
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
Expand All @@ -43,19 +44,19 @@
},
"autoload": {
"psr-4": {
"CodebarAg\\FilamentCodemirror\\": "src/",
"CodebarAg\\FilamentCodemirror\\Database\\Factories\\": "database/factories/"
"CodebarAg\\FilamentJsonField\\": "src/",
"CodebarAg\\FilamentJsonField\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"CodebarAg\\FilamentCodemirror\\Tests\\": "tests/",
"CodebarAg\\FilamentJsonField\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-filament-codemirror --ansi",
"clear": "@php vendor/bin/testbench package:purge-filament-json-field --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
Expand All @@ -81,10 +82,10 @@
"extra": {
"laravel": {
"providers": [
"CodebarAg\\FilamentCodemirror\\FilamentCodemirrorServiceProvider"
"CodebarAg\\FilamentJsonField\\FilamentJsonFieldServiceProvider"
],
"aliases": {
"FilamentCodemirror": "CodebarAg\\FilamentCodemirror\\Facades\\FilamentCodemirror"
"FilamentJsonField": "CodebarAg\\FilamentJsonField\\Facades\\FilamentJsonField"
}
}
},
Expand Down
6 changes: 0 additions & 6 deletions config/filament-codemirror.php

This file was deleted.

2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CodebarAg\FilamentCodemirror\Database\Factories;
namespace CodebarAg\FilamentJsonField\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "filament-codemirror",
"name": "filament-json-field",
"version": "1.0.0",
"description": "[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/filament-codemirror.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-codemirror) [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-codemirror/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/codebar-ag/filament-codemirror/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-codemirror/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/codebar-ag/filament-codemirror/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/filament-codemirror.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-codemirror)",
"description": "[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/filament-json-field.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-json-field) [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-json-field/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/codebar-ag/filament-json-field/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/codebar-ag/filament-json-field/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/codebar-ag/filament-json-field/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/filament-json-field.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/filament-json-field)",
"type": "module",
"main": "index.js",
"directories": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "codemirror/src/codemirror.js";
import "codemirror/src/modes";

import "codemirror/mode/javascript/javascript";
import "codemirror/mode/";

import "codemirror/addon/edit/closebrackets";
import "codemirror/addon/edit/closetag";
Expand Down
4 changes: 2 additions & 2 deletions resources/views/infolists/components/json-entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class="relative rounded-md"
}
@endphp
gutters: [
'CodeMirror-linenumbers',
{{ json_encode($getHasFoldingCode()) }} ? 'CodeMirror-foldgutter' : ''
{{ json_encode($getHasLineNumbers()) }} ? 'CodeMirror-linenumbers' : '',
{{ json_encode($getHasFoldingCode()) }} ? 'CodeMirror-foldgutter' : '',
],
foldOptions: {
widget: (from, to) => {
Expand Down
22 changes: 22 additions & 0 deletions src/Concerns/HasAutoCloseBrackets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CodebarAg\FilamentJsonField\Concerns;

use Closure;

trait HasAutoCloseBrackets
{
protected bool|Closure $hasAutoCloseBrackets = true;

public function autoCloseBrackets(bool|Closure $condition = true): static
{
$this->hasAutoCloseBrackets = $condition;

return $this;
}

public function getHasAutoCloseBrackets(): bool
{
return (bool) $this->evaluate($this->hasAutoCloseBrackets);
}
}
22 changes: 22 additions & 0 deletions src/Concerns/HasDarkTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CodebarAg\FilamentJsonField\Concerns;

use Closure;

trait HasDarkTheme
{
protected bool|Closure $hasDarkTheme = false;

public function darkTheme(bool|Closure $condition = true): static
{
$this->hasDarkTheme = $condition;

return $this;
}

public function getHasDarkTheme(): bool
{
return (bool) $this->evaluate($this->hasDarkTheme);
}
}
22 changes: 22 additions & 0 deletions src/Concerns/HasFoldingCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CodebarAg\FilamentJsonField\Concerns;

use Closure;

trait HasFoldingCode
{
protected bool|Closure $hasFoldingCode = true;

public function foldingCode(bool|Closure $condition = true): static
{
$this->hasFoldingCode = $condition;

return $this;
}

public function getHasFoldingCode(): bool
{
return (bool) $this->evaluate($this->hasFoldingCode);
}
}
22 changes: 22 additions & 0 deletions src/Concerns/HasLineNumbers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CodebarAg\FilamentJsonField\Concerns;

use Closure;

trait HasLineNumbers
{
protected bool|Closure $hasLineNumbers = true;

public function lineNumbers(bool|Closure $condition = true): static
{
$this->hasLineNumbers = $condition;

return $this;
}

public function getHasLineNumbers(): bool
{
return (bool) $this->evaluate($this->hasLineNumbers);
}
}
Loading

0 comments on commit f9a539f

Please sign in to comment.