Skip to content

Instantly share code, notes, and snippets.

View JoeCianflone's full-sized avatar

Joe Cianflone JoeCianflone

View GitHub Profile
@JoeCianflone
JoeCianflone / twig_bug
Created March 7, 2012 01:51
Bug with Twig
//Somewhere in a Class...
Twig_Autoloader::register();
$this->loader = new Twig_Loader_Filesystem($this->CI->config->item('filepath'));
$this->twig = new Twig_Environment($this->loader, $this->configs['env']);
$this->twig->setLexer(new Twig_Lexer($this->twig, $this->configs['tags']));
$tags = array('if');
$filters = array('upper');
<?php
class Controller extends Slim_Middleware {
public $params;
public function __construct() { }
public function paramConfig() {
$this->params = $this->app->request()->params();
@JoeCianflone
JoeCianflone / error.sh
Last active December 7, 2015 14:45
NPM issue
→ gulp compile
module.js:340
throw err;
^
Error: Cannot find module 'amdefine'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
@JoeCianflone
JoeCianflone / fonts.scss
Created December 11, 2015 17:15
PX to Unitless line-height conversion and font fallbacks
// I hate converting units so here's how to do
// px to rem conversion with a fallback to px
// for older browsers...
/**
* Resize font from one type to another
* @param {[type]} $fontSize the font size that you want
* @param {[type]} $toUnit: rem the unit you want to convert to
* @param {[type]} $fromUnitSpecific: px default unit we're going to convert from (if you don't set it)
*
@JoeCianflone
JoeCianflone / SassMeister-input.scss
Created January 6, 2016 04:22
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@function get-value($n) {
@return $n / ($n * 0 + 1);
}
@function get-line-height($font-size, $line-height) {
@return get-value($line-height / $font-size);
@JoeCianflone
JoeCianflone / SassMeister-input.scss
Created January 6, 2016 23:02
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@function get-line-height($font-size, $line-height) {
@return $line-height / $font-size;
}
.foo {
font-size: 22px;
@JoeCianflone
JoeCianflone / SassMeister-input.scss
Created January 17, 2016 22:30
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@function get-line-height($font-size, $line-height) {
@return $line-height / $font-size;
}
.foo {
font-size: 22px;
@JoeCianflone
JoeCianflone / SassMeister-input.scss
Last active January 17, 2016 22:42
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
.person {
width: 100%;
&__element {
width: 80%;
}
@JoeCianflone
JoeCianflone / px-to-rem.md
Last active March 19, 2020 05:14
Converting Pixels to Rem;s with a Simple Mixin

Did you ever notice that developers and designers have different languages? A designer, working in Photoshop or Sketch, will be talking about things in pixels. Designers make headers that are 48 pixels tall and have 60 pixel line-heights. Developers, like me, tend to think about things in percentages or EMs. We want font-sizes that are 4.8rem and line heights that are 1.6.

Today I want to resolve the pixel font-size issue with Sass.

Let's pretend you've got a new blog to code today. You crack open the design file and you see the following:

Main Header: 32px
Sub-Header: 28px
body copy: 18px
@JoeCianflone
JoeCianflone / input.scss
Created November 4, 2020 14:45
Generated by SassMeister.com.
$mq: (
'xs': #{'min-width: 480px'},
'sm': #{'min-width: 576px'},
'md': #{'min-width: 768px'},
'wd': #{'min-width: 900px'},
'xw': #{'min-width: 1024px'},
'lg': #{'min-width: 1280px'},
'xl': #{'min-width: 1366px'},
);