Chrometoaster's KSS Styleguide generator.
Please note: this plugin is optimised for internal Chrometoaster use. YMMV.
- KSS - Knyle Style Sheets; if you're unfamiliar with KSS, please read our docs
- NPM - the Node Package Manager, installed with NodeJS
Open Terminal
npm list kss -g, to check whether you have the kss NPM package installed [src]- If KSS is
(empty):- In Terminal:
sudo npm install -g kss, to instruct NPM to install the KSS binary so that is available globally
- In Terminal:
This project uses the NodeJS implementation of KSS, so you will also need to install kss-node from Github:
- TODO:
???, to check whether you have this installed - If not:
cd /path/to/github-clones, to change to the directory where you store Git repositories that you clonegit clone https://github.com/chrometoasters/kss-node.git, to clone our copy ofkss-nodecd kss-node, to change into the directory you just createdsudo npm install -g- to instruct NPM to install thekss-nodedependencies listed inpackage.json. The-g('global') flag instructs OS X to copy the files to/usr/local/lib/node_modules/kss/
- If you haven't used Grunt before, please read Set up Grunt dependencies.
npm list bower -g, to check whether you have the Bower NPM package installed [src]- If Bower is
(empty):sudo npm install -g bower, to install Bower
Open Terminal
cd /PATH/TO/PROJECT-THEME-FOLDER, to change to your project's theme folder
Note: If you wish to customise where Bower puts installed components, you may add a .bowerrc file into your project directory:
{
"directory" : "PATH/TO/COMPONENTS"
}
This README makes the assumption that you have used the default Bower install path of bower_components.
bower install https://github.com/chrometoasters/ct-grunt-styleguide.git, to install this Grunt taskcp bower_components/ct-grunt-styleguide/package.json package.json, to copypackage.jsoninto your project's theme foldernpm install, to install the dependencies listed inpackage.json- SVN/Git ignore the generated folder:
node_modules - If you are using SVN, ignore the generated folder:
bower_components(bower #1194)
Note: KSS comments are stripped when CSS is compressed. For this reason it's best to set the src to your scss folder.
-
cp bower_components/ct-grunt-styleguide/Gruntfile.js Gruntfile.js, to copyGruntfile.jsinto your project's theme folder -
cp -Ri bower_components/ct-grunt-styleguide/grunt-tasks grunt-tasks, to copygrunt-tasksinto your project's theme folder; if this folder already exists you will need to manually merge the files contained within theoptionsfolder -
nano package.jsonto openpackage.json -
Edit the paths to suit your project; note that the
styleguide.srcfolder must exist already, but thestyleguide.destfolder will be created -
Control + X(exit) ->y(yes) ->Enter -
Create a project template (eg
styleguide-page.php) to import the Styleguide page, at the path you specified instyleguide.page// styleguide.php // NOTE: DOCUMENT_ROOT is the site root, not your theme root <!-- header code here --> <?php // START KSS STYLEGUIDE include( $_SERVER['DOCUMENT_ROOT'] . '/PATH/TO/PROJECT-THEME-FOLDER/STYLEGUIDE-DEST/index.php' ); // END KSS STYLEGUIDE ?> <!-- footer code here -->
Note that the styleguide requires jQuery be present at the top of the page, so if your project <head> does not include this already you will need to add it.
grunt styleguide, to run the Grunt task
- Perform step B1
- Perform step B2.1
- Perform step B4
- If you see
Fatal error: Unable to find local grunt., perform step B2.3 - Perform step B4
You may optionally specify an sg-overlay before your snippet HTML. This will position the design above your component, with controls to change the opacity and toggle the overlay layer off.
/*
Module: Modulename
Markup:
<div class="sg-overlay" draggable="true" data-current="true" data-img="MOE-IE-Guide-page-v14.jpg" data-img-w="1500" data-el-w="770" data-el-h="380" data-el-x="-951" data-el-y="4855"></div>
include "my-module-snippet.html"
Styleguide 123.4
*/
Source: ct-docs.js
Required options:
data-img- filename of the design image, relative to adesigns_pathof/PROJECT_RESOURCES_PATH/build/designs/data-img-w- the pixel width of the design image
Optional options:
data-current- toggle tofalseto indicate that the design has been updated since the CSS was last checkeddata-el-w- the pixel width of the design element, defaults to the width of the parent containerdata-el-h- the pixel height of the design element, defaults to the height of the parent containerdata-el-x- the pixel distance to move the design image to the left (defaults to half of the design width), defaults to zero; use a negative value for design elements located to left of centerdata-el-y- the pixel distance between the top of the design image and the top of the design element, defaults to zero
- You may use
console.logwithinGruntfile.jsto check paths