Skip to content

undeclared/nova-charcounted-fields

 
 

Repository files navigation

Nova Charcounter Fields

Not my work

Just a working package for myself

Text and textarea fields with a character counter for Laravel Nova.

Installation

Add the GitHub URL to your repositories list in composer.json:

"repositories": [
  {
    "type": "vcs",
    "url": "git@github.com:undeclared/nova-charcounted-fields.git"
  }
]

Usage

You can add the field with a resolver as follows:

use ElevateDigital\CharcountedFields\TextCounted;
use ElevateDigital\CharcountedFields\TextareaCounted;

TextCounted::make('Meta title')

Image of character counter

You can use the text and textarea fields with charactercounters on you Nova model. The max number of characters aren't enforced, but just encouraged with warning colors and the counter. (You could enforce the max number of characters with Nova's built in rules and with a maxlength extra attribute).

TextCounted::make('Meta title')
    ->maxChars(60)
    ->warningAt(50)
    ->withMeta(['extraAttributes' => ['maxlength' => '65']]),

TextareaCounted::make('Meta description')
    ->maxChars(160)
    ->warningAt(150)
    ->rows(3),

The maxChars and warningAt are both optional. The color of the counter will change when the max or warningAt limit is reached. Image of character counter with indication

About

Mirror of elevate-digital/nova-charcounted-fields.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Vue 57.9%
  • PHP 27.6%
  • JavaScript 13.8%
  • SCSS 0.7%