PHP Classes
elePHPant
Icontem

Theme Roller: Generate CSS stylesheets with color palette themes

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-05-25 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 159 All time: 8,669 This week: 471Up
Version License PHP version Categories
themeroller 1.1MIT/X Consortium ...5HTML, PHP 5
Description Author

This class can generate CSS style sheets with color palette themes.

It can compose CSS style sheets by adding selectors and rules, as well default values for theme colors.

The class comes with a short themes list that are associated with year seasons with multiple styles for color palette values values.

The default theme may be taken from session variables.

The class can also generate an select form input to let the user pick the preferred theme.

The generated CSS is returned as a string but can be written to a debug file.

  Performance   Level  
Name: Gerry Danen <contact>
Classes: 3 packages by
Country: Malaysia Malaysia
Age: 70
All time rank: 21818 in Malaysia Malaysia
Week rank: 755 Up3 in Malaysia Malaysia Up

 

Details

Theme Roller

Version 1.0.1 23 May 2016

Theme Roller creates CSS style sheets on the fly. Palettes for the chosen theme are created, as well as "all-color" palettes.

Components to make Theme Roller work: * themeRoller.class.php - the class file * sample.php - sample script to test functionality * sample2.php - sample script to test functionality * theme.php - the generated CSS style sheet (output as a CSS string) * themeStrings.php - like theme.php, but this file exposes certain variables that may come in handy in debugging * themeContent.php - the CSS directives go here; used by theme.php and themeStrings.php * readme.md - instructions

themeRoller.class.php

There are 2 static functions for use: * selectTheme() - checks $_SESSION['theme']['choice'] to get the desired theme code; if not found, the designated default code is returned. * themeOptionSelect() - returns a list of theme options to select from

Instantiate the Theme Roller object like this:

> $roller = new ThemeRoller($theme, 'Colour theme: {{theme-title}}');

where $theme is the theme code (can be obtained from selectTheme() or set specifically) and the second parameter is the title that will go in the CSS file.

Functions available:

  • ->addSelector(selector, comment) * selector, like 'body', '.className', or '#idName' * comment (optional), selector comment
  • ->addRule(rule, value) * rule, like 'color', or 'background-color' * value, like '#E8ECFF'
  • ->getThemeDefValue(definition) * definition, like 'color', or 'background-color'
  • ->generateCSS() * generates CSS, and palette files

themeContent.php

This file contains the rules to generate the CSS styles.

Debug functionality

Comprehensive debug functionality is built in. This is also useful for learning how the class works internally. Make sure the debug directory is writeable. Currently set to /data/debug/, you may change that to suit your needs.

License

The MIT License (MIT)

Copyright (c) 2016 Gerry Danen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  theme_rollerExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Accessible without login Plain text file buildUrl.inc.php Appl. Helper script
Accessible without login Plain text file generalFunctions.inc.php Aux. Helper script
Accessible without login Plain text file readme.md Doc. documentation
Accessible without login Plain text file sample.php Example Sample usage
Accessible without login Plain text file sample2.php Example Example file
Accessible without login Plain text file theme.php Appl. Generated CSS
Accessible without login Plain text file themeContent.php Appl. CSS rules
Plain text file themeRoller.class.php Class Class file
Accessible without login Plain text file themeStrings.php Aux. Helper script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:159
This week:0
All time:8,669
This week:471Up