elipzis/nova-embed-card

A custom Laravel Nova card to embed external content in an iframe

v1.0.0 2020-08-13 11:03 UTC

This package is auto-updated.

Last update: 2024-11-21 21:50:23 UTC


README

A custom Laravel Nova card to embed external content in an iframe, e.g. from YouTube on a dashboard.

Installation

You can install the package to your Laravel Nova enabled project via composer:

composer require elipzis/nova-embed-card

Usage

Use the EmbedCard() by adding it to your cards method of the NovaServiceProvider or your custom dashbord.

/**
 * Get the cards that should be displayed on the Nova dashboard.
 *
 * @return array
 */
protected function cards() {
    return [
        //Your other cards...
 
        //A most simple embed
        (new EmbedCard())->url('https://www.youtube.com/embed/WhWc3b3KhnY'),
        
        //A more complex embed of raw <iframe>...</iframe> HTML with header and footer
        (new EmbedCard())->header('Spring')->footer('A Blender Open Movie')->code('<iframe width="560" height="315" src="https://www.youtube.com/embed/WhWc3b3KhnY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
    ];
}

See the Laravel Nova documentation for more insights about cards.

Card options

Content options

  • url('string') : The URL to embed. If an URL is set, code is neglected.
  • code('string') : Raw <iframe>...</iframe> HTML content to embed.

Either url or code have to be configured

Text options

  • header('string'): Header text to lead the embedded content as simple text string or raw HTML
  • footer('string'): Footer text to conclude the embedded content as simple text string or raw HTML

Styling options

  • center('bool') : Center texts and content. Defaults to 'true'.
  • height('string') : The height of the card as 'auto', 'default' or a pixel number. Defaults to 'auto'
  • forceFullWidth() : Force the card to be full width
  • cardClasses('string') : CSS classes to attach to the card element
  • headerClasses('string') : CSS classes to attach to the header element
  • footerClasses('string') : CSS classes to attach to the footer element

Example

Screenshot

Compatibility

This custom Laravel Nova Embed Card has been tested with Laravel Nova v3.8.2

License and Credits

The Laravel Nova Embed Card is released under the MIT license by elipZis.

Disclaimer

This source and the whole package comes without a warranty. It may or may not harm your computer. Please use with care. Any damage cannot be related back to the author. The source has been tested on a virtual environment and scanned for viruses and has passed all tests.