Exemple #1
0
        public void SingleDoubleNestedReference()
        {
            var css = StyleSheet.Parse(@"
#networkLinks .block {
  .edit {
    opacity: 0;
    
    &:before {
      font-family: 'carbon';
    }
  }
}".Trim());

            var node = (((css.Children[0] as StyleRule).Children[0] as StyleRule)).Children[1] as StyleRule;

            var selector = CssWriter.ExpandSelector(node);

            Assert.True(selector[0][0] is CssReference);
            Assert.True(selector[0][1] is CssString);

            // throw new System.Exception(string.Join(Environment.NewLine, selector[0].Select(a => a.Kind + " " + a.ToString())));

            Assert.Equal(@"
#networkLinks .block .edit:before { font-family: 'carbon'; }
#networkLinks .block .edit { opacity: 0; }
".Trim(), css.ToString());
        }
Exemple #2
0
        public void ChildSelector()
        {
            var ss = StyleSheet.Parse(@"div {
  input,
  textarea {
    display: block;
    font-size: 22px;
    line-height: 40px;
    color: #333;
    width: 100%;
    height: 60px;
    padding: 10px 15px;
    margin: 0;
    border: none;
    box-shadow: none;
    border-radius: 0px;
    border-radius: 2px 2px 0 0;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
  }
}");

            Assert.Single(ss.Children);

            var node   = (StyleRule)((StyleRule)ss.Children[0]).Children[0];
            var parent = (StyleRule)node.Parent;

            Assert.Equal("div", parent.Selector.ToString());
            Assert.Equal("input, textarea", node.Selector.ToString());
            var selector = CssWriter.ExpandSelector(node);

            Assert.Equal("div input, div textarea", selector.ToString());

            Assert.Equal(@"div input,
div textarea {
  display: block;
  font-size: 22px;
  line-height: 40px;
  color: #333;
  width: 100%;
  height: 60px;
  padding: 10px 15px;
  margin: 0;
  border: none;
  box-shadow: none;
  border-radius: 0px;
  border-radius: 2px 2px 0 0;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}", ss.ToString());
        }