Skip to content

mattsplat/readmore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Read More

For the index view adds the ability to shorten text/textarea or show all by clicking on the field.

Works by adding a macro to Laravel Nova Text which is extended by TextArea so it works for both.

Install

composer require mattsplat/readmore

Usage with TextArea

Textarea::make('Notes')
    ->showOnIndex()
    ->readMore(),
                

with options


Textarea::make('Notes')
    ->showOnIndex()
    ->readMore(['mask' => 'Look Here', 'max' => 5]),

or using Text


Text::make('Notes')->readMore(),

Options

  • max - number of characters to display (default 20)
  • mask - text displayed to show all text (default ...)

Use an icon instead of text

$icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path class="heroicon-ui" d="M6 2h9a1 1 0 0 1 .7.3l4 4a1 1 0 0 1 .3.7v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.1.9-2 2-2zm9 2.41V7h2.59L15 4.41zM18 9h-3a2 2 0 0 1-2-2V4H6v16h12V9zm-5 4h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2v-2a1 1 0 0 1 2 0v2z"/></svg>';

Text::make('Notes')->readMore(['max' => 0, 'mask' => $icon]),

Inspired by

Index TextArea by Brian Dillingham