Tutorial: Integrating colouro sync to gulp-based project
This tutorial will walk you through process of integrating colouro-sync to your gulp-based workflow.
There is prepared fork of StartBootstrap Comming Soon Theme for you. The StartBootstrap templates was choosen as good base for the tutorial as it provides:
- clean gulp-based project starter,
devtask prepared for running browser-sync,- uses SASS as stylesheet processor.
Fastest way to try Colouro in action
If you want just quickly try Colouro in action and don't want to go thru the whole tutorial below, there is a shortcut for you:
Clone the repository (point 1 in tutorial below)
git clone https://github.com/barzto/startbootstrap-coming-soon.gitSwitch to
colouro-integratedbranch:cd startbootstrap-coming-soon git checkout colouro-integrated- Run Colouro app, enter the preview dialog, make sure you are connected to same wifi as the computer and note the IP address for next step.
- Change the
hostfield incolouro.jsonfile to the address from previous step. - Run
gulp devto start thebrowserSyncalong withcolouroSync. At this point you should be able to change colors live from Colouro app.
Get your gulp-based project.
In your working directory run following git clone command to get the forked repo cloned into
startbootstrap-commin-soondirectory.git clone https://github.com/barzto/startbootstrap-coming-soon.gitInstall npm packages
cd startbootstrap-coming-soon npm installInstall
colouro-sdkas dev dependencynpm i -D colouro-sdkModify
gulpfile.jsto initializecolouroSyncalong withbrowserSync.Import the colouroSync function at beginning of
gulpfile.jsconst colouroSync = require('colouro-sdk').colouroSync;Call
colouroSync()inbrowserSync(done)function. Change the function so it looks like this:// BrowserSync function browserSync(done) { colouroSync(); browsersync.init({ server: { baseDir: "./" } }); done(); }
Create template to be used by expanded by colouro-sync
cd scss cp _variables.scss _variables.scss.inEdit the newly created
_variables.scss.infile and replace non-gray color values with curly braces variables like this (note the last block of variables):// Variables // Restated Bootstrap Variables $white: #fff !default; $gray-100: #f8f9fa !default; $gray-200: #e9ecef !default; $gray-300: #dee2e6 !default; $gray-400: #ced4da !default; $gray-500: #adb5bd !default; $gray-600: #868e96 !default; $gray-700: #495057 !default; $gray-800: #343a40 !default; $gray-900: #212529 !default; $black: #000 !default; $primary: {{bg-maj}} !default; $primary-fg: {{fg-maj}} !default; $secondary: {{bg-min}} !default; $secondary-fg: {{fg-min}} !default; $midground: {{mg}} !default;Run the Colouro app on your handset. Enter the preview dialog and:
- Make sure you are connected to the same wifi as the computer with project, and
- note the IP address for next step.
Create
colouro.jsonconfiguration file in project root with following content. Replace the IP address inhostfield with the one Colouro app shows in preview dialog (i.e. the address of handset app is running on).{ "dest": "scss/_variables.scss", "templateFile": "scss/_variables.scss.in", "host": "192.168.0.42:8080" }Now we have all set for live color update. The last thing we need to do is run
gulp devto start browserSync server and watch project files for changes.gulp devNew browser tab should get open with the
index.htmlfile loaded. At this point you should be able to change SCSS color variables within Colouro app. Have fun!