This text is italic
This file contains hidden or 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
/** | |
* Smooth scroll animation | |
* @param {int} endX: destination x coordinate | |
* @param {int} endY: destination y coordinate | |
* @param {int} duration: animation duration in ms | |
*/ | |
function smoothScrollTo(endX, endY, duration) { | |
const startX = window.scrollX || window.pageXOffset; | |
const startY = window.scrollY || window.pageYOffset; | |
const distanceX = endX - startX; |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import Candidate from './Candidate.js'; | |
import Button from 'react-uikit-button'; | |
export default class CandidateList extends Component { | |
constructor(props) { | |
super(props); | |
this.handleClick = this.handleClick.bind(this) | |
} |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import CandidateList from './Views/CandidateList.js'; | |
import Candidate from './Views/Candidate.js'; | |
import fetch from 'isomorphic-fetch'; | |
import { Route, Switch } from "react-router-dom"; | |
class ParentComponent extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { |
A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.
Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.
This file contains hidden or 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 maximizeFontSize(elem, maxWidth, maxHeight, opt_dontChangeFontSize) { | |
var canBeBigger, | |
display = elem.style.display, | |
fontSize = elem.style.fontSize, | |
font = elem.style.font, | |
computedFont = window.getComputedStyle(elem, null).getPropertyValue('font'), | |
doc = elem.ownerDocument, | |
parentNode = elem.parentNode, | |
tempParent = doc.createElement('div'), | |
nextSibling = elem.nextSibling, |
This file contains hidden or 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 getVideoImage(path, secs, callback) { | |
var me = this, video = document.createElement('video'); | |
video.onloadedmetadata = function() { | |
if ('function' === typeof secs) { | |
secs = secs(this.duration); | |
} | |
this.currentTime = Math.min(Math.max(0, (secs < 0 ? this.duration : 0) + secs), this.duration); | |
}; | |
video.onseeked = function(e) { | |
var canvas = document.createElement('canvas'); |
I am moving this gist to a github repo so more people can contribute to it. Also, it makes it easier for me to version control.
Please go to - https://github.com/praveenpuglia/shadow-dom-in-depth for latest version of this document. Also, if you find the document useful, please shower your love, go ⭐️ it. :)
Heads Up! It's all about the V1 Spec.
In a nutshell, Shadow DOM enables local scoping for HTML & CSS.
This file contains hidden or 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
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
This file contains hidden or 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 filter = (fn, arr) => arr.reduce((newArr, item) => { | |
return fn(item) ? newArr.concat([item]) : newArr; | |
}, []); |