LaravelPackages.net
Acme Inc.
Toggle sidebar
konsulting/nova-target

Target elements to hide or adjust classes in Laravel Nova resources

8.570
5
1.0.2
About konsulting/nova-target

konsulting/nova-target is a Laravel package for target elements to hide or adjust classes in laravel nova resources. It currently has 5 GitHub stars and 8.570 downloads on Packagist (latest version 1.0.2). Install it with composer require konsulting/nova-target. Discover more Laravel packages by konsulting or browse all Laravel packages to compare alternatives.

Last updated

nova-target

Target elements to hide or adjust classes in Laravel Nova resources

NovaTarget is a Laravel Nova 4 field, that is hidden and utilised to target and alter HTML DOM elements. It has been kept intentionally simple.

For quite a while we looked for a way to hide the 'Create and Add Another' and 'Update and Continue Editing' buttons for some resources. The only solution seen was to add some global CSS to always hide the buttons based on the Dusk selector.

This package essentially builds on that but utilises a field on the Resource page(s) so the CSS is targeted (as it only appears when the field is used).

Following simple hiding, we have added the ability to alter, or replace classes on elements too, such as re-colouring a button.

To install, simply:

    composer require konsulting/nova-target:^1.0

To use, simply add the field to the form and called one of the following methods.

\Konsulting\NovaTarget\NovaTarget::make('')
    ->hideCreateAndAddAnotherButton()
\Konsulting\NovaTarget\NovaTarget::make('')
    ->hideUpdateAndContinueEditingButton()
\Konsulting\NovaTarget\NovaTarget::make('')
    // ->replaceElementClass($cssSelector, $newClasses)
    ->replaceElementClass('[dusk=update-and-continue-editing-button]', 'bg-red-500')
\Konsulting\NovaTarget\NovaTarget::make('')
    // ->adjustElementClass($cssSelector, $removeClasses, $addClasses)
    ->adjustElementClass('[dusk=update-and-continue-editing-button]', 'bg-primary-500 hover:bg-primary-400 ring-primary-200', 'bg-gray-500 hover:bg-gray-400 ring-gray-200')

We are happy to receive contributions to this package.

Star History Chart