leonardohipolito / blade-class-props
easy way to convert blade component properties to classes
dev-main
2023-08-15 14:15 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.16.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-01-08 14:35:48 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require leonardohipolito/blade-class-props
Usage
// .../views/components/button.blade.php <div {{$attributes->classProps(['lg'=>'class-1 class-2','md'=>'class-3'], 'md')}}> {{$slot}} </div> //or <div {{$attributes->classProps(['lg'=>'class-1 class-2','md'=>'class-3'])}}> {{$slot}} </div> //or <button {{$attributes ->classProps([ 'xs'=>fn($c)=>$c->has('outline')?'text-primary-500':'bg-primary-500 text-white', 'md'=>'button-md' ],'md') ->classProps([ 'outline'=>'bg-transparent' ]) }}> {{$slot}} </button>
now you can use your component:
<x-button lg>Test</x-button> <x-button :lg="fn():bool=>true">Test</x-button>
outputs:
<div class="class-1 class-2"> Test </div>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.