1. Go to this page and download the library: Download ynacorp/nova-swatches library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ynacorp / nova-swatches example snippets
namespace App\Nova;
use Yna\NovaSwatches\Swatches;
class Article extends Resource
{
// ...
public function fields(Request $request)
{
return [
// ...
Swatches::make('Color'),
// ...
];
}
}
public function fields(Request $request)
{
return [
// ...
// material-basic is a basic collection of material colors.
Swatches::make('Color')->colors('material-basic'),
// ...
];
}
public function fields(Request $request)
{
return [
// ...
// material-basic is a basic collection of material colors.
Swatches::make('Color')->colors(['#ffffff', '#000']),
// ...
];
}
public function fields(Request $request)
{
return [
// ...
Swatches::make('Color')
->withProps([
'colors' => ["#4ae2c4", "#4fccff", "#41c84d"],
'show-fallback' => true,
'fallback-type' => 'input',
'popover-to' => 'left',
// More options at https://saintplay.github.io/vue-swatches/api/props.html
]),
// ...
];
}
return [
/**
* Props to pass to the vue-swatches component.
*
* See https://saintplay.github.io/vue-swatches/api/props.html
*/
'props' => [
'colors' => 'basic', // Preset
// 'colors' => 'material-basic', // Preset
// 'colors' => ['#ffffff', '#000'], // Array
// 'show-fallback' => true,
// 'fallback-input-type' => 'input', // Or "color"
]
];