Skip to content

Commit

Permalink
fix PropertySkip value missing px wrap (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoli799480165 authored Jul 10, 2024
1 parent 659699b commit af40f23
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Css/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal static string FormatValue<T>(string key, T value)
float v => Wrap(key, v, v != 0),
double v => Wrap(key, v, v != 0),
Keyframe v => v.ToString(),
PropertySkip v => v.GetValue(key),
_ => value?.ToString()
};
}
Expand Down
7 changes: 7 additions & 0 deletions src/Css/IProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ public interface IProperty
public struct PropertySkip
{
public bool SkipCheck { get; set; }

public Property<string, double> Value { get; set; }

public string GetValue(string key)
{
return Value.GetValue(key);
}

public override string ToString()
{
return Value.ToString();
Expand Down
21 changes: 20 additions & 1 deletion test/CssInCSharp.Tests/CSSObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,24 @@ public void Animation()
});
messageMoveIn.ToString().ShouldBe("MessageMoveIn;@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0;}100%{padding:100px;transform:translateY(0);opacity:1;}}");
}
}

[Fact]
public void Should_Property_Skip_Pxwrap()
{
new CSSObject()
{
[".test"] = new CSSObject()
{
Left = new PropertySkip()
{
SkipCheck = true,
Value = 12
}
}
}
.ToString()
.ShouldBe(".test{left:12px;}");
}

}
}

0 comments on commit af40f23

Please sign in to comment.