Giter Club home page Giter Club logo

nova-rating-field's Introduction

Nova Rating field

A Star rating field to use in your Laravel Nova apps.

Uses vue-star-rating.

Latest Version on Packagist Total Downloads


Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require nikaia/nova-rating-field

Next you can use the Nikaia\Rating\Rating field in your Nova resource.

Usage

public function fields(Request $request)
{
    return [
        // ...

        Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideFromIndex(),
        
        // Defining a custom style for the index page.
        Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideRating()
            ->withStyles([
                'star-size' => 15,
                'rounded-corners' => true,
            ])->onlyOnIndex()->sortable(),

        // ...    
        
    ];
}

Defining properties

public function fields(Request $request)
{
    Rating::make('Rating')
    
        // Miniumum rating (default: 0)
        ->min(0) 
        
        // Maximum rating (default: 5)
        // This is how the component knows how many stars it should display.
        ->max(5)
        
        // Incremet (default: 1)
        // Can be float. The underlying eloquent colum must be defined as float in that case.
        // ie. 0.5 for half stars or 0.01 for fluid stars.
        ->increment(0.5)
        
        // Show rating value next to the stars
        ->hideRating()
        
}

Customizing styles

You can style the component using withStyles method. Options are passed to the the underlying vue component style props.

Default values are :

public function fields(Request $request)
{
    Rating::make('Rating')
        ->withStyles([
            'star-size' => 30,
            'active-color' => 'var(--primary)', // Primary nova theme color.
            'inactive-color' => '#d8d8d8',
            'border-color' => 'var(--60)',
            'border-width' => 0,
            'padding' => 10,
            'rounded-corners' => false,
            'inline' => false,
            'glow' => 0,
            'glow-color' => '#fff',
            'text-class' => 'inline-block text-80 h-9 pt-2',
        ]);
}

nova-rating-field's People

Contributors

nbourguig avatar ahmed-mohammed1 avatar milewski avatar

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.