Skip to content

Instantly share code, notes, and snippets.

View bansavage's full-sized avatar
🌐
Building Luxe Digital Experiences for Brands

Kyle Bansavage bansavage

🌐
Building Luxe Digital Experiences for Brands
View GitHub Profile
@bansavage
bansavage / migrate-metafields.md
Created January 10, 2025 20:12 — forked from tpage99/migrate-metafields.md
Migrate legacy metafield definitions to Shopify's native editor

Migrate Legacy Metafields

If an error occurs for a value already existing for a metafield (legacy) but isn't available, navigate to:

/admin/metafields/[type]/migrate/[namespace]/[key]

to migrate to native Shopify metafields editor.

Example

Example for SEO Hidden created with previous methods, route would be:

@bansavage
bansavage / fetch.js
Last active May 19, 2023 05:09
FETCH - Super Clean JS Fetch Code
//Create function that builds a header object for JS Fetch
function fetchConfig(type = 'json') {
return {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': `application/${type}` }
};
}
//Create function to create header object for Fetch JS command
const body = JSON.stringify({
@bansavage
bansavage / get_url_parameter.liquid
Created April 26, 2023 04:41
Get URL parameter using Liquid
{% comment %}
To use:
{% render 'get_parameter' get_parameter: 'color' %}
{% endcomment %}
{%- assign param = get_parameter | default: '' -%}
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
@bansavage
bansavage / 100vh-fix.css
Created November 5, 2021 04:40
100vh-fix
.element {
max-height: calc(100vh - 250px); /* Fallback for browsers that do not support Custom Properties */
height: calc( calc(var(--vh, 1vh) * 100) - 250px); /* 100vh - 250px */
}
.element2 {
max-height: calc(100vh - 250px); /* Fallback for browsers that do not support Custom Properties */
height: calc(var(--vh, 1vh) * 100) /* 100vh */
}
@bansavage
bansavage / on_touchstart_or_click.js
Created September 29, 2021 02:39
Detect touchstart or click
var clickEvent = (function() {
if ('ontouchstart' in document.documentElement === true)
return 'touchstart';
else
return 'click';
})();
$document.on(clickEvent, '.element', function(event) {});
@bansavage
bansavage / mutation-observer.js
Created September 22, 2021 21:37
Mutation Observer (JS)
let mainTarget = document.querySelector('main');
let config = { attributes: true, childList: true, subtree: true };
let callback = function(mutationsList, observer) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
//code here
}
}
};
@bansavage
bansavage / img.scss
Created July 19, 2021 21:07
The Right Way Lazysizes Styles
/* MIXINS
*********/
/*============================================================================
Prefix mixin for generating vendor prefixes.
Based on https://github.com/thoughtbot/bourbon/blob/v4-stable/app/assets/stylesheets/addons/_prefixer.scss
Usage:
// Input:
.element {
@bansavage
bansavage / lazysizes.js
Last active September 22, 2021 21:38
The Right Way Lazysizes Script with plugins
/*! lazysizes - v5.3.1 - config */
window.lazySizesConfig = window.lazySizesConfig || {};
window.lazySizesConfig.loadHidden = false;
/*! lazysizes - v5.3.1 - MAIN SCRIPT */
!function(e){var t=function(u,D,f){"use strict";var k,H;if(function(){var e;var t={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",fastLoadedClass:"ls-is-cached",iframeLoadMode:0,srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:true,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:true,ricTimeout:0,throttleDelay:125};H=u.lazySizesConfig||u.lazysizesConfig||{};for(e in t){if(!(e in H)){H[e]=t[e]}}}(),!D||!D.getElementsByClassName){return{init:function(){},cfg:H,noSupport:true}}var O=D.documentElement,i=u.HTMLPictureElement,P="addEventListener",$="getAttribute",q=u[P].bind(u),I=u.setTimeout,U=u.requestAnimationFrame||I,o=u.requestIdleCallback,j=/^picture$/i,r=["load","error","lazyincluded","_l
@bansavage
bansavage / img.liquid
Last active September 22, 2021 21:38
The Right Way Image Snippet
{%- comment -%}
=========================================
THE RIGHT WAY - RESPONSIVE IMAGE SNIPPET
=========================================
Outputs an image ready for Lazysizes plugin (https://github.com/aFarkas/lazysizes)
OPTIONS:
type: Sets image type if not a Shopify image object.
'asset', 'file', 'url', 'accentuate'
@bansavage
bansavage / README.MD
Created June 3, 2021 15:39 — forked from lmarkus/README.MD
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...