Commit 95dfd0d5 authored by NickWilde's avatar NickWilde

git commit -m 'Issue #2999873: Enforce PHP/CSS Code Standards'

parent 5a395e36
.idea/
/core/
/vendor/
/modules/
composer.lock
......@@ -13,7 +13,8 @@
list of colors. If enabled, opacity is a number field.
- *Color Default*: Textbox to put in a hex value. If enabled, opacity is a
number field.
- *Color Grid*: Uses [jQuery Simple Color](https://github.com/recurser/jquery-simple-color)
- *Color Grid*: Uses
[jQuery Simple Color](https://github.com/recurser/jquery-simple-color)
to provide a pop up grid of color options. If enabled, opacity is a number
field.
- *Color HTML5*: Uses the color HTML5 input type to render in a browser/system
......@@ -32,7 +33,7 @@ integrated slider for opacity (if opacity is enabled).
## INSTALLATION
Install as you would normally install a contributed Drupal module. See also
[Core Documentation](https://www.drupal.org/docs/8/extending-drupal-8/installing-modules)
[Core Docs](https://www.drupal.org/docs/8/extending-drupal-8/installing-modules)
### DEPENDENCIES
There are JavaScript libraries required for a couple of the field widgets. If
......@@ -103,6 +104,12 @@ Field
2. Select the 'Color Field' field type
3. Select the 'Color' widget you want
## DEVELOPMENT
To ease matching Drupal code standards, development dependencies are configured
to use a pre-commit hook. Install composer dev dependencies and PHPCS will be
automatically run if php is in your path.
## CREDIT
Original Creator: [targoo](https://www.drupal.org/u/targoo).
......
......@@ -4,7 +4,9 @@
"drupal/core": "*"
},
"require-dev": {
"drupal/token": "~1.3"
"drupal/token": "~1.3",
"php-composter/php-composter": "^0.3.3",
"nickwilde1990/php-composter-phpcs-drupal": "^1.0"
},
"suggest": {
"bower-asset/jquery-simple-color": "^v1.2.2: Provides JavaScript library necessary for the Color Grid widget",
......@@ -27,10 +29,18 @@
"role": "Maintainer"
}
],
"repositories":[
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"description": "Provides a color field type to store the color value and opacity",
"homepage": "https://www.drupal.org/project/color_field",
"support": {
"issues": "https://www.drupal.org/project/issues/color_field?version=8.x",
"source": "http://cgit.drupalcode.org/color_field"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
.color_field_widget_box__square {
border: 1px solid #000;
box-shadow: 0 0 1px #000;
box-sizing: border-box;
height: 16px;
margin: 2px;
width: 16px;
......@@ -17,6 +18,7 @@
background-repeat: no-repeat;
border: 1px solid #000;
box-shadow: 0 0 1px #000;
box-sizing: border-box;
height: 16px;
margin: 2px;
width: 16px;
......
......@@ -94,13 +94,13 @@ class ColorCMY extends ColorBase {
* {@inheritdoc}
*/
public function toHex() {
return $this->toRGB()->toHex();
return $this->toRgb()->toHex();
}
/**
* {@inheritdoc}
*/
public function toRGB() {
public function toRgb() {
$red = (1 - $this->cyan) * 255;
$green = (1 - $this->magenta) * 255;
$blue = (1 - $this->yellow) * 255;
......@@ -110,7 +110,7 @@ class ColorCMY extends ColorBase {
/**
* {@inheritdoc}
*/
public function toCMY() {
public function toCmy() {
$cyan = ($this->cyan * (1 - $this->key) + $this->key);
$magenta = ($this->magenta * (1 - $this->key) + $this->key);
$yellow = ($this->yellow * (1 - $this->key) + $this->key);
......
......@@ -114,20 +114,20 @@ class ColorCMYK extends ColorBase {
* {@inheritdoc}
*/
public function toHex() {
return $this->toRGB()->toHex();
return $this->toRgb()->toHex();
}
/**
* {@inheritdoc}
*/
public function toRGB() {
return $this->toCMY()->toRGB();
public function toRgb() {
return $this->toCmy()->toRgb();
}
/**
* {@inheritdoc}
*/
public function toCMY() {
public function toCmy() {
$cyan = ($this->cyan * (1 - $this->key) + $this->key);
$magenta = ($this->magenta * (1 - $this->key) + $this->key);
$yellow = ($this->yellow * (1 - $this->key) + $this->key);
......
......@@ -55,7 +55,7 @@ class ColorHex extends ColorBase {
* The color in format: #RRGGBB.
*/
public function toString($opacity = TRUE) {
$rgb = $this->toRGB();
$rgb = $this->toRgb();
$hex = '#';
$hex .= str_pad(dechex($rgb->getRed()), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb->getGreen()), 2, "0", STR_PAD_LEFT);
......@@ -76,7 +76,7 @@ class ColorHex extends ColorBase {
/**
* {@inheritdoc}
*/
public function toRGB() {
public function toRgb() {
$red = (($this->color & 0xFF0000) >> 16);
$green = (($this->color & 0x00FF00) >> 8);
$blue = (($this->color & 0x0000FF));
......
......@@ -29,11 +29,11 @@ interface ColorInterface {
* @return \Drupal\color_field\ColorRGB
* The color as a RGB instance.
*/
public function toRGB();
public function toRgb();
// Public function toHSV();
// public function toHSL();
// public function toRGB();
// public function toRgb();
// public function toCMYK();
// public function toCSS();
}
......@@ -119,7 +119,7 @@ class ColorRGB extends ColorBase {
/**
* {@inheritdoc}
*/
public function toRGB() {
public function toRgb() {
return $this;
}
......
......@@ -205,10 +205,10 @@ class ColorFieldFormatterCss extends FormatterBase implements ContainerFactoryPl
$color_hex = new ColorHex($item->color, $item->opacity);
if ($opacity && $settings['opacity']) {
$rgbtext = $color_hex->toRGB()->toString(TRUE);
$rgbtext = $color_hex->toRgb()->toString(TRUE);
}
else {
$rgbtext = $color_hex->toRGB()->toString(FALSE);
$rgbtext = $color_hex->toRgb()->toString(FALSE);
}
return $rgbtext;
......
......@@ -154,10 +154,10 @@ class ColorFieldFormatterSwatch extends FormatterBase {
$color_hex = new ColorHex($item->color, $item->opacity);
if ($opacity && $settings['opacity']) {
$rgbtext = $color_hex->toRGB()->toString(TRUE);
$rgbtext = $color_hex->toRgb()->toString(TRUE);
}
else {
$rgbtext = $color_hex->toRGB()->toString(FALSE);
$rgbtext = $color_hex->toRgb()->toString(FALSE);
}
return $rgbtext;
......
......@@ -132,10 +132,10 @@ class ColorFieldFormatterText extends FormatterBase {
case 'rgb':
if ($opacity && $settings['opacity']) {
$output = $color_hex->toRGB()->toString(TRUE);
$output = $color_hex->toRgb()->toString(TRUE);
}
else {
$output = $color_hex->toRGB()->toString(FALSE);
$output = $color_hex->toRgb()->toString(FALSE);
}
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment