Skip to content

Commit

Permalink
Improve support for transparent.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Feb 10, 2019
1 parent 959249e commit 3b97ecd
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/value/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ impl Rgba {
}
}
pub fn from_name(name: &str) -> Option<Self> {
if name == "transparent" {
return Some(Self::from_rgba(0, 0, 0, 0));
}
LOOKUP.n2v.get(name).map(|n| {
// Note: nicer but not yet supported code:
// let [_, r, g, b] = n.to_be().to_bytes()
Expand Down Expand Up @@ -231,7 +234,7 @@ impl Display for Rgba {
} else {
write!(out, "#{:02x}{:02x}{:02x}", r, g, b)
}
} else if self.all_zero() {
} else if out.alternate() && self.all_zero() {
write!(out, "transparent")
} else if out.alternate() {
// I think the last {} should be {:#} here,
Expand Down
1 change: 0 additions & 1 deletion tests/core_functions/color/hsla/four_args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rsass::set_precision;

/// From "sass-spec/spec/core_functions/color/hsla/four_args/alpha_unitless"
#[test]
#[ignore] // failing
fn alpha_unitless() {
assert_eq!(
rsass(
Expand Down
2 changes: 0 additions & 2 deletions tests/core_functions/color/rgba/four_args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rsass::set_precision;

/// From "sass-spec/spec/core_functions/color/rgba/four_args/alpha_unitless"
#[test]
#[ignore] // failing
fn alpha_unitless() {
assert_eq!(
rsass(
Expand All @@ -21,7 +20,6 @@ fn alpha_unitless() {

/// From "sass-spec/spec/core_functions/color/rgba/four_args/basic"
#[test]
#[ignore] // failing
fn basic() {
assert_eq!(
rsass(
Expand Down
1 change: 0 additions & 1 deletion tests/core_functions/color/rgba/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mod three_args;

/// From "sass-spec/spec/core_functions/color/rgba/two_args"
#[test]
#[ignore] // failing
fn two_args() {
assert_eq!(
rsass(
Expand Down
2 changes: 0 additions & 2 deletions tests/libsass/color_functions/opacity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ fn fade_in() {

/// From "sass-spec/spec/libsass/color-functions/opacity/fade-out"
#[test]
#[ignore] // failing
fn fade_out() {
assert_eq!(
rsass(
Expand Down Expand Up @@ -61,7 +60,6 @@ fn opacity() {

/// From "sass-spec/spec/libsass/color-functions/opacity/transparentize"
#[test]
#[ignore] // failing
fn transparentize() {
assert_eq!(
rsass(
Expand Down
1 change: 0 additions & 1 deletion tests/libsass/color_functions/other/change_color/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rsass::set_precision;

/// From "sass-spec/spec/libsass/color-functions/other/change-color/a"
#[test]
#[ignore] // failing
fn a() {
assert_eq!(
rsass(
Expand Down
1 change: 0 additions & 1 deletion tests/libsass/color_functions/rgb/rgba/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rsass::set_precision;

/// From "sass-spec/spec/libsass/color-functions/rgb/rgba/a"
#[test]
#[ignore] // failing
fn a() {
assert_eq!(
rsass(
Expand Down

0 comments on commit 3b97ecd

Please sign in to comment.