DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Java
  4. Vaadin 7 Eases Your Theme Development

Vaadin 7 Eases Your Theme Development

Nicolas Fränkel user avatar by
Nicolas Fränkel
CORE ·
Sep. 24, 12 · Interview
Like (0)
Save
Tweet
Share
9.44K Views

Join the DZone community and get the full member experience.

Join For Free

Vaadin theming is a nice way to reuse your Cascading Style Sheets across different projects. Vaadin 7 adds even more sugar to the whole theming thing since it allows you to use Syntactically Awesome Stylesheets.

The purpose of this article is not to describe technology since it's already well documented on the SASS website but to expose how to use SASS within Vaadin.

In order to use the SASS technology, a few steps are necessary:

  • First, the UI base class has to be annotated with the @Theme annotation referencing our own new theme.
    @Theme("custom")
    public class SassUI extends UI {
        ...
    }
  • Remember to set this UI as the Vaadin servlet parameter in the web deployment descriptor:
    <servlet>
        <servlet-name>VaadinServlet</servlet-name>
        <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
        <init-param>
            <param-name>UI</param-name>
            <param-value>com.morevaadin.vaadin7.sass.SassUI</param-value>
        </init-param>
    </servlet>
  • Finally, instead of a CSS file, provide a styles.scss file under /VAADIN/themes/<name> (in your case, the name is "custom"). The code below is just an example:
    @import "../reindeer/styles.css";
     
    $color: rgb(51,204,255);
    $dark-color: darken($color, 20%);
    $spacing: 4px;
     
    .v-button-caption {
        color: $color;
    }
     
    @mixin border-radius($radius) {
        -webkit-border-radius: $radius;
        -moz-border-radius: $radius;
        border-radius: $radius;
    }
     
    .rounded-borders {
        @include border-radius(4px);
        border: 1px solid $color;
    }
     
    .v-label {
        color: $dark-color;
        padding-left: $spacing;
        margin-top: $spacing;
        margin-bottom: $spacing;
        font-weight: bold;
    }
That's it. Empowering your themes with SASS technology is as simple as that! Sources for this article can be found on GitHub.

Note that some SASS features are still missing at the time of this writing.

From http://morevaadin.com/content/vaadin-7-eases-your-theme-development

Vaadin

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top Five Tools for AI-based Test Automation
  • Visual Network Mapping Your K8s Clusters To Assess Performance
  • A Real-Time Supply Chain Control Tower Powered by Kafka
  • Why Does DevOps Recommend Shift-Left Testing Principles?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: