Separate look & feel with logic using themes
Themes can include
Custom themes are placed under VAADIN/themes/ folder
(see another page)
Saas is an extension of CSS3
Skipped, unless I find CSS not enough
Custom themes placed in VAADIN/themes
Themes SCSS
1. recommend rules should be prefixed with a selector for the theme name, by using Saas mixins
@import "addons.scss"; @import "mytheme.scss"; .mytheme { @include addons; @include mytheme; }
2. (the above is for using UI in portlets, each can have own theme, otherwise) just include
@import "addons.scss"; @import "mytheme.scss"; @include addons; @include mytheme;
3. Actual theme should be defined as a mixin that includes the base theme
@import "../valo/valo.scss"; @mixin mytheme { @include valo; /* An actual theme rule */ .v-button { color: blue; } }
4. Add-on Themes
(skipped)
5. Plain old CSS Themes (skipped)
Each UI component has a CSS style class, and many have additional sub-elements that allow styling
addStyleName() - add
getStyleName() - only custom style names
do not use set to replace built-in style names
built-in style names are easiest find out by inspector (Firebug)
File->New->Other... Vaadin/Vaadin Theme
This wizard creates theme folder, actual sheet as "myname.scss" and the styles.scss files
Font Icon over bitmap
Loading Icon Fonts:
Basic use:
Style the icons:
.v-icon { color: blue; }
Use in HTML: Label l = new Label("I "+FontAwesome.HEART.getHtml()+" vaadin"....
Use in other text: just get the unicode with getCodePoint(), but need to set font family for the text (all of them)
.v-caption-awesomecaption .v-captiontext { font-family: FontAwesome; }
Skipped
Skipped
Skipped for now
1. Plan before coding UI (so at least know roughly the right place of components)
2. Name all things (layouts, panels, etc.)
- call addStyleName not "set"
- choose name like variable / class names: semantic, meaningful and independent of components
3. Never pass style names directly as string literals
- always as constants in a single theme class (so the class becomes an API)
4. come up with unique prefix for the app (like "v-" for vaadin)
5. give each unique component a unique ID with setId()
- !!!! developer's responsibility that ID is unique on-screen all the time
6. Keep it simple (use built-in whenever I can)
- custom components are harder to theme than built-in
7. Client-side code should include as little css as possible; all others go to theme
8. Keep complexity of UI code low (prefer shallow component tree)
9. Don't do it too early, stablize views first, focus on functionality first