kak/colorpicker

为Yii2设计的颜色选择器小部件

v1.0.0 2020-03-09 12:38 UTC

This package is auto-updated.

Last update: 2024-08-29 05:29:02 UTC


README

安装此扩展的首选方式是通过 Composer

运行以下命令之一

php composer.phar require --prefer-dist kak/colorpicker "*"

此包包含2个小部件 InputColorInputGradient

输入颜色

预览

用法

一旦安装了扩展,只需在代码中使用它即可

<?= $form->field($model, 'color')->widget(InputColor::class, [
   'clientOptions' => [], // js options lib pickr 
   'theme' => InputColor::THEME_MONOLITH,  // default theme
   'addonPreview' => true, // displays a preview of the color next to the {input}
   // 'addonPreview' => false, // displays the {input} preview in the background and inverts the text color
]); ?>

clientOptions 查看js库 https://github.com/Simonwep/pickr#options

输入渐变

预览

用法

一旦安装了扩展,只需在代码中使用它即可

<?= $form->field($model, 'color_gradient')->widget(InputGradient::class, [
   'clientOptions' => [], // js options lib pickr 
   'theme' => InputColor::THEME_MONOLITH,  // default theme
   'createLabel' => '', // btn create point label
   'createOptions' => [], // btn create point options

]); ?>

clientOptions 查看js库 https://github.com/Simonwep/pickr#options

JS事件

  • gradient:change(颜色)
    • 格式化参数事件
    [{
        color: 'hex|rbg',
        stop: '13'
    }]