-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Polished.net | ||
============ | ||
|
||
_A lightweight toolset for writing styles in C#_ | ||
|
||
Polished.net is a port of https://github.com/styled-components/polished (version 3.4.0) to C#. | ||
|
||
Docs | ||
==== | ||
|
||
There are no docs yet for this version but the polished js docs maybe helpful: https://polished.js.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Polished.Tests.Mixins | ||
{ | ||
[TestClass] | ||
public class Normalize | ||
{ | ||
private readonly IMixins _mixins = new Polished.Mixins(); | ||
|
||
[TestMethod] | ||
public void NormalizeCss() | ||
{ | ||
string actual = _mixins.Normalize(); | ||
string expected = @"html { line-height: 1.15; -webkit-text-size-adjust: 100%; } body { margin: 0; } main { display: block; } h1 { font-size: 2em; margin: 0.67em 0; } hr { box-sizing: content-box; height: 0; overflow: visible; } pre { font-family: monospace, monospace; font-size: 1em; } a { background-color: transparent; } abbr[title] { border-bottom: none; text-decoration: underline; text-decoration: underline dotted; } b, strong { font-weight: bolder; } code, kbd, samp { font-family: monospace, monospace; font-size: 1em; } small { font-size: 80%; } sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sub { bottom: -0.25em; } sup { top: -0.5em; } img { border-style: none; } button, input, optgroup, select, textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0; } button, input { overflow: visible; } button, select { text-transform: none; } button, [type=""button""], [type=""reset""], [type=""submit""] { -webkit-appearance: button; } button::-moz-focus-inner, [type=""button""]::-moz-focus-inner, [type=""reset""]::-moz-focus-inner, [type=""submit""]::-moz-focus-inner { border-style: none; padding: 0; } button:-moz-focusring, [type=""button""]:-moz-focusring, [type=""reset""]:-moz-focusring, [type=""submit""]:-moz-focusring { outline: 1px dotted ButtonText; } fieldset { padding: 0.35em 0.75em 0.625em; } legend { box-sizing: border-box; color: inherit; display: table; max-width: 100%; padding: 0; white-space: normal; } progress { vertical-align: baseline; } textarea { overflow: auto; } [type=""checkbox""], [type=""radio""] { box-sizing: border-box; padding: 0; } [type=""number""]::-webkit-inner-spin-button, [type=""number""]::-webkit-outer-spin-button { height: auto; } [type=""search""] { -webkit-appearance: textfield; outline-offset: -2px; } [type=""search""]::-webkit-search-decoration { -webkit-appearance: none; } ::-webkit-file-upload-button { -webkit-appearance: button; font: inherit; } details { display: block; } summary { display: list-item; } template { display: none; } [hidden] { display: none; } "; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Collections.Generic; | ||
|
||
namespace Polished.Tests.Mixins | ||
{ | ||
[TestClass] | ||
public class RadialGradient | ||
{ | ||
private readonly IMixins _mixins = new Polished.Mixins(); | ||
|
||
[TestMethod] | ||
public void TwoColorStops() | ||
{ | ||
string actual = _mixins.RadialGradient(new RadialGradientConfiguration { ColorStops = new List<string> { "#fff", "#000" } }); | ||
string expected = "background-color:#fff;background-image:radial-gradient(#fff, #000);"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void ExtentShapeAndPosition() | ||
{ | ||
string actual = _mixins.RadialGradient(new RadialGradientConfiguration | ||
{ | ||
ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, | ||
Extent = "farthest-corner at 45px 45px", | ||
Position = "center", | ||
Shape = "ellipse" | ||
}); | ||
string expected = "background-color:#00FFFF;background-image:radial-gradient(center ellipse farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void ExtentAndShape() | ||
{ | ||
string actual = _mixins.RadialGradient(new RadialGradientConfiguration | ||
{ | ||
ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, | ||
Extent = "farthest-corner at 45px 45px", | ||
Shape = "ellipse" | ||
}); | ||
string expected = "background-color:#00FFFF;background-image:radial-gradient(ellipse farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void Extent() | ||
{ | ||
string actual = _mixins.RadialGradient(new RadialGradientConfiguration | ||
{ | ||
ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, | ||
Extent = "farthest-corner at 45px 45px" | ||
}); | ||
string expected = "background-color:#00FFFF;background-image:radial-gradient(farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void ExtentAndFallback() | ||
{ | ||
string actual = _mixins.RadialGradient(new RadialGradientConfiguration | ||
{ | ||
ColorStops = new List<string> { "#00FFFF 0%", "rgba(0, 0, 255, 0) 50%", "#0000FF 95%" }, | ||
Extent = "farthest-corner at 45px 45px", | ||
Fallback = "#FFF" | ||
}); | ||
string expected = "background-color:#FFF;background-image:radial-gradient(farthest-corner at 45px 45px, #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #0000FF 95%);"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void ThrowsIfColorStopsAreNull() | ||
{ | ||
Assert.ThrowsException<PolishedException>( | ||
() => _mixins.RadialGradient(null, null, null, null, null) | ||
); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void ThrowsIfColorStopsAreLessThan2() | ||
{ | ||
Assert.ThrowsException<PolishedException>( | ||
() => _mixins.RadialGradient(new List<string> { "#fff" }, null, null, null, null) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Polished.Tests.Mixins | ||
{ | ||
[TestClass] | ||
public class RetinaImage | ||
{ | ||
private readonly IMixins _mixins = new Polished.Mixins(); | ||
|
||
[TestMethod] | ||
public void ShowThrowIfNoFilename() | ||
{ | ||
Assert.ThrowsException<PolishedException>( | ||
() => _mixins.RetinaImage(null, null) | ||
); | ||
} | ||
|
||
[TestMethod] | ||
public void Filename() | ||
{ | ||
string actual = _mixins.RetinaImage("img", null); | ||
string expected = "background-image:url(img.png);@media only screen and (-webkit-min-device-pixel-ratio: 1.3),only screen and (min--moz-device-pixel-ratio: 1.3),only screen and (-o-min-device-pixel-ratio: 1.3/1),only screen and (min-resolution: 125dpi),only screen and (min-resolution: 1.3dppx){background-image:url(img_2x.png);}"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void FilenameAndCover() | ||
{ | ||
string actual = _mixins.RetinaImage("img", "cover"); | ||
string expected = "background-image:url(img.png);@media only screen and (-webkit-min-device-pixel-ratio: 1.3),only screen and (min--moz-device-pixel-ratio: 1.3),only screen and (-o-min-device-pixel-ratio: 1.3/1),only screen and (min-resolution: 125dpi),only screen and (min-resolution: 1.3dppx){background-image:url(img_2x.png);background-size:cover;}"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void FilenameAndExtension() | ||
{ | ||
string actual = _mixins.RetinaImage("img", null, "jpg"); | ||
string expected = "background-image:url(img.jpg);@media only screen and (-webkit-min-device-pixel-ratio: 1.3),only screen and (min--moz-device-pixel-ratio: 1.3),only screen and (-o-min-device-pixel-ratio: 1.3/1),only screen and (min-resolution: 125dpi),only screen and (min-resolution: 1.3dppx){background-image:url(img_2x.jpg);}"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void FilenameAndRetinaFilename() | ||
{ | ||
string actual = _mixins.RetinaImage("img", null, null, "retina_img"); | ||
string expected = "background-image:url(img.png);@media only screen and (-webkit-min-device-pixel-ratio: 1.3),only screen and (min--moz-device-pixel-ratio: 1.3),only screen and (-o-min-device-pixel-ratio: 1.3/1),only screen and (min-resolution: 125dpi),only screen and (min-resolution: 1.3dppx){background-image:url(retina_img.png);}"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void FilenameAndSuffix() | ||
{ | ||
string actual = _mixins.RetinaImage("img", null, null, null, "_5x"); | ||
string expected = "background-image:url(img.png);@media only screen and (-webkit-min-device-pixel-ratio: 1.3),only screen and (min--moz-device-pixel-ratio: 1.3),only screen and (-o-min-device-pixel-ratio: 1.3/1),only screen and (min-resolution: 125dpi),only screen and (min-resolution: 1.3dppx){background-image:url(img_5x.png);}"; | ||
Assert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |
Oops, something went wrong.