Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages

Installation Instructions

composer require konsulting/nova-target

Readme

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.

Back to Top
Added 2 years ago
Last updated 10 Months Ago
Version 1.0.2
Nova Version ^4.26|^5.0
Composer
konsulting/nova-target
GitHub stars 5
Packagist downloads 6,828

Favorites

0 users favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
3 ratings

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas