Skip to content

Instantly share code, notes, and snippets.

View letrastudio's full-sized avatar

Letra Studio letrastudio

View GitHub Profile
@letrastudio
letrastudio / fixed-ratio-grid.scss
Last active November 18, 2016 10:45
All that's needed to make a nice, dynamic grid using the CSS Grid Layout Module. Useful for lists of products, photos, videos, etc. where all items have the same aspect ratio.
.grid-container {
display: grid;
grid-gap: 1em;
// set the number of columns explicitly:
grid-template-columns: repeat(4, 1fr);
// or set the number of columns based on minimum element width:
grid-template-columns: repeat(auto-fill, minmax(16em, 1fr));
// the magic trick! this fills up gaps automatically when some items are larger than others:
grid-auto-flow: dense;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
font: 18px/1.5 -apple-system, sans-serif;
font-kerning: normal;
text-rendering: optimizeLegibility;
@letrastudio
letrastudio / responsify-embeds.js
Last active June 9, 2018 02:31
Make all iframes in a page responsive, keeping aspect ratio from width/height attributes
function responsifyEmbeds() {
var iframes = document.getElementsByTagName("iframe");
for (var i = 0; i < iframes.length; i++) {
var iframe = iframes[i];
var parent = iframe.parentNode;
var wrapper, width, height;
// ignore iframes with "100%" width (those are presumed to be responsive enough already)
if (iframe.getAttribute("width") !== "100%") {
{% if object == nil %}
object is nil
{% elsif object == true or object == false %}
object is a boolean
{% elsif object.first %}
object is an array
{% else %}
{% assign number_test = object | divided_by: 1.0 %}
{% if object == number_test %}
object is a number
@letrastudio
letrastudio / uploads.html
Created March 13, 2018 11:35
Loop though media files in a Jekyll collection and display them in a list
---
---
<ul>
{% assign collection = site.collections | where: 'label', 'uploads' | first %}
{% for file in collection.files %}
{% assign extension = file.extname | downcase %}
{% case extension %}
{% assign heading_level = "2" %}
{% assign opening_tag = "<h" | append: heading_level %}
{% assign closing_tag = "</h" | append: heading_level | append: ">" %}
{% assign toc = content | split: opening_tag %}
<nav class="page-toc">
<ol>
{% for item in toc %}
{% if item contains closing_tag %}
{% assign tag = item | split: closing_tag | first | strip %}
function imageType(format) {
switch (format.toUpperCase()) {
case "JPEG":
case "JPG":
return { format: "JPEG", ext: "jpg", mimetype: "image/jpeg" }
case "PNG":
return { format: "PNG", ext: "png", mimetype: "image/png" }
case "GIF":
return { format: "GIF", ext: "gif", mimetype: "image/gif" }
case "SVG":