Skip to content

Commit

Permalink
Allow hsl() and rgb() to spit out the raw incoming CSS if LESS doesn'…
Browse files Browse the repository at this point in the history
…t get the expected inputs
  • Loading branch information
Kier committed Feb 7, 2024
1 parent 14e4fe1 commit 8744973
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,21 @@ public static function scaled( $n, $size = 255 ) {
}

public function rgb( $r = null, $g = null, $b = null ) {
if ( $r === null || $g === null || $b === null ) {
throw new Less_Exception_Compiler( "rgb expects three parameters" );
$components = func_get_args();

if (count( $components ) != 3)
{
return null;
}

foreach ( $components AS $component )
{
if ( !$component instanceof Less_Tree_Dimension )
{
return null;
}
}

return $this->rgba( $r, $g, $b, 1.0 );
}

Expand All @@ -81,28 +93,23 @@ public function rgba( $r = null, $g = null, $b = null, $a = null ) {
return new Less_Tree_Color( $rgb, $a );
}

public function hsl( $h, $s, $l ) {
if (self::isLessHsl( $h, $s, $l )) {
return $this->hsla( $h, $s, $l, 1.0 );
}

return 'hsl(' . $h . ')';
}
public function hsl( $h, $s = null, $l = null ) {
$components = func_get_args();

protected function isLessHsl( $h, $s, $l ) {
$hsl = func_get_args();

if (count( $hsl ) != 3) {
return false;
if (count( $components ) != 3)
{
return null;
}

foreach ( $hsl AS $arg ) {
if ( !$arg instanceof Less_Tree_Dimension ) {
return false;
foreach ( $components AS $component )
{
if ( !$component instanceof Less_Tree_Dimension )
{
return null;
}
}

return true;
return $this->hsla( $h, $s, $l, 1.0 );
}

public function hsla( $h, $s, $l, $a ) {
Expand Down

0 comments on commit 8744973

Please sign in to comment.