浏览代码

Merge pull request #3470 from Automattic/fix/varia-color-utils

Varia: fix color utils, version up to 1.6.6.
Jeffrey Pearce 4 年之前
父节点
当前提交
e452798ebb
共有 5 个文件被更改,包括 16 次插入15 次删除
  1. 12 11
      varia/inc/color-utils.php
  2. 1 1
      varia/package.json
  3. 1 1
      varia/style-rtl.css
  4. 1 1
      varia/style.css
  5. 1 1
      varia/style.scss

+ 12 - 11
varia/inc/color-utils.php

@@ -28,19 +28,20 @@ if ( ! function_exists( 'rgb_to_hsvl' ) ) {
 		$min_rgb           = min( $r, $g, $b );
 		$chroma            = $max_rgb - $min_rgb;
 		$v                 = 100 * $max_rgb;
-		if ( 0 === $chroma ) {
+		if ( $chroma > 0 ) {
+			$s = 100 * ( $chroma / $max_rgb );
+			if ( $r === $min_rgb ) {
+				$h = 3 - ( ( $g - $b ) / $chroma );
+			} elseif ( $b === $min_rgb ) {
+				$h = 1 - ( ( $r - $g ) / $chroma );
+			} else { // $g === $min_rgb
+				$h = 5 - ( ( $b - $r ) / $chroma );
+			}
+			$h = 60 * $h;
+			return array( $h, $s, $v, $l );
+		} else {
 			return array( 0, 0, $v, $l );
 		}
-		$s = 100 * ( $chroma / $max_rgb );
-		if ( $r === $min_rgb ) {
-			$h = 3 - ( ( $g - $b ) / $chroma );
-		} elseif ( $b === $min_rgb ) {
-			$h = 1 - ( ( $r - $g ) / $chroma );
-		} else { // $g === $min_rgb
-			$h = 5 - ( ( $b - $r ) / $chroma );
-		}
-		$h = 60 * $h;
-		return array( $h, $s, $v, $l );
 	}
 }
 

+ 1 - 1
varia/package.json

@@ -1,6 +1,6 @@
 {
   "name": "varia",
-  "version": "1.6.5",
+  "version": "1.6.6",
   "description": "A variable-based design system for WordPress sites built with Gutenberg.",
   "bugs": {
     "url": "https://github.com/Automattic/themes/issues?q=is%3Aopen+is%3Aissue+label%3Avaria"

+ 1 - 1
varia/style-rtl.css

@@ -6,7 +6,7 @@ Author: Automattic
 Author URI: https://automattic.com/
 Description: A variable-based design system for WordPress sites built with Gutenberg.
 Requires at least: WordPress 4.9.6
-Version: 1.6.5
+Version: 1.6.6
 License: GNU General Public License v2 or later
 License URI: LICENSE
 Text Domain: varia

+ 1 - 1
varia/style.css

@@ -6,7 +6,7 @@ Author: Automattic
 Author URI: https://automattic.com/
 Description: A variable-based design system for WordPress sites built with Gutenberg.
 Requires at least: WordPress 4.9.6
-Version: 1.6.5
+Version: 1.6.6
 License: GNU General Public License v2 or later
 License URI: LICENSE
 Text Domain: varia

+ 1 - 1
varia/style.scss

@@ -5,7 +5,7 @@ Author: Automattic
 Author URI: https://automattic.com/
 Description: A variable-based design system for WordPress sites built with Gutenberg.
 Requires at least: WordPress 4.9.6
-Version: 1.6.5
+Version: 1.6.6
 License: GNU General Public License v2 or later
 License URI: LICENSE
 Text Domain: varia