Skip to content

Instantly share code, notes, and snippets.

View CreateSean's full-sized avatar

CreateSean

View GitHub Profile
@terryupton
terryupton / modal.twig
Created April 9, 2020 18:18
Ajax Loading a page into a modal with Alpine JS
<section x-data="{showModal: false, html: ''}">
<button
@click="html='loading...'; showLoading = true; showModal = !showModal;
fetch('{{ entry.url }}', {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
},
})
@zenbug
zenbug / responsive-images-craft.txt
Last active July 14, 2020 14:32
Using LazySizes and the Picture element with responsive breakpoints for art-direction in Craft CMS
{#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_layouts/main-layout.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All image transforms are defined here in the main layout template so they can be used site-wide. Templates using this layout can reference them thus:
{{ theBackgroundImage.url(transform.small) }}
#}
{% set transform = {
small: {
{% macro truncate(text, limit, append) %}
{# settings #}
{% set suffix = append|default('...') %}
{% set punctuation = ['.',',','-',':',';'] %}
{# logic #}
{% set array = text|split(' ') %}
{% set arrayTruncated = array|slice(0, limit) %}
{% set string = arrayTruncated|join(' ') %}
{% if limit and array|length > limit %}
{% for mark in punctuation %}
// Add this to your 'plugins' array in your tailwind config file.
// This creates classes suffixed with an opacity level for each bg colour
// For example, .bg-red would have .bg-red-10 through .bg-red-100 for 0.10% opacity background and 100% opacity respectively.
({addUtilities, config}) => {
let colors = config('colors', []);
const newColors = {};
let hexToRgb = (hex) => {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
@aarongustafson
aarongustafson / lazy-loaded-markup.html
Last active March 8, 2018 09:35
Easy Responsive Images in ExpressionEngine with CE Image
<div class="module__image image--lazy"
data-image-src="Tim-Smith_220x140_220_140_int_c1.jpg"></div>
@shoeshine
shoeshine / EE-default.gitignore
Last active December 27, 2015 04:09
Default ExpressionEngine .gitignore file
# Globals
.DS_Store
cgi-bin/
error_log
# Master Config
config/config.local.php
# Caches
sized/