Skip to content

Instantly share code, notes, and snippets.

@marinho
Created November 5, 2016 13:40
Show Gist options
  • Save marinho/46c50ad3a8e625c7063f060a85dea496 to your computer and use it in GitHub Desktop.
Save marinho/46c50ad3a8e625c7063f060a85dea496 to your computer and use it in GitHub Desktop.
sg-wrapper not working in sc5-styleguide
// Imports
var gulp = require('gulp');
var sass = require('gulp-sass');
var styleguide = require('sc5-styleguide');
// Path definitions
var sourcePath = 'src';
var htmlWild = sourcePath + '/**/*.html';
var styleSourcePath = sourcePath + '/styles';
var scssWild = styleSourcePath + '/**/*.scss';
var scssRoot = styleSourcePath + '/tutorial.scss';
var overviewPath = styleSourcePath + '/README.md';
var buildPath = 'build';
var styleBuildPath = buildPath + '/styles';
var styleguideAppRoot = '/styleguide';
var styleguideBuildPath = buildPath + styleguideAppRoot;
var tmpPath = 'tmp';
var styleguideTmpPath = tmpPath + '/styleguide';
// Building the application
//
// In reality the app would ofcourse be a lot more complex.
// Here the app simply consists of some HTML so we get to examine how
// the styles would be used in the application. A key relevation is
// that the markup needs to be written into the app. There is no magic
// that would bring the markup for a page into the app from the pages
// section in the styleguide.
gulp.task('html', function() {
return gulp.src(htmlWild)
.pipe(gulp.dest(buildPath));
});
gulp.task('scss', function() {
return gulp.src(scssRoot)
.pipe(sass())
.pipe(gulp.dest(styleBuildPath));
});
// Building styleguide for static hosting to be displayed as a part of the application
//
// Here we build the styleguide so it can be included in a web folder within the app.
// The benefit for including the styleguide at /styleguide path of the app is that
// everyone can always find a master copy of the style guide. Another benefit is that
// this copy will be load balanced by the web server, so it can handle heavy loads.
// All interactive features are disabled to prevent users from tampering with the
// styles.
gulp.task('staticStyleguide:generate', function() {
return gulp.src(scssWild)
.pipe(styleguide.generate({
title: 'C4RE Style Guide',
rootPath: styleguideBuildPath,
appRoot: styleguideAppRoot,
overviewPath: overviewPath
}))
.pipe(gulp.dest(styleguideBuildPath));
});
gulp.task('staticStyleguide:applystyles', function() {
return gulp.src(scssRoot)
.pipe(sass({ errLogToConsole: true }))
.pipe(styleguide.applyStyles())
.pipe(gulp.dest(styleguideBuildPath));
});
gulp.task('staticStyleguide', ['staticStyleguide:generate', 'staticStyleguide:applystyles']);
// Running styleguide development server to view the styles while you are working on them
//
// This task runs the interactive style guide for use by developers. It runs a built-in server
// and contains all the interactive features and should be updated automatically whenever the
// styles are modified.
gulp.task('styleguide:generate', function() {
return gulp.src(scssWild)
.pipe(styleguide.generate({
title: 'C4RE Style Guide',
server: true,
port: 3001,
rootPath: styleguideTmpPath,
overviewPath: overviewPath,
beforeBody: [
"<style>@import url('https://fonts.googleapis.com/css?family=Open+Sans&subset=latin');</style>"
]
}))
.pipe(gulp.dest(styleguideTmpPath));
});
gulp.task('styleguide:applystyles', function() {
return gulp.src(scssRoot)
.pipe(sass({ errLogToConsole: true }))
.pipe(styleguide.applyStyles())
.pipe(gulp.dest(styleguideTmpPath));
});
gulp.task('styleguide', ['styleguide:generate', 'styleguide:applystyles']);
// Developer mode
gulp.task('dev', ['html', 'scss', 'styleguide'], function() {
gulp.watch(htmlWild, ['html']);
gulp.watch(scssWild, ['scss', 'styleguide']);
console.log(
'\nDeveloper mode!\n\nSC5 Styleguide available at http://localhost:3001/\n'
);
});
// The basic build task
gulp.task('default', ['html', 'scss', 'staticStyleguide'], function() {
console.log(
'\nBuild complete!\n\nFresh build available in directory: ' +
buildPath + '\n\nCheckout the build by commanding\n' +
'(cd ' + buildPath + '; python -m SimpleHTTPServer)\n' +
'and pointing yout browser at http://localhost:8000/\n' +
'or http://localhost:8000/styleguide/ for the styleguide\n\n' +
'Run gulp with "gulp dev" for developer mode and style guide!\n'
);
});
@import './variables';
@import './mixins';
// .table-header
//
// Table header section
//
// markup:
// <thead class="table-header">
// <tr>
// <th class="table-header__cell table-header__cell--featured">Service</th>
// <th class="table-header__cell">Unit</th>
// <th class="table-header__cell table-header__cell--number">Quantity</th>
// <th class="table-header__cell table-header__cell--number">Cost</th>
// <th class="table-header__cell table-header__cell--number">Total</th>
// </tr>
// </thead>
//
// sg-wrapper:
// <table class="table">
// <sg-wrapper-content/>
// <table>
//
// Styleguide 1.2.3
.table-header {
position: relative;
background: $contrast-background-color;
color: $contrast-foreground-color;
width: 100%;
&__cell {
padding: $vertical-table-header-cell-padding $horizontal-table-cell-padding;
text-align: left;
font-weight: normal;
&--featured {
font-weight: 600;
}
&--number {
text-align: right;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment