Wednesday, January 18, 2012

Liferay 6.1 and SASS

Lieray 6.1 CE is released and many of you have started using it. There are lots of features in Liferay 6.1 and one among them is the facility to use SASS in Liferay.

SASS:

SASS( http://sass-lang.com ) stands for Syntactically Awesome StyleSheets. It is a tool that allows you to write CSS more easily It is an extension of CSS3 which means whatever CSS file is a valid SassyCSS (SCSS). It allows you to use variables, nested rules, mixins, inline imports, interpolation, arguments, manipulating colors and more with a fully CSS-compatible syntax. Sass generates well formatted CSS and it is much easier to organize and maintain your stylesheets.

Compass :

Compass( http://compass-style.org ) is an open-source CSS authoring framework which makes easier to build and maintain your markup and stylesheets. By using compass, you can write your own stylesheet in Sass instead of CSS.

How does Compass Work?

It can be imported using @import "compass" in CSS. SCSS is built based on the CSS3 specification which means that it is highly compatible with CSS3. SCSS also has all the power of Sass.

We’ll see here as how to use the variables, nested rules, mixins, inline imports, interpolation and arguments through CSS files.

Variables:

We’ll see how to use variables and a custom mixin to show how Compass makes it easy to reuse colors, sizes, and other values without repeating.

/* Variable Declaration */

/*These variables can be used globally throughout your stylesheets */ 

 

Example:

Liferay6.1     Liferay 6.0.x

Mixins:

By using the mixin, you can re-use the styles, properties & selectors without copying to other selectors. To achieve this , you need to package the properties with @mixin and to include it in other element with @include. 

Example:

Liferay 6.1   Liferay 6.0.x

Nested Rules:

Nesting avoids repeating CSS selectors and also keeps the style compact for a certain area of the User Interface. 

Let us have a look at an example of custom.css code for navigation part in themes. After using the nesting rule, the code should look like this :

Liferay 6.1     Liferay 6.0.x

Parent Reference:

Parent reference allows you to reference a parent selector  in the case of pseudo-classes like :hover, :link, :visited and :active states.

Liferay 6.1 Liferay 6.0.x

Interpolation:

We can also use SassScript variables in selectors and property names using #{} interpolation. Here’s the example:

Liferay 6.1 Liferay 6.0.x

Liferay6.1 allows you to use Sass which helps the code be simpler for mobile site design. (Thanks to BradleyWood’s solution in this  forum post ). 

As said in Sass , it makes CSS fun again and with Liferay 6.1, you can easily create manageable style sheets and start updating to Liferay 6.1 and use Sass to manage your style sheets  smiley .

 

16 comments:

  1. This text is priceless. How can I find out more?


    Here is my web pageon survey bypass

    ReplyDelete
  2. I'm truly enjoying the design and layout of your website.
    It's a very easy on the eyes which makes it much more enjoyable for
    me to come here and visit more often. Did you hire out a designer to create your
    theme? Outstanding work!

    Here is my web page :: After Effects Tutorial

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi Himanshu.

    I am searching the best way to compile css by sass in a maven liferay theme.
    Any advice?
    This article seems interesting but the page doesn´t load the images.

    Could yo fix fix it?
    Thanks anyway.

    ReplyDelete
  5. your blog information's are really creative and It contains full of new innovative ideas.thank you for sharing with us.please update more data.
    devops Course in Anna Nagar
    Best devops Training Institute in Anna nagar
    devops Certification Training in Anna nagar
    devops Training in Ambattur

    ReplyDelete
  6. Thank you for writing this informative post. Looking forward to read more.
    Responsive Website Design Services India

    ReplyDelete
  7. very very informative post for me thanks for sharing

    Blockchain Course in Bangalore

    ReplyDelete
  8. aaj mein aap ko time badhane wale condom ke baare mein btaunga vo condom jine condom ko use karne se aap long time tak sex kare skte hain bana kise medication ko kaha kare aur aap safe sex bhi kare skte hain aise karne se aap ko koi sexual disease bhi nhi hogi

    ReplyDelete