Loading...
 
Skip to main content

History: Enabling themes to provide values

Source of version: 2 (current)

Copy to clipboard
            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 

{CODE()}
.tiki .chosen-container .active-result { color: @chosen-active-result; }
{CODE}

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

{CODE()}
@chosen-active-result: @input-color;
{CODE}

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:

{CODE()}
//** 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
{CODE}

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.


        

History

Advanced
Information Version
Sun 17 of Jul, 2016 07:36 GMT-0000 Gary Cunningham-Lee Add last section. 2
Sun 17 of Jul, 2016 07:17 GMT-0000 Gary Cunningham-Lee 1