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

Commit

Permalink
Fix adjust-color handling of transparent values vaadin#319
Browse files Browse the repository at this point in the history
* Consider the alpha channel if transparent is given as input (was previously ignored, and would return 'black')
* Return literal 'transparent' untouched if it was given as input, without parameters
  • Loading branch information
mkgl committed Aug 28, 2018
1 parent fafa1b6 commit 7a1cfe0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ protected SassListItem computeForArgumentList(LexicalUnitImpl function,
checkParams(function, actualArguments);
LexicalUnitImpl color = getColor(function, actualArguments);
float alpha = 1;
if (ColorUtil.isRgba(color) || ColorUtil.isHsla(color)) {
if (ColorUtil.isTransparent(color)) {
alpha = 0f;
} else if (ColorUtil.isRgba(color) || ColorUtil.isHsla(color)) {
int lastIndex = color.getParameterList().size() - 1;
alpha = color.getParameterList().get(lastIndex).getContainedValue()
.getFloatValue();
}
Float[] adjustBy = getAdjustments(function, actualArguments);
if (!anySet(adjustBy, 0, 7) && ColorUtil.isTransparent(color)) {
return LexicalUnitImpl.createIdent(ColorUtil.transparent);
}
if (adjustBy[6] != null) {
if ("adjust-color".equals(functionName)) {
alpha += adjustBy[6];
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/vaadin/sass/internal/util/ColorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ColorUtil {
.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})");
private static Map<String, String> colorNameToHex = new HashMap<String, String>();
private static Map<String, String> hexToColorName = new HashMap<String, String>();
private static String transparent = "transparent";
public static String transparent = "transparent";

static {
colorNameToHex.put("aqua", "#00ffff");
Expand Down

0 comments on commit 7a1cfe0

Please sign in to comment.