Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from carolinan/trunk
Browse files Browse the repository at this point in the history
sync with trunk
  • Loading branch information
carolinan authored Sep 18, 2020
2 parents 3008aca + c84f518 commit 0028d80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions assets/js/customize-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* Get luminance from a HEX color.
*
*
* @param {string} hex - The hex color.
*
*
* @return {number}
*/
function twentytwentyoneGetHexLum( hex ) {
Expand All @@ -14,9 +14,9 @@

/**
* Get RGB from HEX.
*
*
* @param {string} hex - The hex color.
*
*
* @return {Object} - Returns an object {r, g, b}
*/
function twentytwentyoneGetRgbFromHex( hex ) {
Expand All @@ -40,7 +40,7 @@
api( 'background_color', function( value ) {
value.bind( function( to ) {
var lum = twentytwentyoneGetHexLum( to ),
textColor = 127 < lum ? '#222' : '#fff';
textColor = 127 < lum ? '#000' : '#fff';

document.documentElement.style.setProperty( '--global--color-primary', textColor );
document.documentElement.style.setProperty( '--global--color-secondary', textColor );
Expand Down
4 changes: 2 additions & 2 deletions classes/class-twenty-twenty-one-custom-colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct() {
}

/**
* Determine the luminance of the given color and then return #FFFFFF or #222222 so that our text is always readable.
* Determine the luminance of the given color and then return #fff or #000 so that our text is always readable.
*
* @access public
*
Expand All @@ -40,7 +40,7 @@ public function __construct() {
* @return string (hex color)
*/
public function custom_get_readable_color( $background_color ) {
return ( 127 < $this->get_relative_luminance_from_hex( $background_color ) ) ? '#222222' : '#FFFFFF';
return ( 127 < $this->get_relative_luminance_from_hex( $background_color ) ) ? '#000' : '#fff';
}

/**
Expand Down

0 comments on commit 0028d80

Please sign in to comment.