Skip to content

Instantly share code, notes, and snippets.

View M-Drummond's full-sized avatar
🦨

mackinley M-Drummond

🦨
  • 18:34 (UTC +10:00)
View GitHub Profile
@M-Drummond
M-Drummond / onClick.js
Created February 17, 2016 03:00
jQUery basic click handler
$('button').on('click', function() {
var message = $('<span>Call 1-555-jquery-air to book this tour</span>');
$('.usa').append(message);
$('button').remove();
});
@M-Drummond
M-Drummond / gulpfile.js
Last active March 30, 2016 00:28
Simple Sass + Watch Gulpfile
var gulp = require('gulp');
var sass = require('gulp-sass');
var input = '*.scss';
var output = '';
gulp.task('sass', function () {
return gulp
// Find all `.scss` files from the `stylesheets/` folder
.src(input)
@M-Drummond
M-Drummond / analytics-external-link.js
Created May 25, 2016 23:34
Use Analytics to detect links to external pages.
@M-Drummond
M-Drummond / grid-bloq.html
Created August 11, 2016 11:15
Bloqs - Grid layout as used on Warrawong Plaza.
{grid}
<section class="grid {if background_style == 'colour'}colour{/if} {if background_style == 'image'}image-bg{/if}" {if background_style == 'image'}style="background-image: url({background_image}); "{/if} >
<div class="container">
{if image_heading}<img src="{image_heading}" alt="{title}">
{if:else}
<h1>{title}</h1>
{if more}<a href="{more_link}" class="more">{more} <?php echo file_get_contents("images/icons/chevron-right.svg") ?></a>{/if}
{/if}
</div>
@M-Drummond
M-Drummond / srcSet.twig
Created March 26, 2019 22:54
Craft + imager data-srcset macro.
{% macro srcSet(image) %}
{# Lazyload + WebP enable iamge tag. #}
{# Create image sizes in JPG format #}
{% set jpg = [
{ width: 1080 , format: 'jpg' },
{ width: 900 , format: 'jpg'},
{ width: 720 , format: 'jpg'},
{ width: 480 , format: 'jpg' }
@M-Drummond
M-Drummond / contact.twig
Created June 4, 2019 00:46
reCaptcha and Craft3
<form method="post" action="?" accept-charset="UTF-8" class="form" id="contact-form">
<input type="hidden" name="action" value="contact-form/send">
<label for="email" id="label-email">Your Email</label>
<input type="email" id="email" name="fromEmail">
<div class="g-recaptcha" data-sitekey="{{ reCaptcha.siteKey }}"></div>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
@M-Drummond
M-Drummond / .eslintignore
Last active June 4, 2019 03:57
Basic Punchbuggy eslint setup
public/assets
web/assets/
node_modules
*.min.js
src/js/vendor/*
gulpfile.js
*.html
*.twig
{
products ( limit: -1 ) {
dateCreated @formatDateTime (format: "Y-m-d")
title
... on standard_Product {
description
image {
url @transform (handle: "general" )
}
productCategory {
@M-Drummond
M-Drummond / filteredProducts.ts
Last active March 3, 2024 10:00
Vue - Computed property to filter an array of products.
export function filteredProducts() {
// get the total list of products
let filteredProducts = useGlobalStore().products;
// set criteria - examples var names here.
const stamina = useGlobalStore().decisions.stamina
const type = useGlobalStore().decisions.type
const group = useGlobalStore().decisions.group
@M-Drummond
M-Drummond / media.twig
Last active March 3, 2024 09:58
CraftCMS - get the webp/jpeg version of a a sourceset.
{% macro imageSourceTags( image ) %}
{% if image.extension is defined %}
{% if image | length >= 1 and image.extension != 'svg' %}
{% set formats = ['webp', 'jpg'] %}
{% for format in formats %}
{% set srcset = image.getSrcset([185, 576, 768, 960, 1454, 1920, 2560], { format: format }) %}
<source srcset="{{ srcset }}" type="image/{{ format }}" sizes="100vw">
{% endfor %}