Skip to content

Instantly share code, notes, and snippets.

@josephbergdoll
josephbergdoll / Styleguide.scss
Last active August 29, 2015 14:10
Empty Styleguide
// Empty Global Styleguide (SG)
// Define ONLY type styles in the silent clases, that way they can be reused.
// Get specific with colors, alignment, etc, in the actual declarations below where these silent classes are extended.
a {
}
%sg-h1 {
}
// Aritst Card Hover Thumb Interval
$('.artist-card.more-thumbs').each(function() {
var
thumb = '.image-thumb',
$thumb = $(this).find('.image-thumb'),
activeClass = 'thumb-active',
activeSelector = '.thumb-active';
$(this).mouseenter(function() {
var $this = $(this);
if ($this.find(activeSelector).next(thumb).length) {
@josephbergdoll
josephbergdoll / Neat-Grid-Clases.scss
Last active November 28, 2018 04:40
A generator for Foundation style classes to be used with Bourbon Neat, assuming you have the same breakpoints I do.
// Breakpoints
$small: new-breakpoint(max-width 767px 6);
$medium-only: new-breakpoint(min-width 768px max-width 1023px 12);
$medium-up: new-breakpoint(min-width 768px 12);
$large-only: new-breakpoint(min-width 1024px max-width 1279px 12);
$large-up: new-breakpoint(min-width 1024px 12);
$xlarge-only: new-breakpoint(min-width 1280px max-width 1799px 12);
$xlarge-up: new-breakpoint(min-width 1280px 12);
$xxlarge: new-breakpoint(min-width 1800px 12);
@josephbergdoll
josephbergdoll / lazyload-noreflow.js
Created July 16, 2015 20:47
For lazy loading images
// Assumes all of your images are wrapped in a container with the class .js-image-container
// I use separate "js-" prepended classes so that way interactivity couplings are separate from
// visual style changes. => https://coderwall.com/p/qktuzw/decouple-javascript-classes-from-css-ones-by-using-prefix
//
// this is written with the notion that you are using markup as follows:
// <div class="img-container js-img-container">
// <img src="../path/to/image.jpeg" data-width="[width of jpeg without px]" data-height="[height of jpeg without px]">
// </div>
// somewhere in your CSS, you want the following:
@josephbergdoll
josephbergdoll / Course-Fixed.js
Last active August 29, 2015 14:25
course fixed
// Assumes all of your images are wrapped in a container with the class .js-image-container
// I use separate "js-" prepended classes so that way interactivity couplings are separate from
// visual style changes. => https://coderwall.com/p/qktuzw/decouple-javascript-classes-from-css-ones-by-using-prefix
//
// this is written with the notion that you are using markup as follows:
// <div class="img-container js-img-container">
// <img src="../path/to/image.jpeg" data-width="[width of jpeg without px]" data-height="[height of jpeg without px]">
// </div>
// somewhere in your CSS, you want the following:
@josephbergdoll
josephbergdoll / no_orphans.php
Last active November 30, 2015 23:53
Small PHP function to prevent orphans from occurring in digital typography. More on orphans, widows, and rags: http://www.fonts.com/content/learning/fontology/level-2/text-typography/rags-widows-orphans
<?php
// What are orphans?
// http://www.fonts.com/content/learning/fontology/level-2/text-typography/rags-widows-orphans
function noOrphans($str) {
$nbspStr = null;
if (strpos($str, '<p>') !== false) {
$paragraphs = explode('</p>', $str);
foreach($paragraphs as &$paragraph) {
$lastSpace = strrpos($paragraph, ' ');
$nbspParagraph = substr_replace($paragraph, '<span class="nbsp">&nbsp;</span>', $lastSpace, 1);
@josephbergdoll
josephbergdoll / web-fonts-asset-pipeline.md
Created December 4, 2015 18:42 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

<!--
RESPONSIVE IMAGE SNIPPET
Based on https://gist.github.com/zacwasielewski/6140785cf500d63fcb26
Works with both product and blog images.
I usually include this, like so for products:
{% for image in product.images %}
<img src="#" data-srcset="{% include 'responsive-image', image: image, product: 'true' %}">
{% endfor %}
<?php
// LiveReload script injection for those using grunt-watch
// This way you don't have to go to the localhost port
// Call this function once in the <head> of your layout.twig via {{ liveReload }}
// You can disable it by either removing or passing {{ liveReload(false) }}
// Add the local domain you are developing from by passing it as the second argument:
// {{ liveReload(true, 'example.dev') }}
namespace Craft;