Commit 95dfd0d5 authored by NickWilde's avatar NickWilde

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

parent 5a395e36
.idea/ .idea/
/core/
/vendor/
/modules/
composer.lock
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
list of colors. If enabled, opacity is a number field. list of colors. If enabled, opacity is a number field.
- *Color Default*: Textbox to put in a hex value. If enabled, opacity is a - *Color Default*: Textbox to put in a hex value. If enabled, opacity is a
number field. 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 to provide a pop up grid of color options. If enabled, opacity is a number
field. field.
- *Color HTML5*: Uses the color HTML5 input type to render in a browser/system - *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). ...@@ -32,7 +33,7 @@ integrated slider for opacity (if opacity is enabled).
## INSTALLATION ## INSTALLATION
Install as you would normally install a contributed Drupal module. See also 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 ### DEPENDENCIES
There are JavaScript libraries required for a couple of the field widgets. If There are JavaScript libraries required for a couple of the field widgets. If
...@@ -103,6 +104,12 @@ Field ...@@ -103,6 +104,12 @@ Field
2. Select the 'Color Field' field type 2. Select the 'Color Field' field type
3. Select the 'Color' widget you want 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 ## CREDIT
Original Creator: [targoo](https://www.drupal.org/u/targoo). Original Creator: [targoo](https://www.drupal.org/u/targoo).
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
"drupal/core": "*" "drupal/core": "*"
}, },
"require-dev": { "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": { "suggest": {
"bower-asset/jquery-simple-color": "^v1.2.2: Provides JavaScript library necessary for the Color Grid widget", "bower-asset/jquery-simple-color": "^v1.2.2: Provides JavaScript library necessary for the Color Grid widget",
...@@ -27,10 +29,18 @@ ...@@ -27,10 +29,18 @@
"role": "Maintainer" "role": "Maintainer"
} }
], ],
"repositories":[
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"description": "Provides a color field type to store the color value and opacity", "description": "Provides a color field type to store the color value and opacity",
"homepage": "https://www.drupal.org/project/color_field", "homepage": "https://www.drupal.org/project/color_field",
"support": { "support": {
"issues": "https://www.drupal.org/project/issues/color_field?version=8.x", "issues": "https://www.drupal.org/project/issues/color_field?version=8.x",
"source": "http://cgit.drupalcode.org/color_field" "source": "http://cgit.drupalcode.org/color_field"
} },
"minimum-stability": "dev",
"prefer-stable": true
} }
.color_field_widget_box__square { .color_field_widget_box__square {
border: 1px solid #000; border: 1px solid #000;
box-shadow: 0 0 1px #000; box-shadow: 0 0 1px #000;
box-sizing: border-box;
height: 16px; height: 16px;
margin: 2px; margin: 2px;
width: 16px; width: 16px;
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
background-repeat: no-repeat; background-repeat: no-repeat;
border: 1px solid #000; border: 1px solid #000;
box-shadow: 0 0 1px #000; box-shadow: 0 0 1px #000;
box-sizing: border-box;
height: 16px; height: 16px;
margin: 2px; margin: 2px;
width: 16px; width: 16px;
......
...@@ -94,13 +94,13 @@ class ColorCMY extends ColorBase { ...@@ -94,13 +94,13 @@ class ColorCMY extends ColorBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toHex() { public function toHex() {
return $this->toRGB()->toHex(); return $this->toRgb()->toHex();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toRGB() { public function toRgb() {
$red = (1 - $this->cyan) * 255; $red = (1 - $this->cyan) * 255;
$green = (1 - $this->magenta) * 255; $green = (1 - $this->magenta) * 255;
$blue = (1 - $this->yellow) * 255; $blue = (1 - $this->yellow) * 255;
...@@ -110,7 +110,7 @@ class ColorCMY extends ColorBase { ...@@ -110,7 +110,7 @@ class ColorCMY extends ColorBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toCMY() { public function toCmy() {
$cyan = ($this->cyan * (1 - $this->key) + $this->key); $cyan = ($this->cyan * (1 - $this->key) + $this->key);
$magenta = ($this->magenta * (1 - $this->key) + $this->key); $magenta = ($this->magenta * (1 - $this->key) + $this->key);
$yellow = ($this->yellow * (1 - $this->key) + $this->key); $yellow = ($this->yellow * (1 - $this->key) + $this->key);
......
...@@ -114,20 +114,20 @@ class ColorCMYK extends ColorBase { ...@@ -114,20 +114,20 @@ class ColorCMYK extends ColorBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toHex() { public function toHex() {
return $this->toRGB()->toHex(); return $this->toRgb()->toHex();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toRGB() { public function toRgb() {
return $this->toCMY()->toRGB(); return $this->toCmy()->toRgb();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toCMY() { public function toCmy() {
$cyan = ($this->cyan * (1 - $this->key) + $this->key); $cyan = ($this->cyan * (1 - $this->key) + $this->key);
$magenta = ($this->magenta * (1 - $this->key) + $this->key); $magenta = ($this->magenta * (1 - $this->key) + $this->key);
$yellow = ($this->yellow * (1 - $this->key) + $this->key); $yellow = ($this->yellow * (1 - $this->key) + $this->key);
......
...@@ -55,7 +55,7 @@ class ColorHex extends ColorBase { ...@@ -55,7 +55,7 @@ class ColorHex extends ColorBase {
* The color in format: #RRGGBB. * The color in format: #RRGGBB.
*/ */
public function toString($opacity = TRUE) { public function toString($opacity = TRUE) {
$rgb = $this->toRGB(); $rgb = $this->toRgb();
$hex = '#'; $hex = '#';
$hex .= str_pad(dechex($rgb->getRed()), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb->getRed()), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb->getGreen()), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb->getGreen()), 2, "0", STR_PAD_LEFT);
...@@ -76,7 +76,7 @@ class ColorHex extends ColorBase { ...@@ -76,7 +76,7 @@ class ColorHex extends ColorBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toRGB() { public function toRgb() {
$red = (($this->color & 0xFF0000) >> 16); $red = (($this->color & 0xFF0000) >> 16);
$green = (($this->color & 0x00FF00) >> 8); $green = (($this->color & 0x00FF00) >> 8);
$blue = (($this->color & 0x0000FF)); $blue = (($this->color & 0x0000FF));
......
...@@ -29,11 +29,11 @@ interface ColorInterface { ...@@ -29,11 +29,11 @@ interface ColorInterface {
* @return \Drupal\color_field\ColorRGB * @return \Drupal\color_field\ColorRGB
* The color as a RGB instance. * The color as a RGB instance.
*/ */
public function toRGB(); public function toRgb();
// Public function toHSV(); // Public function toHSV();
// public function toHSL(); // public function toHSL();
// public function toRGB(); // public function toRgb();
// public function toCMYK(); // public function toCMYK();
// public function toCSS(); // public function toCSS();
} }
...@@ -119,7 +119,7 @@ class ColorRGB extends ColorBase { ...@@ -119,7 +119,7 @@ class ColorRGB extends ColorBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function toRGB() { public function toRgb() {
return $this; return $this;
} }
......
...@@ -205,10 +205,10 @@ class ColorFieldFormatterCss extends FormatterBase implements ContainerFactoryPl ...@@ -205,10 +205,10 @@ class ColorFieldFormatterCss extends FormatterBase implements ContainerFactoryPl
$color_hex = new ColorHex($item->color, $item->opacity); $color_hex = new ColorHex($item->color, $item->opacity);
if ($opacity && $settings['opacity']) { if ($opacity && $settings['opacity']) {
$rgbtext = $color_hex->toRGB()->toString(TRUE); $rgbtext = $color_hex->toRgb()->toString(TRUE);
} }
else { else {
$rgbtext = $color_hex->toRGB()->toString(FALSE); $rgbtext = $color_hex->toRgb()->toString(FALSE);
} }
return $rgbtext; return $rgbtext;
......
...@@ -154,10 +154,10 @@ class ColorFieldFormatterSwatch extends FormatterBase { ...@@ -154,10 +154,10 @@ class ColorFieldFormatterSwatch extends FormatterBase {
$color_hex = new ColorHex($item->color, $item->opacity); $color_hex = new ColorHex($item->color, $item->opacity);
if ($opacity && $settings['opacity']) { if ($opacity && $settings['opacity']) {
$rgbtext = $color_hex->toRGB()->toString(TRUE); $rgbtext = $color_hex->toRgb()->toString(TRUE);
} }
else { else {
$rgbtext = $color_hex->toRGB()->toString(FALSE); $rgbtext = $color_hex->toRgb()->toString(FALSE);
} }
return $rgbtext; return $rgbtext;
......
...@@ -132,10 +132,10 @@ class ColorFieldFormatterText extends FormatterBase { ...@@ -132,10 +132,10 @@ class ColorFieldFormatterText extends FormatterBase {
case 'rgb': case 'rgb':
if ($opacity && $settings['opacity']) { if ($opacity && $settings['opacity']) {
$output = $color_hex->toRGB()->toString(TRUE); $output = $color_hex->toRgb()->toString(TRUE);
} }
else { else {
$output = $color_hex->toRGB()->toString(FALSE); $output = $color_hex->toRgb()->toString(FALSE);
} }
break; 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