Skip to content

Instantly share code, notes, and snippets.

View searleb's full-sized avatar

Bill Searle searleb

View GitHub Profile
@searleb
searleb / installing-react-laravel.md
Last active September 10, 2017 21:55
Setting up React with Laravel

Setting up React with Laravel

This guide will help you get a starting point for implementing React into a default install of Laravel v5.3.

Install React

cd application
npm install --save react react-dom

Gulp file

@searleb
searleb / gulpfile.js
Created July 20, 2016 01:09
Gulp - BrowserSync, Sass -> Css, Imagemin
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {
browserSync.init({
@searleb
searleb / controller.js
Created May 3, 2016 05:19
How to act detect the end of ng-repeat - useful for jQuery
// Init slider with options
scope.$on('LastRepeaterElement', function(){
// Do something
$slider.slick(slickOptions);
});
@searleb
searleb / prevent-page-scrolling.js
Created March 14, 2016 00:38
Prevent page scrolling - eg when using a full screen nav overlay
// prevent page scrolling when mobile menu is visible
$('.navbar-toggle').on('click', function() {
$('body').toggleClass('no-scroll');
});
@searleb
searleb / Outside the nav click.js
Created March 10, 2016 00:16
Click any where that isn't the nav to close but clicking anywhere on the nav won't close it. The one is also staggered closing multiple nav levels.
/**
* Closes all navigation layers, staggered from bottom
* if the user clicks anywhere outside of the nav
*/
$('html').on('click', function(event) {
// if the closest parent is not the nav
if (!$(event.target).closest('nav').length) {
// get all elements with the nav--open class and reverse the array
$($('.nav--open').get().reverse()).each(function(i, el) {
// remove the element nav--open class with 300ms * i delay to get the stagger effect
@searleb
searleb / blade-template.php
Created February 29, 2016 23:01
Slick Slider with custom controls and slide indicator
// blade template - just html really
@section('journal-carousel')
<div class="container article-carousel">
<div class="row">
<div class="col-sm-12">
<div class="article-carousel__slider">
@for ($i = 0; $i < 3; $i++)
<figure><img src="{{Theme::url('images/blonde'.$i.'.jpg')}}" alt="" class="img-responsive" /></figure>
@endfor
@for ($i = 0; $i < 3; $i++)
@searleb
searleb / _helpers.scss
Created February 24, 2016 23:05
A collection of SCSS helpers
/**
* Add this to a bootstrap .row to add flex.
* This will cause child .col-* elements to expand to equal hights
*/
.row-flex {
@media #{$media-sm}{
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
@searleb
searleb / _mixins.scss
Last active March 3, 2016 03:15
A collection of SCSS mixins
/**
* background-image mixin
* @param {string} $url only image name required
* @param {string} $pos: center background-position: [default]center
* @param {string} $size: cover background-size: [default]cover
* @param {string} $rep: no-repeat background-repeat: [default]no-repeat
*/
@mixin background-image($url, $pos: center, $size: cover, $rep: no-repeat ) {
background-image: url('../images/#{$url}');
background-position: $pos;
@searleb
searleb / meteor-starting-packages
Last active January 30, 2016 02:35
Default Meteor Packages
meteor remove insecure autopublish
meteor add fourseven:scss iron:router msavin:mongol accounts-ui
npm install -g meteor-jsdoc
@searleb
searleb / format-time.js
Last active January 4, 2016 05:31
Meteor Template Helper - Format Time with Moment.js
// requires Moment.js
// format time
UI.registerHelper('formatTime', function(time, formatting) {
if(time) {
return moment(time).format(formatting);
}
});