Giter Site home page Giter Site logo

nova-help's Introduction

Warning This library is not maintained anymore but feel free to fork it. For info do not exitate contacting me.

Laravel Nova Help Field

A custom Nova fields which allows to show custom help messages within form, detail and index screens.

Base example

Changelog

See changelog here.

Install

Run this command in your nova project:

composer require comodolab/nova-help

Then you can use the field in your resource as follow:

use Comodolab\Nova\Fields\Help\Help;

public function fields(Request $request)
{
    return [
        Help::make('Help title', 'Help message!'),
    ];
}

Base example

Options

Nova Help Field has many options as follow:

Default templates

Help::make('title', 'message'); // Default help message
Help::success('title', 'message');
Help::info('title', 'message');
Help::warning('title', 'message');
Help::danger('title', 'message');

// There's also a special template for headings
Help::header('title', 'subtitle');

// If you prefer you can call the non static type method
Help::make('title', 'message')->type('warning'); 

Help templates:

Base example

Headings template:

Base example

Both title and message are optional

Help::make('Only title');
Help::make()->message('Only message');

Messages can also be callable

Help::make()->message(function () {
    return "{$this->name} is awesome!";
});

Icons

You can pick one of the default SVG icons (http://www.zondicons.com/) provided by Steve Schoger.

Help::make('Title')->icon('help'); // the default one
Help::make('Title')->icon('info');
Help::make('Title')->icon('warning');
Help::make('Title')->icon('danger');
// Load a custom one
Help::make('Love you')
    ->message('Yes, I love you!')
    ->icon('<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10 3.22-.61-.6a5.5 5.5 0 0 0 -7.78 7.77l8.39 8.39 8.39-8.4a5.5 5.5 0 0 0 -7.78-7.77z"/></svg>');
// or show no icon at all
Help::make('Sad')->withoutIcon();

Base example

Render html messages

Help::make('Title', 'Message with <a href="#">link</a>')->displayAsHtml();

From v0.2 the displayAsHtml() method applies also to the field name (unless shown as column header on index).

Full width on details screen

// Remove annoing padding in detail screen, also the default behaviour for the heading template 
Help::make('Negative margin')->showFullWidthOnDetail();

Base example

With side label

// Show a side label instead of the title on the top
Help::make('Look I\'m on the side')
    ->message('I\'m not...')
    ->withSideLabel();

Base example

Collapsible help fields

Help fields can be made collapsible using the fluent method collapsible(). Collapsible help fields are collapsed by default and toggle their state clicking on their title. Also, keep in mind that collapsible fields must define both a title and message and cannot be used with side labels.

// Collapsible field
Help::info('Click here to toggle', 'Lorem ipsum dolor sit amet...')
    ->collapsible();

Base example

Show help messages on index

/**
 * By default help messages aren't shown on index,
 * when enabled they are shown as an hoverable 
 * icon showing a plain (no html) tooltip.
 */
Help::make('Column title')
    ->message('Message with <a href="#">link</a>') // The link code will be stripped out on index
    ->alsoOnIndex();
    
// Field icons can be shown conditionally on index
Help::make()->message(function () {
    return $this->name?"{$this->name} is awesome!":null;
})->onlyOnIndex();

Base example

nova-help's People

Contributors

bomshteyn avatar harlekoy avatar jeffbeltran avatar micc83 avatar mikebronner avatar spaantje avatar weeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nova-help's Issues

Doesn't work with a JSON field?

Thanks for this component - but I have a small issue: I have a prices column which is set to JSON in the database and cast as an Object on my resource.

If I make this field:

        Help::make()->message(function () {
            return $this->prices->gbp->comment;
        }),

I get an error 'trying to get property 'gbp' of none object'

However the help field shows as expected and dd($this->prices) or further clearly shows it as an object and I'm using it fine in this way on other nova fields.

I'm afraid I don't know how to debug it further sorry

Thanks

Laravel 8 Support

Does not currently support Laravel 8 due to illuminate/support dependency.

Laravel 7 support?

Is the author planning to update the package to support Laravel 7 soon?

not work

Declaration of Comodolab\Nova\Fields\Help\Help::jsonSerialize() must be compatible with Laravel\Nova\Fields\Field::jsonSerialize(): array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.