Skip to content

Instantly share code, notes, and snippets.

View wpeasy's full-sized avatar

Alan Blair wpeasy

  • WPEasy Pty Ltd
  • Brisbane Australia
View GitHub Profile
@wpeasy
wpeasy / template.json
Created July 7, 2024 23:32
ACSS A11Y Contrast Checker
{"content":[{"id":"zpoqdc","name":"section","parent":0,"children":["hxxvtj","eqyrql","tnchrj"],"settings":{},"label":"A11Y"},{"id":"hxxvtj","name":"code","parent":"zpoqdc","children":[],"settings":{"executeCode":true,"noRoot":true,"signature":"ef34dcb5f72679007750c01717fcfdf7","user_id":1,"time":1720392610,"code":"<script type=\"module\">\n // Function to convert RGB to Luminance\n const rgbToLuminance = (rgb) => {\n const rgbArr = rgb.match(/\\d+/g).map(Number);\n const [r, g, b] = rgbArr.map((value) => {\n value /= 255;\n return value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) / 1.055, 2.4);\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n }\n\n // Function to calculate the contrast ratio\n const calculateContrastRatio = (luminance1, luminance2) => {\n const brighter = Math.max(luminance1, luminance2);\n const darker = Math.min(luminance1, luminance2);\n return (brighter + 0.05) / (darker + 0.05);\n }\n\n // Function to check A11Y compliance\n const ch
@wpeasy
wpeasy / template.json
Created July 7, 2024 06:35
Bricks Builder Splitting JS
{"content":[{"id":"nzmpxb","name":"code","parent":0,"children":[],"settings":{"code":"<link rel=\"stylesheet\" href=\"https://unpkg.com/splitting/dist/splitting.css\" />\n<link rel=\"stylesheet\" href=\"https://unpkg.com/splitting/dist/splitting-cells.css\" />\n<script src=\"https://unpkg.com/splitting/dist/splitting.min.js\"></script>\n\n<script type=\"module\">\n Splitting(); \n</script>","executeCode":true,"noRoot":true,"signature":"388e5749bc3a3f681d4be4dc49285866","user_id":1,"time":1720330112}},{"id":"yqnnjo","name":"section","parent":0,"children":["vtzawa"],"settings":{}},{"id":"vtzawa","name":"container","parent":"yqnnjo","children":["pudafr"],"settings":{"_alignItems":"center"}},{"id":"pudafr","name":"text-basic","parent":"vtzawa","children":[],"settings":{"text":"Select any part of","tag":"p","_cssGlobalClasses":["kekkpn"],"_attributes":[{"id":"wcvkrk","name":"data-splitting"}]},"label":"Split Text"}],"source":"bricksCopiedElements","sourceUrl":"https://acss-at-based.local","version":"1.9.9","globa
@wpeasy
wpeasy / template.json
Last active June 14, 2024 14:40
Bricks Remote Slider Buttons
{"content":[{"id":"chbcen","name":"section","parent":0,"children":["dssnom"],"settings":{}},{"id":"dssnom","name":"container","parent":"chbcen","children":["ipncxv"],"settings":{"_display":"grid","_gridGap":"1rem","_gridTemplateColumns":"repeat(2, minmax(0, 1fr))"}},{"id":"dbe55a","name":"block","parent":"ipncxv","children":["771f25","909e90","a7136e","iwrkdr","2686bd"],"settings":{"_direction":"row","_cssGlobalClasses":["mkgizl"],"_attributes":[{"id":"jlzjql","name":"data-wpe-splide-id","value":"brxe-oennwd"},{"id":"hsqwec","name":"aria-role","value":"tablist"}],"tag":"ul"},"label":"WPE Splide Buttons"},{"id":"771f25","name":"div","parent":"dbe55a","children":["693011"],"settings":{"tag":"li","_cssGlobalClasses":["etqxgn"],"_attributes":[{"id":"bvagrz","name":"role","value":"presentation"}]},"label":"LI"},{"id":"693011","name":"button","parent":"771f25","children":[],"settings":{"text":"About","style":"primary","_cssGlobalClasses":["bggreh"],"tag":"button","_attributes":[{"id":"wycehu","name":"role","value":
@wpeasy
wpeasy / template-w-js.json
Created May 29, 2024 06:21
Zebre Card JS
{"content":[{"id":"viygze","name":"section","parent":0,"children":["egnjib"],"settings":[]},{"id":"egnjib","name":"container","parent":"viygze","children":["yonmxz","oqmbbl","uwohbk","rzygds"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_display":"grid","_gridGap":"3rem","_gridTemplateColumns":"1fr 1fr 1fr"}},{"id":"yonmxz","name":"block","parent":"egnjib","children":["tlcgnn","loidvy","gisipf"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_cssGlobalClasses":["dvrfvx"]},"label":"Zebre Card"},{"id":"tlcgnn","name":"image","parent":"yonmxz","children":[],"settings":{"tag":"figure","caption":"none","_cssGlobalClasses":["ysiige"],"image":{"id":463,"filename":"iegvy4o3bym.jpg","size":"large","full":"https://bb-card-tutorial.local/wp-con
@wpeasy
wpeasy / template.json
Created May 28, 2024 23:37
Card Transition Part 2 template
{"content":[{"id":"horvqp","name":"section","parent":0,"children":["sanapy"],"settings":{}},{"id":"sanapy","name":"container","parent":"horvqp","children":["tnmmsn","ulnnev","nldauu","dvkokk"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_display":"grid","_gridGap":"3rem","_gridTemplateColumns":"1fr 1fr 1fr"}},{"id":"tnmmsn","name":"div","parent":"sanapy","children":["ejhnwh","zfemip","tpipnu"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_cssGlobalClasses":["azsttb"]},"label":"Zebre Card V2"},{"id":"ejhnwh","name":"image","parent":"tnmmsn","children":[],"settings":{"tag":"figure","caption":"none","_cssGlobalClasses":["nlnmzm"],"image":{"id":463,"filename":"iegvy4o3bym.jpg","size":"large","full":"https://bb-card-tutorial.local/wp-co
@wpeasy
wpeasy / template.json
Created May 28, 2024 06:42
Zebre Card Template
{"content":[{"id":"viygze","name":"section","parent":0,"children":["egnjib"],"settings":[]},{"id":"egnjib","name":"container","parent":"viygze","children":["yonmxz","oqmbbl","uwohbk","rzygds"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_display":"grid","_gridGap":"3rem","_gridTemplateColumns":"1fr 1fr 1fr"}},{"id":"yonmxz","name":"block","parent":"egnjib","children":["tlcgnn","loidvy","gisipf"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_cssGlobalClasses":["dvrfvx"]},"label":"Zebre Card"},{"id":"tlcgnn","name":"image","parent":"yonmxz","children":[],"settings":{"tag":"figure","caption":"none","_cssGlobalClasses":["ysiige"],"image":{"id":463,"filename":"iegvy4o3bym.jpg","size":"large","full":"https://bb-card-tutorial.local/wp-con
@wpeasy
wpeasy / script.js
Last active April 26, 2024 03:19
Bricks Intersection Observers
(() => {
const animateAttribute = "data-animate";
const partialInSelector = ".animate-in-viewport";
const partialRootMargin = "-20% 0px -20% 0px";
const fullInSelector = ".animate-fully-in-viewport";
// Debounce function to limit the rate of execution
function debounce(func, delay) {
@wpeasy
wpeasy / javascript.js
Created April 19, 2024 06:39
Bricks fix focus state.
(() => {
document.addEventListener("DOMContentLoaded", () => {
const removeCSSRule = (selectorText) => {
// Get all stylesheets in the document
const stylesheets = document.styleSheets;
// Loop through all stylesheets
for (let i = 0; i < stylesheets.length; i++) {
const stylesheet = stylesheets[i];
@wpeasy
wpeasy / template-v1.json
Created April 14, 2024 21:42
Bricks Multi Getter
{"content":[{"id":"pvgpqz","name":"block","parent":"qpveqx","children":["nplvpo","bnytfm"],"settings":{"_cssGlobalClasses":["vqsvry"]},"label":"Greeter"},{"id":"nplvpo","name":"block","parent":"pvgpqz","children":["krzjsc","pcvgqk","xkljep","bsbgde"],"settings":{"_cssGlobalClasses":["jygnpk"]},"label":"Message"},{"id":"bnytfm","name":"block","parent":"pvgpqz","children":["tayvfi"],"settings":{"_cssGlobalClasses":["ffvjmd"]},"label":"Triggers"},{"id":"krzjsc","name":"heading","parent":"nplvpo","children":[],"settings":{"text":"I am a heading","_cssGlobalClasses":["wfbmzt"]}},{"id":"pcvgqk","name":"text","parent":"nplvpo","children":[],"settings":{"text":"<p>Here goes your text ... Select any part of your text to access the formatting toolbar.</p>","_cssGlobalClasses":["cbatsv"]},"label":"Text"},{"id":"xkljep","name":"button","parent":"nplvpo","children":[],"settings":{"text":"I am a button","style":"primary","_cssGlobalClasses":["mkkvzf","kmdcmf"],"link":{"type":"external","url":"#"}},"label":"CTA"},{"id":"byn
@wpeasy
wpeasy / rest-endpoint.php
Created March 29, 2024 02:44
Bricks Live Update Options
<?php
add_action('rest_api_init', 'wpe_register_live_options_rest_route');
function wpe_register_live_options_rest_route() {
register_rest_route('v1/wpe_live_options', '/get_options', array(
'methods' => 'GET',
'callback' => 'mb_live_options_get_options',
'permission_callback' => 'wpe_verify_referrer_hostname'
));