Skip to content

Commit

Permalink
This is a bit of a punt, but i'm looking to see if hsl() in LESS fi…
Browse files Browse the repository at this point in the history
…les gets ignored if there isn't a function called `hsl()` in Functions.php. May need to revert this.
  • Loading branch information
Kier committed Feb 6, 2024
1 parent 0526825 commit 3c2c5d3
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 56 deletions.
5 changes: 4 additions & 1 deletion lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ public function rgba( $r = null, $g = null, $b = null, $a = null ) {
return new Less_Tree_Color( $rgb, $a );
}

public function hsl( $h, $s, $l ) {
public function hsl_less($h, $s, $l ) {
if ( $h === null || $s === null || $l === null ) {
throw new Less_Exception_Compiler( "hsl_less expects three parameters" );
}
return $this->hsla( $h, $s, $l, 1.0 );
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ private function parseEntitiesVariableCurly() {
*
* #4F3C2F
*
* `rgb` and `hsl` colors are parsed through the `entities.call` parser.
* `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
*
* @return Less_Tree_Color|null
*/
Expand Down
2 changes: 1 addition & 1 deletion test/Fixtures/bug-reports/less/210.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body {
color: argb(rgba(@r,@g,@b,@a));
}
.hsl {
color: hsl(@h,@s,@l);
color: hsl_less(@h,@s,@l);
}
.hsla {
color: hsla(@h,@s,@l,@a);
Expand Down
6 changes: 3 additions & 3 deletions test/Fixtures/lessjs (1.5)/less/colors.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
}

#808080 {
color: hsl(50, 0%, 50%);
color: hsl_less(50, 0%, 50%);
}

#00ff00 {
color: hsl(120, 100%, 50%);
color: hsl_less(120, 100%, 50%);
}

.lightenblue {
Expand Down Expand Up @@ -87,6 +87,6 @@
opacity: alpha(rgba(50, 120, 95, 0.2));
}
#hsl {
opacity: alpha(hsl(120, 100%, 50%));
opacity: alpha(hsl_less(120, 100%, 50%));
}
}
16 changes: 8 additions & 8 deletions test/Fixtures/lessjs (1.5)/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
hsl-clamp: hsl(380, 150%, 150%);
spin-p: spin(hsl(340, 50%, 50%), 40);
spin-n: spin(hsl(30, 50%, 50%), -40);
hsl-clamp: hsl_less(380, 150%, 150%);
spin-p: spin(hsl_less(340, 50%, 50%), 40);
spin-n: spin(hsl_less(30, 50%, 50%), -40);
luma-white: luma(#fff);
luma-black: luma(#000);
luma-black-alpha: luma(rgba(0,0,0,0.5));
Expand Down Expand Up @@ -54,13 +54,13 @@
format-multiple: %("hello %s %d", "earth", 2);
format-url-encode: %('red is %A', #ff0000);
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));

unitless: unit(12px);
unit: unit((13px + 1px), em);

hue: hue(hsl(98, 12%, 95%));
saturation: saturation(hsl(98, 12%, 95%));
lightness: lightness(hsl(98, 12%, 95%));
hue: hue(hsl_less(98, 12%, 95%));
saturation: saturation(hsl_less(98, 12%, 95%));
lightness: lightness(hsl_less(98, 12%, 95%));
hsvhue: hsvhue(hsv(98, 12%, 95%));
hsvsaturation: hsvsaturation(hsv(98, 12%, 95%));
hsvvalue: hsvvalue(hsv(98, 12%, 95%));
Expand Down Expand Up @@ -103,7 +103,7 @@

fade-out: fadeOut(red, 5%); // support fadeOut and fadeout
fade-in: fadein(fadeout(red, 10%), 5%);

hsv: hsv(5, 50%, 30%);
hsva: hsva(3, 50%, 30%, 0.2);

Expand Down
4 changes: 2 additions & 2 deletions test/Fixtures/lessjs (1.5)/less/operations.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

.with-functions {
color: (rgb(200, 200, 200) / 2);
color: (2 * hsl(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl(0, 50%, 50%));
color: (2 * hsl_less(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl_less(0, 50%, 50%));
}

@z: -2;
Expand Down
8 changes: 4 additions & 4 deletions test/Fixtures/lessjs (1.6)/less/colors.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.b { color: (#eee + #fff); } // #ffffff
.c { color: (#aaa * 3); } // #ffffff
.d { color: (#00ee00 + #009900); } // #00ff00
.e { color: rgba(-99.9, 31.4159, 321, 0.42); }
.e { color: rgba(-99.9, 31.4159, 321, 0.42); }
}

#grey {
Expand All @@ -49,11 +49,11 @@
}

#808080 {
color: hsl(50, 0%, 50%);
color: hsl_less(50, 0%, 50%);
}

#00ff00 {
color: hsl(120, 100%, 50%);
color: hsl_less(120, 100%, 50%);
}

.lightenblue {
Expand Down Expand Up @@ -88,7 +88,7 @@
opacity: alpha(rgba(50, 120, 95, 0.2));
}
#hsl {
opacity: alpha(hsl(120, 100%, 50%));
opacity: alpha(hsl_less(120, 100%, 50%));
}
}

Expand Down
16 changes: 8 additions & 8 deletions test/Fixtures/lessjs (1.6)/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
hsl-clamp: hsl(380, 150%, 150%);
spin-p: spin(hsl(340, 50%, 50%), 40);
spin-n: spin(hsl(30, 50%, 50%), -40);
hsl-clamp: hsl_less(380, 150%, 150%);
spin-p: spin(hsl_less(340, 50%, 50%), 40);
spin-n: spin(hsl_less(30, 50%, 50%), -40);
luma-white: luma(#fff);
luma-black: luma(#000);
luma-black-alpha: luma(rgba(0,0,0,0.5));
Expand Down Expand Up @@ -54,13 +54,13 @@
format-multiple: %("hello %s %d", "earth", 2);
format-url-encode: %('red is %A', #ff0000);
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));

unitless: unit(12px);
unit: unit((13px + 1px), em);

hue: hue(hsl(98, 12%, 95%));
saturation: saturation(hsl(98, 12%, 95%));
lightness: lightness(hsl(98, 12%, 95%));
hue: hue(hsl_less(98, 12%, 95%));
saturation: saturation(hsl_less(98, 12%, 95%));
lightness: lightness(hsl_less(98, 12%, 95%));
hsvhue: hsvhue(hsv(98, 12%, 95%));
hsvsaturation: hsvsaturation(hsv(98, 12%, 95%));
hsvvalue: hsvvalue(hsv(98, 12%, 95%));
Expand Down Expand Up @@ -105,7 +105,7 @@

fade-out: fadeOut(red, 5%); // support fadeOut and fadeout
fade-in: fadein(fadeout(red, 10%), 5%);

hsv: hsv(5, 50%, 30%);
hsva: hsva(3, 50%, 30%, 0.2);

Expand Down
4 changes: 2 additions & 2 deletions test/Fixtures/lessjs (1.6)/less/operations.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

.with-functions {
color: (rgb(200, 200, 200) / 2);
color: (2 * hsl(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl(0, 50%, 50%));
color: (2 * hsl_less(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl_less(0, 50%, 50%));
}

@z: -2;
Expand Down
8 changes: 4 additions & 4 deletions test/Fixtures/lessjs/less/colors.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.b { color: (#eee + #fff); } // #ffffff
.c { color: (#aaa * 3); } // #ffffff
.d { color: (#00ee00 + #009900); } // #00ff00
.e { color: rgba(-99.9, 31.4159, 321, 0.42); }
.e { color: rgba(-99.9, 31.4159, 321, 0.42); }
}

#grey {
Expand All @@ -49,11 +49,11 @@
}

#808080 {
color: hsl(50, 0%, 50%);
color: hsl_less(50, 0%, 50%);
}

#00ff00 {
color: hsl(120, 100%, 50%);
color: hsl_less(120, 100%, 50%);
}

.lightenblue {
Expand Down Expand Up @@ -88,7 +88,7 @@
opacity: alpha(rgba(50, 120, 95, 0.2));
}
#hsl {
opacity: alpha(hsl(120, 100%, 50%));
opacity: alpha(hsl_less(120, 100%, 50%));
}
}

Expand Down
18 changes: 9 additions & 9 deletions test/Fixtures/lessjs/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
saturate: saturate(#29332f, 20%);
desaturate: desaturate(#203c31, 20%);
greyscale: greyscale(#203c31);
hsl-clamp: hsl(380, 150%, 150%);
spin-p: spin(hsl(340, 50%, 50%), 40);
spin-n: spin(hsl(30, 50%, 50%), -40);
hsl-clamp: hsl_less(380, 150%, 150%);
spin-p: spin(hsl_less(340, 50%, 50%), 40);
spin-n: spin(hsl_less(30, 50%, 50%), -40);
luma-white: luma(#fff);
luma-black: luma(#000);
luma-black-alpha: luma(rgba(0,0,0,0.5));
Expand Down Expand Up @@ -67,17 +67,17 @@
format-single-quoted: %('hello %s', "single world");
format-escaped-string: %(~"hello %s", "escaped world");
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));

unitless: unit(12px);
unit: unit((13px + 1px), em);
unitpercentage: unit(100, %);

get-unit: get-unit(10px);
get-unit-empty: get-unit(10);

hue: hue(hsl(98, 12%, 95%));
saturation: saturation(hsl(98, 12%, 95%));
lightness: lightness(hsl(98, 12%, 95%));
hue: hue(hsl_less(98, 12%, 95%));
saturation: saturation(hsl_less(98, 12%, 95%));
lightness: lightness(hsl_less(98, 12%, 95%));
hsvhue: hsvhue(hsv(98, 12%, 95%));
hsvsaturation: hsvsaturation(hsv(98, 12%, 95%));
hsvvalue: hsvvalue(hsv(98, 12%, 95%));
Expand Down Expand Up @@ -123,7 +123,7 @@

fade-out: fadeOut(red, 5%); // support fadeOut and fadeout
fade-in: fadein(fadeout(red, 10%), 5%);

hsv: hsv(5, 50%, 30%);
hsva: hsva(3, 50%, 30%, 0.2);

Expand Down
4 changes: 2 additions & 2 deletions test/Fixtures/lessjs/less/operations.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

.with-functions {
color: (rgb(200, 200, 200) / 2);
color: (2 * hsl(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl(0, 50%, 50%));
color: (2 * hsl_less(0, 50%, 50%));
color: (rgb(10, 10, 10) + hsl_less(0, 50%, 50%));
}

@z: -2;
Expand Down
4 changes: 2 additions & 2 deletions test/assets/less-1.6.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ less.Parser = function Parser(env) {
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
// `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
//
color: function () {
var rgb;
Expand Down Expand Up @@ -7637,4 +7637,4 @@ if (typeof define === "function" && define.amd) {
define(function () { return less; } );
}

})(window);
})(window);
4 changes: 2 additions & 2 deletions test/assets/less-1.7.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ less.Parser = function Parser(env) {
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
// `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
//
color: function () {
var rgb;
Expand Down Expand Up @@ -7933,4 +7933,4 @@ if (typeof define === "function" && define.amd) {
define(function () { return less; } );
}

})(window);
})(window);
4 changes: 2 additions & 2 deletions test/assets/less-1.7.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ less.Parser = function Parser(env) {
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
// `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
//
color: function () {
var rgb;
Expand Down Expand Up @@ -7933,4 +7933,4 @@ if (typeof define === "function" && define.amd) {
define(function () { return less; } );
}

})(window);
})(window);
2 changes: 1 addition & 1 deletion test/assets/less-1.7.5.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ less.Parser = function Parser(env) {
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
// `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
//
color: function () {
var rgb;
Expand Down
8 changes: 4 additions & 4 deletions test/assets/less-2.5.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

/** * @license
/** * @license
*/

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.less = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
Expand Down Expand Up @@ -3482,7 +3482,7 @@ var Parser = function Parser(context, imports, fileInfo) {
//
// #4F3C2F
//
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
// `rgb` and `hsl_less` colors are parsed through the `entities.call` parser.
//
color: function () {
var rgb;
Expand Down Expand Up @@ -10090,13 +10090,13 @@ Promise.all = function (arr) {
}

Promise.reject = function (value) {
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
reject(value);
});
}

Promise.race = function (values) {
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
values.forEach(function(value){
Promise.resolve(value).then(resolve, reject);
})
Expand Down

0 comments on commit 3c2c5d3

Please sign in to comment.