This gist contains various utility functions.
- getDomPath()
- getVisibleChildNodes()
- preventFocusOnClick()
- slideUp(), slideDown(), slideToggle()
- trapFocus(), focusTrap = {}
/* Use this file to set CSS variables & root properties */ | |
/* Import google font */ | |
@import url(''); | |
/* Set root variables */ | |
:root { | |
/* Body paragraph text (used for rem sizing) */ | |
font-size: 18px; |
/** | |
* Implements template_preprocess(). | |
*/ | |
function theme_preprocess(&$variables) { | |
/* Set variables to icon library */ | |
$variables['icons'] = '/themes/custom/THEME/assets/icons'; | |
$variables['brand_ico'] = '/themes/custom/THEME/assets/icons/brands.svg'; | |
$variables['light_ico'] = '/themes/custom/THEME/assets/icons/light.svg'; | |
$variables['regular_ico'] = '/themes/custom/THEME/assets/icons/regular.svg'; | |
$variables['solid_ico'] = '/themes/custom/THEME/assets/icons/solid.svg'; |
/* | |
* Merge attributes onto an image | |
* | |
* Note: Attributes must have at least one non-null value. | |
* If you don't have a value, enter an single-space string (' '). | |
*/ | |
{% for item in items %} | |
{{ item.content|merge({'#item_attributes': {'attribute-name': ['attribute', 'values', 'here']}}) }} | |
{% endfor %} |
## | |
# SSH COMMANDS | |
## | |
# SSH into AWS Server | |
ssh -i ~/KEY_LOCATION ubuntu@IP_OR_WEBSITE | |
# Copy files from server | |
# scp SOURCE DESTINATION | |
scp USER@SERVER:PATH ~/Desktop |
function getVisibleChildNodes(input) { | |
if (!input instanceof Node) { | |
return false; | |
} else { | |
const filteredNodes = | |
// Create array from child nodes | |
Array.from(input.childNodes) | |
// Remove comments |
This gist contains various utility functions.
<?php | |
/** | |
* Converts hex color strings to array of HSL values. | |
* Code based on JS version: https://css-tricks.com/converting-color-spaces-in-javascript/. | |
* Formula here: https://www.rapidtables.com/convert/color/rgb-to-hsl.html. | |
* | |
* @param string $hexString | |
* The 6-character hexadecimal color code, optionally with a leading hash | |
* |
const styleDiff = (elementOne, elementTwo) => { | |
const elOneStyles = window.getComputedStyle(elementOne); | |
const elTwoStyles = window.getComputedStyle(elementTwo); | |
const styleDiff = new Set(); | |
for (const prop in elOneStyles) { | |
if (elOneStyles[prop] !== elTwoStyles[prop]) { | |
styleDiff.add(`${prop}: ${elOneStyles[prop]} | ${elTwoStyles[prop]}`); | |
} | |
} |