kak/colorpicker

color picker widgets for Yii2

Installs: 1 989

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

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

This package is auto-updated.

Last update: 2024-04-29 04:27:15 UTC


README

The preferred way to install this extension is through composer.

Either run

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

This package contains 2 widgets InputColor, InputGradient

Input Color

Preview

68747470733a2f2f646f63732e676f6f676c652e636f6d2f64726177696e67732f642f652f32504143582d3176524362673430784c6b4f6d2d386c414d4a5547674575686b78524445656e314c7773674b64345276397a68587a356e48337730744766524f4d48664a6871386a704e6d414f4979474675595970502f7075623f773d33313426683d353432

Usage

Once the extension is installed, simply use it in your code by :

<?= $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 see js lib https://github.com/Simonwep/pickr#options

Input Gradient

Preview

68747470733a2f2f646f63732e676f6f676c652e636f6d2f64726177696e67732f642f652f32504143582d31765432724c6f6572657a72536e636d64785674454f65704a6f664e5974352d3273555a3831447458465f68573749676f4a69734b59516b2d555835367867307653677061524b736e6d666b4c6b62372f7075623f773d36373226683d343736

Usage

Once the extension is installed, simply use it in your code by :

<?= $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 see js lib https://github.com/Simonwep/pickr#options

JS Events

  • gradient:change (colors)
    • format argument event
    [{
        color: 'hex|rbg',
        stop: '13'
    }]