SmoothFriction.nl

posts - 39, comments - 20, trackbacks - 0

Sunday, October 18, 2009

Introducing .less, goodbye to Less.NET

As some of you might know, I’ve been diligently working on the C# port for the 'funky' ruby gem, {Less}. Well, we merged the nLess and Less.NET groups, creating .Less, and we’re live! We support the main {Less} specs, up to version 1.2.0 if I am correct. Here’s a quick synopsis, taken from our main site:

Variables

Variables allow you to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code.

 
@brand_color: #4D926F;
 
#header {
  color: @brand_color;
}
 
h2 {
  color: @brand_color;
}
Operations

Are some elements in your style sheet proportional to other elements? Operations let you add, subtract, divide and multiply property values and colors, giving you the power to do create complex relationships between properties.

 
@the-border: 1px;
@base-color: #111;
 
#header {
  color: @base-color * 3;
  border-left: @the-border;
  border-right: @the-border * 2;
}
 
#footer { 
  color: (@base-color + #111) * 1.5; 
}
Mixins

Mixins allow you to embed all the properties of a class into another class by simply including the class name as one of its properties. It's just like variables, but for whole classes.

 
.rounded_corners {
  -moz-border-radius: 8px;
  -webkit-border-radius: 8px;
  border-radius: 8px;
}
 
#header {
  .rounded_corners;
}
 
#footer {
  .rounded_corners;
}
Nested Rules

Rather than constructing long selector names to specify inheritance, in Less you can simply nest selectors inside other selectors. This makes inheritance clear and style sheets shorter.

 
#header {
  color: red;
  a { 
       font-weight: bold; 
       text-decoration: none; 
    } 
}

We’re currently in the process of tidying up the codebase, and we’re looking into which features we really want to include for the v1.0 release candidate. There’s a few options we consider, but please, if you have suggestions, drop them on our uservoice!

posted @ Sunday, October 18, 2009 12:54 AM | Feedback (0) |