Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Introduction

A SCSS module is provided for magnolia 5 as a community project on magnolia forge.
Since the Vaadin UI framework used by magnolia leverages SCSS and comes with a SCSS compiler, a simple module can expose this functionality for use by your themes.

SCSS, also known as SASS, is an extension to CSS. In a nutshell, SCSS extends CSS with many useful concepts such as nested rules or mixins and also lets you define variables and use simple programming constructs (like for loops) in your CSS stylesheets. A SCSS compiler turns your SCSS files into plain old CSS for shipping to the browser.

If you have large or complicated CSS files, or if it has ever bothered you that you have to define the same color values or font-families over and over again in the same CSS file, then SCSS might be for you.

More information on SCSS can be found at: http://sass-lang.com

Getting the module

Download JAR: from nexus.

Maven Dependency:

<dependency>
  <groupId>net.jaardvark</groupId>
  <artifactId>magnolia-module-resources-scss</artifactId>
  <version>1.0.0</version>
</dependency>

Getting the source:

 git clone http://git.magnolia-cms.com/forge/magnolia-module-resources-scss

Using SCSS in magnolia

After installing the SCSS module you will be able to create two new kinds of resources in the resources workspace:

  • SCSS - for plain SCSS stylesheets.
  • Processed SCSS - for SCSS stylesheets which additionally contain freemarker code.

Create resources of the appropriate type and fill them with your SCSS code.

When you request an SCSS resource, the SCSS compiler compiles your SCSS into CSS on the fly. It will process any imports, resolving them against magnolia's resources workspace. Errors will be reported to magnolia's log files on author and public instances and additionally as a comment in the CSS output on author instances.

When using "Processed SCSS" stylesheets, the freemarker processing happens before the SCSS processing.

Be aware that the SCSS resources are subject to the same caching (magnolia's cache, resources "far future" caching and browser cache) as other resources in magnolia, so make sure your caches are flushed if things aren't changing after you modify the resources.

Limitations

The SCSS module does not include an SCSS compiler. Instead, it uses the SCSS compiler provided by the Vaadin UI framework included with magnolia. Therefore the SCSS module is limited to supporting those aspects of SCSS supported by Vaadin's compiler. At the moment the support is rather poor - many things are not implemented. However, the most important and commonly used features of SCSS are working (mixins, nested rules, variables), so you can already benefit a lot from the current level of functionality. Also, the compiler may improve in the future, in which case magnolia's support for SCSS will improve with it.

License

Use at your own risk, your milage may vary.

Provided under a BSD License, with the express invitation to use, fork or otherwise change for your own purposes. Please consider contributing in the form of code, documentation, bug reports or feedback.

License
Copyright (c) 2014, Richard Unger
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: 

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies, 
either expressed or implied, of Magnolia Inc.

Technical Details

TODO

  • No labels