You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

themes-valo.asciidoc 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. ---
  2. title: Valo Theme
  3. order: 7
  4. layout: page
  5. ---
  6. [[themes.valo]]
  7. = Valo Theme
  8. Valo is the word for light in Finnish. The Valo theme incorporates the use of
  9. light in its logic, in how it handles shades and highlights. It creates lines,
  10. borders, highlights, and shadows adaptively according to a background color,
  11. always with contrasts pleasant to human visual perception. Auxiliary colors are
  12. computed using an algorithmic color theory to blend gently with the background.
  13. The static art is complemented with responsive animations.
  14. The true power of Valo lies in its configurability with parameters, functions,
  15. and Sass mixins. You can use the built-in definitions in your own themes or
  16. override the defaults. Detailed documentation of the available mixins,
  17. functions, and variables can be found in the Valo API documentation available at
  18. https://vaadin.com/api/valo/.
  19. [[themes.valo.use]]
  20. == Basic Use
  21. Valo is used just like other themes. Its optional parameters must be given
  22. before the [literal]#++@import++# statement.
  23. Your project theme file, such as [filename]#mytheme.scss#, included from the
  24. [filename]#styles.scss# file, could be as follows:
  25. ----
  26. // Modify the base color of the theme
  27. $v-background-color: hsl(200, 50%, 50%);
  28. // Import valo after setting the parameters
  29. @import "../valo/valo";
  30. .mythemename {
  31. @include valo;
  32. // Your theme's rules go here
  33. }
  34. ----
  35. If you need to override mixins or function definitions in the valo theme, you
  36. must do that after the import statement, but before including the valo mixin.
  37. Also, with some configuration parameters, you can use variables defined in the
  38. theme. In this case, they need to be overridden after the import statement.
  39. [[themes.valo.variables]]
  40. == Common Settings
  41. In the following, we describe the optional parameters that control the visual
  42. appearance of the Valo theme. In addition to the ones given here, component
  43. styles have their own parameters, listed in the sections describing the
  44. components in the other chapters.
  45. [[themes.valo.variables.general]]
  46. === General Settings
  47. $v-background-color(default:[literal]#++hsl(210, 0%, 98%)++#):: The background color is the main control parameter for the Valo theme and it is
  48. used for computing all other colors in the theme. If the color is dark (has low
  49. luminance), light foreground colors that give high contrast with the background
  50. are automatically used.
  51. +
  52. You can specify the color in any way allowed in CSS: hexadecimal RGB color code,
  53. RGB/A value specified with [methodname]#rgb()# or [methodname]#rgba()#, HSL/A
  54. value specified with [methodname]#hsl()# or [methodname]#hsla()#. You can also
  55. use color names, but it should be avoided, as not all CSS color names are
  56. currently supported.
  57. $v-app-background-color(default:$v-background-color):: Background color of the UI's root element. You can specify the color in any way
  58. allowed in CSS.
  59. $v-app-loading-text(default:[literal]#++""++#):: A static text that is shown under the loading spinned while the client-side
  60. engine is being loaded and started. The text must be given in quotes. The text
  61. can not be localized currently.
  62. +
  63. ----
  64. $v-app-loading-text: "Loading Resources...";
  65. ----
  66. $v-line-height(default:[literal]#++1.55++#):: Base line height for all widgets. It must be given a unitless number.
  67. +
  68. ----
  69. $v-line-height: 1.6;
  70. ----
  71. [[themes.valo.variables.fonts]]
  72. === Font Settings
  73. $v-font-size(default:[literal]#++16px++#):: Base font size. It should be specified in pixels.
  74. +
  75. ----
  76. $v-font-size: 18px;
  77. ----
  78. $v-font-weight(default:[literal]#++300++#):: Font weight for normal fonts. The size should be given as a numeric value, not
  79. symbolic.
  80. +
  81. ----
  82. $v-font-weight: 400;
  83. ----
  84. $v-font-color(default: computed):: Foreground text color, specified as any CSS color value. The default is computed
  85. from the background color so that it gives a high contrast with the background.
  86. $v-font-family(default:[literal]#++"Open Sans", sans-serif++#):: Font family and fallback fonts as a comma-separated list. Font names containing
  87. spaces must be quoted. The default font Open Sans is a web font included in the
  88. Valo theme. Other used Valo fonts must be specified in the list to enable them.
  89. See <<themes.valo.fonts>>.
  90. +
  91. ----
  92. $v-font-family: "Source Sans Pro", sans-serif;
  93. ----
  94. $v-caption-font-size(default:[literal]#++round($v-font-size * 0.9)++#):: Font size for component captions. The value should be a pixel value.
  95. $v-caption-font-weight(default:[literal]#++max(400, $v-font-weight)++#):: Font weight for captions. It should be defined with a numeric value instead of
  96. symbolic.
  97. [[themes.valo.variables.layout]]
  98. === Layout Settings
  99. ++++
  100. <variablelist xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xl="http://www.w3.org/1999/xlink"><varlistentry><term><varname>$v-unit-size</varname> (default: <literal>round(2.3 * $v-font-size)</literal>)</term><listitem><para>
  101. This is the base size for various layout measures. It is
  102. directly used in some measures, such as button height and
  103. layout margins, while other measures are derived from
  104. it. The value must be specified in pixels, with a suitable
  105. range of 18-50.
  106. </para><programlisting>$v-unit-size: 40px;</programlisting></listitem></varlistentry><varlistentry><term><varname>$v-layout-margin-top</varname></term><term><varname>$v-layout-margin-right</varname></term><term><varname>$v-layout-margin-bottom</varname></term><term><varname>$v-layout-margin-left</varname> (default: <literal>$v-unit-size</literal>)</term><listitem><para>
  107. Layout margin sizes for all built-in layout components,
  108. when the margin is enabled with
  109. <methodname>setMargin()</methodname>, as described in
  110. <xref linkend="layout.settings.margins"/>.
  111. </para></listitem></varlistentry><varlistentry><term><varname>$v-layout-spacing-vertical</varname> and
  112. <varname>$v-layout-spacing-horizontal</varname> (default:
  113. <literal>round($v-unit-size/3)</literal>)</term><listitem><para>
  114. Amount of vertical or horizontal space when spacing is enabled
  115. for a layout with <methodname>setSpacing()</methodname>, as
  116. described in <xref linkend="layout.settings.spacing"/>.
  117. </para></listitem></varlistentry></variablelist>
  118. ++++
  119. [[themes.valo.variables.component]]
  120. === Component Features
  121. The following settings apply to various graphical features of some components.
  122. $v-border(default:[literal]#++1px solid (v-shade 0.7)++#):: Border specification for the components that have a border. The thickness
  123. measure must be specified in pixels. For the border color, you can specify any
  124. CSS color or one of the [literal]#++v-tint++#, [literal]#++v-shade++#, and
  125. [literal]#++v-tone++# keywords described later in this section.
  126. $v-border-radius(default:[literal]#++4px++#):: Corner radius for components that have a border. The measure must be specified
  127. in pixels.
  128. +
  129. ----
  130. $v-border-radius: 8px;
  131. ----
  132. $v-gradient(default:[literal]#++v-linear 8%++#):: Color gradient style for components that have a gradient. The gradient style may
  133. use the following keywords: [literal]#++v-linear++# and
  134. [literal]#++v-linear-reverse++#. The opacity must be given as percentage between
  135. 0% and 100%.
  136. +
  137. ----
  138. $v-gradient: v-linear 20%;
  139. ----
  140. $v-bevel(default:[literal]#++inset 0 1px 0 v-tint, inset 0 -1px 0 v-shade++#):: Inset shadow style to define how some components are "raised" from the
  141. background. The value follows the syntax of CSS box-shadow, and should be a list
  142. of insets. For the bevel color, you can specify any CSS color or one of the
  143. [literal]#++v-tint++#, [literal]#++v-shade++#, and [literal]#++v-tone++#
  144. keywords described later in this section.
  145. +
  146. //TODO Check the meaning of v-tone
  147. $v-bevel-depth(default:[literal]#++30%++#):: Specifies the "depth" of the bevel shadow, as applied to one of the color
  148. keywords for the bevel style. The actual amount of tint, shade, or tone is
  149. computed from the depth.
  150. $v-shadow(default:[literal]#++0 2px 3px v-shade++#):: Default shadow style for all components. As with $v-bevel, the value follows the
  151. syntax of CSS box-shadow, but without the [literal]#++inset++#. For the shadow
  152. color, you can specify any CSS color or one of the [literal]#++v-tint++# or
  153. [literal]#++v-shade++# keywords described later in this section.
  154. $v-shadow-opacity(default:[literal]#++5%++#):: Specifies the opacity of the shadow, as applied to one of the color keywords for
  155. the shadow style. The actual amount of tint or shade is computed from the depth.
  156. $v-focus-style(default:[literal]#++0 0 0 2px rgba($v-focus-color, .5)++#):: Box-shadow specification for the field focus indicator. The space-separated
  157. values are the horizontal shadow position in pixels, vertical shadow position in
  158. pixels, blur distance in pixels, spread distance in pixels, and the color. The
  159. color can be any CSS color. You can only specify the color, in which case
  160. defaults for the position are used. [methodname]#rgba()# or [methodname]#hsla()#
  161. can be used to enable transparency.
  162. +
  163. For example, the following creates a 2 pixels wide orange outline around the
  164. field:
  165. +
  166. ----
  167. $v-focus-style: 0 0 0 2px orange;
  168. ----
  169. $v-focus-color(default:[literal]#++valo-focus-color()++#):: Color for the field focus indicator. The [methodname]#valo-focus-color()#
  170. function computes a high-contrast color from the context, which is usually the
  171. background color. The color can be any CSS color.
  172. $v-animations-enabled(default:[literal]#++true++#):: Specifies whether various CSS animations are used.
  173. $v-hover-styles-enabled(default:[literal]#++true++#):: Specifies whether various [literal]#++:hover++# styles are used for indicating
  174. that mouse pointer hovers over an element.
  175. $v-disabled-opacity(default:[literal]#++0.5++#):: Opacity of disabled components, as described in
  176. <<../components/components-features#components.features.enabled,"Enabled">>.
  177. $v-selection-color(default:[literal]#++$v-focus-color++#):: Color for indicating selection in selection components.
  178. $v-default-field-width(default:[literal]#++$v-unit-size * 5++#):: Default width of certain field components, unless overridden with
  179. [methodname]#setWidth()#.
  180. $v-error-indicator-color(default:[literal]#++#ed473b++#):: Color of the component error indicator, as described in
  181. <<../application/application-errors#application.errors.error-indicator,"Error
  182. Indicator and Message">>.
  183. $v-required-field-indicator-color(default:[literal]#++$v-error-indicator-color++#):: Color of the required indicator in field components.
  184. ifdef::vaadin7[]
  185. Field components are described in <<../components/components-fields#components.fields.field,"Field Interface">>.
  186. endif::vaadin7[]
  187. Color specifications for $v-border, $v-bevel, and $v-shadow may use, in addition
  188. to CSS colors, the following keywords:
  189. v-tint:: Lighter than the background color.
  190. v-shade:: Darker than the background color.
  191. v-tone:: Adaptive color specification: darker on light background and lighter on dark
  192. background. Not usable in $v-shadow.
  193. For example:
  194. ----
  195. $v-border: 1px solid v-shade;
  196. ----
  197. You can fine-tune the contrast by giving a weight parameter in parentheses:
  198. ----
  199. $v-border: 1px solid (v-tint 2);
  200. ----
  201. ----
  202. $v-border: 1px solid (v-tone 0.5);
  203. ----
  204. [[themes.valo.variables.optimization]]
  205. === Theme Compilation and Optimization
  206. $v-relative-paths(default:[literal]#++true++#):: This flags specifies whether relative URL paths are relative to the currently
  207. parsed SCSS file or to the compilation root file, so that paths are correct for
  208. different resources. Vaadin theme compiler parses URL paths differently from the
  209. regular Sass compiler (Vaadin modifies relative URL paths). Use
  210. [literal]#++false++# for Ruby compiler and [literal]#++true++# for Vaadin Sass
  211. compiler.
  212. $v-included-components(default: component list):: Theme optimization parameter to specify the included component themes, as
  213. described in <<themes.valo.optimization>>.
  214. $v-included-additional-styles(default:[literal]#++$v-included-components++#):: Theme optimization parameter that lists the components for which the additional
  215. component stylenames should be included. See <<themes.valo.component>> for more
  216. details.
  217. [[themes.valo.mixins]]
  218. == Valo Mixins and Functions
  219. Valo uses Sass mixins and functions heavily to compute various theme features,
  220. such as colors and shades. Also, all component styles are mixins. You can use
  221. the built-in mixins or override them. For detailed documentation of the mixins
  222. and functions, please refer to the Valo API documentation available at
  223. http://vaadin.com/valo/api.
  224. [[themes.valo.fonts]]
  225. == Valo Fonts
  226. Valo includes the following custom fonts:
  227. * Open Sans
  228. * Source Sans Pro
  229. * Roboto
  230. * Lato
  231. * Lora
  232. The used fonts must be specified with the $v-font-family parameter for Valo, in
  233. a fallback order. A font family is used in decreasing order of preference, in
  234. case a font with higher preference is not available in the browser. You can
  235. specify any font families and generic families that browsers may support. In
  236. addition to the primary font family, you can use also others in your
  237. application. To enable using the fonts included in Valo, you need to list them
  238. in the variable.
  239. ----
  240. $v-font-family: 'Open Sans', sans-serif, 'Source Sans Pro';
  241. ----
  242. Above, we specify Open Sans as the preferred primary font, with any sans-serif
  243. font that the browser supports as a fallback. In addition, we include the Source
  244. Sans Pro as an auxiliary font that we can use in custom rules as follows:
  245. ----
  246. .v-label pre {
  247. font-family: 'Source Sans Pro', monospace;
  248. }
  249. ----
  250. This would specify using the font in any [classname]#Label# component with the
  251. [literal]#++PREFORMATTED++# content mode.
  252. [[themes.valo.component]]
  253. == Component Styles
  254. Many components have component-specific styles to make them smaller, bigger, and
  255. so forth. You can specify the component styles with [methodname]#addStyleName()#
  256. using the constants defined in the [classname]#ValoTheme# enum.
  257. ----
  258. table.addStyleName(ValoTheme.TABLE_COMPACT);
  259. ----
  260. For a complete up-to-date list of component-specific styles, please refer to
  261. Vaadin API documentation on the [classname]#ValoTheme# enum. Some are also
  262. described in the component-specific styling sections.
  263. [[themes.valo.component.disabling]]
  264. === Disabling Component Styles
  265. Component styles are optional, but all are enabled by default. They can be
  266. enabled on per-component basis with the $v-included-additional-styles parameter.
  267. It defaults to $v-included-components and can be customized in the same way, as
  268. described in <<themes.valo.optimization>>.
  269. [[themes.valo.component.parameters]]
  270. === Configuration Parameters
  271. The following variables control some common component styles:
  272. $v-scaling-factor--tiny(default:[literal]#++0.75++#):: A scaling multiplier for [literal]#++TINY++# component styles.
  273. $v-scaling-factor--small(default:[literal]#++0.85++#):: A scaling multiplier for [literal]#++SMALL++# component styles.
  274. $v-scaling-factor--large(default:[literal]#++1.2++#):: A scaling multiplier for [literal]#++LARGE++# component styles.
  275. $v-scaling-factor--huge(default:[literal]#++1.6++#):: A scaling multiplier for [literal]#++HUGE++# component styles.
  276. [[themes.valo.optimization]]
  277. == Theme Optimization
  278. Valo theme allows optimizing the size of the compiled theme CSS by including the
  279. rules for only the components actually used in the application. The included
  280. component styles can be specified in the [literal]#++$v-included-components++#
  281. variable, which by default includes all components. The variable should include
  282. a comma-separated list of component names in lower-case letters. Likewise, you
  283. can specify which additional component styles, as described in
  284. <<themes.valo.component>>, should be included using the
  285. $v-included-additional-styles parameter and the same format. The list of
  286. additional styles defaults to $v-included-components.
  287. For example, if your UI contains just [classname]#VerticalLayout#,
  288. [classname]#TextField#, and [classname]#Button# components, you could define the
  289. variable as follows:
  290. ----
  291. $v-included-components:
  292. verticallayout,
  293. textfield,
  294. button;
  295. ----
  296. You can use the [methodname]#remove()# function reversely to remove just some
  297. component themes from the standard selection.
  298. For example, with the following you can remove the theme definitions for the
  299. [classname]#Calendar# component:
  300. ----
  301. $v-included-components: remove($v-included-components, calendar);
  302. ----
  303. Note that in this case, you need to give the statement __after__ the
  304. [literal]#++@import++# statement for the Valo theme, because it overrides a
  305. variable by using its value that is defined in the theme.