Skip to content

Instantly share code, notes, and snippets.

View azinasili's full-sized avatar
😎
Learning

Azin Asili azinasili

😎
Learning
View GitHub Profile
@azinasili
azinasili / collapse.js
Created January 7, 2019 11:11
Functions to enable animating collapsible sections
// Element in to expand/collapse needs to have `overflow: hidden` applied to it
/**
* Collapse element height
* @param {HTMLElement} element - Element to collapse
* @param {Number} [height=0] - Size of element height in pixels
*/
function collapseSection(element, height = 0) {
const sectionHeight = element.scrollHeight;
const elementTransition = element.style.transition;
@azinasili
azinasili / camelCase.js
Last active April 12, 2019 17:56
Takes a string and converts to camelCase
/**
* Convert string to camelCase.
* Function will remove `,`, `_`, `-`, and `' '` from string.
*
* Note: Function does not strip numeric characters.
* A string like `hello 1world` would return `hello1world`
*
* @example
* camelCase('hello world') // returns 'helloWorld'
*
@azinasili
azinasili / pascalCase.js
Created April 12, 2019 17:56
Takes a string and converts to pascalCase
/**
* Convert string to pascalCase.
* Function will remove `,`, `_`, `-`, and `' '` from string.
*
* Note: Function does not strip numeric characters.
* A string like `hello 1world` would return `Hello1world`
*
* @example
* pascalCase('hello world') // returns 'HelloWorld'
*