From 56b66f2242b262b11137d5728a271a8e0163eec7 Mon Sep 17 00:00:00 2001 From: Roman Schmid Date: Thu, 4 May 2017 10:41:25 +0200 Subject: [PATCH] Updated readme for 4.x --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1520c1c..38671ed 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,18 @@ The ColorPicker Module adds a color-picker input field to the SilverStripe CMS. It makes use of the ColorPicker jQuery Plugin. +## Requirements + +SilverStripe Framework v4+ + +For a Version that is compatible to SilverStripe 3+, consider using the [3.0 release](https://github.com/tractorcow/silverstripe-colorpicker/releases/tag/3.0.0) + ## Installation - * Extract all files into the 'colorpicker' folder under your Silverstripe root, or install using composer +Install using composer ```bash -composer require "tractorcow/silverstripe-colorpicker" "3.0.*@dev" +composer require tractorcow/silverstripe-colorpicker ^4@dev ``` ## Usage @@ -17,7 +23,7 @@ Here's how you define a DB field to be a color: ```php private static $db = array( - 'BgColor' => 'Color' + 'BgColor' => 'TractorCow\Colorpicker\Color' ); ``` @@ -32,7 +38,7 @@ public function getCMSFields() $fields->addFieldToTab( 'Root.Main', - new ColorField('BgColor', 'Background color') + ColorField::create('BgColor', 'Background color') ); return $fields; @@ -41,7 +47,8 @@ public function getCMSFields() ### Tips for using the Color fieldtype in templates -The `Color` fieldtype provides some helper methods that can be useful in templating. Let's consider the above scenario where you have a Field named 'BgColor'. The most common use-case is something like this: +The `TractorCow\Colorpicker\Color` fieldtype provides some helper methods that can be useful in templating. +Let's consider the above scenario where you have a Field named 'BgColor'. The most common use-case is something like this: ```html @@ -64,6 +71,5 @@ Here's a complete list of the `Color` methods available in templates: - `Blue` returns the blue color component - `CSSColor` returns the color as `rgba`. The alpha value can be specified with the (optional) argument. - `Luminance` the luminance of the color as a floating-point value ranging from 0-1 + - `Blend` blends the color with a second background color (defaults to #FFFFFF) with the given opacity. `$BGColor.Blend(0.5, '#000000')` will give the color 50% opacity and put it on top of a black background. - `AlteredColorHSV` modifies the current color by the given HSV values. These values are offsets, so you could do something like this: `$BgColor.AlteredColorHSV(0.5, 0, 0)` which will return the color with the opposite hue. All parameters are percentage based and range from `0 - 1`. So doing: `$BgColor.AlteredColorHSV(0, 0, -0.2)` will result in a color with 20% less brightness (absolute, not relative). - -