Loading...
 
(Cached)

Enabling themes to provide values

For the purposes of styling details, the files themes/base_files/less/tiki-selectors.less and /tiki-variables.less are the gateway between the component files where the CSS selectors are described, and the themes. For a theme to style Tiki pages and features as completely as possible, it should import tiki-selectors.less and tiki-variables.less and be sure values are provided that are used in those files.

Tiki's base_files Less files are something like Bootstrap's component Less files in that they each address a Tiki feature or a page element, etc. In principle these don't contain variables that themes need to have access to. The idea is that they put together the foundation that themes build on, using global properties. CSS rules in these files that themes would benefit by having access to have been collected into the tiki-selectors.less file, and variables are used in this file, rather than hard-coded values, to enable themes to provide appropriate values such as for color.

A specific case

This also makes it possible for themes to provide values to override the CSS rules of external scripts. Here's an example. There can be conflicts between Tiki's native design details and those of external scripts like jQuery Chosen. We found Chosen dropdown selectors showed bad contrast (white text on a white background). While Tiki already has a tiki-external_scripts_overrides.less file to handle situations where the CSS of scripts needs to be modified to work within Tiki, this is compiled to be part of tiki_base.css, not the theme CSS files directly so it isn't so good for specifying colors or fonts, etc. Colors, for example, specified by tiki-external_scripts_overrides.less, which is compiled into tiki_base.css, will be used by all themes.

To prevent problems for themes, and allow them to directly provide a CSS rule for the external script override, a rule for the text color property of the Chosen selector dropdown items in tiki-external_scripts_overrides.less was created in tiki-selectors.less

Copy to clipboard
.tiki .chosen-container .active-result { color: @chosen-active-result; }


and a variable was added there for the color property. A default definition for this rule was added in the tiki-variables.less file

Copy to clipboard
@chosen-active-result: @input-color;


which is one of the standard Bootstrap variables, defined in the theme's bootstrap-variables.less (equivalent to the default Bootstrap variables.less file, defined something like this:

Copy to clipboard
//** Text color for `<input>`s @input-color: @gray-dark; // defined above in the file as @gray-dark: #444444; (in the case of the Amelia theme, for example


In this way any theme can define the text color of the Chosen selector dropdown items.

About external style sheets

The tiki_base.css file not only provides global CSS rules to be used by all Less-compiled themes, it also supports the use of external Bootstrap.css style sheets that have no awareness of Tiki's CSS requirements. The tiki_base.less file compiles the component Less partials and also imports the default Bootstrap variables.less file to provide default values for such rules as the fix for color contrast in Chosen selectors described above.


Page last modified on Sunday 17 of July, 2016 07:36:29 GMT-0000

Layout

Subscribe to Tiki Newsletters!

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other big news!
Contribute to Tiki

Site Config