Skip to content

Instantly share code, notes, and snippets.

View gdibble's full-sized avatar
🤩
Optimistic

Gabriel Dibble gdibble

🤩
Optimistic
View GitHub Profile
/** replaceJSX
* RegExp search text and replace with JSX
* @see https://stackoverflow.com/a/63647844
* @param {string} str
* @param {RegExp} find
* @param {JSX} replace
* @returns {JSX}
*/
export default function replaceJSX(str, find, replace) {
const parts = str.split(find);
@gdibble
gdibble / CloseConfirm.module.scss
Created March 10, 2022 23:54
CSS x to check animation
/** CloseConfirm.module.scss - Animated x → ✓
* @see https://codepen.io/gdibble/pen/LYePYXL
* @example <button className={styles.CloseConfirm} type="button" onClick={someFn}><div className="check"> </div></button>
*/
$SkyBlue100: #08b2e3;
.CloseConfirm {
position: absolute;
top: 0.25em;
@gdibble
gdibble / isMobile.const.js
Created March 11, 2022 00:07
Mobile Device Feature Detection (Works in Chrome + Safari as of 2022-02-07)
/** isMobile - Feature Detection of an actual mobile device
* @description The localStorage.mobile works in Chrome mobile; the latter works in Safari mobile.
* Does not trigger desktop browsers with or w/o the dev-tools open and/or on a mobile simulator.
* @see https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser/71030087#71030087
*/
const isMobile = localStorage.mobile || window.navigator.maxTouchPoints > 1;