This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateAttribute(element, name, newVal, oldVal = null) { | |
if (name[0] === 'o' && name[1] === 'n') { | |
name = name.slice(2).toLowerCase(); | |
if (newVal) { | |
element.addEventListener(name, newVal); | |
} | |
if (oldVal) { | |
element.removeEventListener(name, oldVal); | |
} | |
} else if (newVal == null || newVal === false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function callbackMiddlewareProxy(callback) { | |
const middleware = []; | |
const push = middleware.push.bind(middleware); | |
return new Proxy(callback, { | |
get: (target, prop) => { | |
if (prop === 'use') { | |
return push; | |
} | |
return target[prop]; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const msg = new SpeechSynthesisUtterance(); | |
msg.voiceURI = 'native'; | |
msg.text = 'Hello World'; | |
msg.lang = 'en-US'; | |
speechSynthesis.speak(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.shadow-light { | |
box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.23), 0 1.5px 6px rgba(0, 0, 0, 0.12); | |
} | |
.shadow-medium { | |
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.16); | |
} | |
.shadow-heavy { | |
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.23), 0 3px 12px rgba(0, 0, 0, 0.16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body:before { | |
content: ""; | |
position: fixed; | |
top: -10px; | |
left: 0; | |
width: 100%; | |
height: 10px; | |
box-shadow: 0px 0px 10px rgba(0,0,0,.5); | |
z-index:100; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.vr { | |
display: inline-block; | |
align-self: stretch; | |
width: 1px; | |
min-height: 1em; | |
background-color: currentcolor; | |
opacity: 0.25; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Courtesy of: https://www.24a11y.com/2018/accessible-svg-icons-with-inline-sprites/ */ | |
.svg-icon { | |
/* Place the icon on the text baseline. */ | |
position: relative; | |
top: .125em; | |
/* Prevent the icon from shrinking inside a flex container. */ | |
flex-shrink: 0; | |
/* Scale the icon to match the font-size. */ | |
height: 1em; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function supportsContainerQueries() { | |
return !!window.CSSContainerRule; | |
} | |
function supportsCustomPropertyDefinitions() { | |
return !!window.CSSPropertyRule; | |
} | |
function supportsScopedCSS() { | |
return !!window.CSSScopeRule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the IANA timezone | |
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | |
// My result | |
console.log(timezone); //=> "America/Toronto" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spec: https://wicg.github.io/ua-client-hints | |
// Support: https://caniuse.com/mdn-api_navigator_useragentdata | |
const isMobile = navigator.userAgentData.mobile; //=> true/false |