[UI design tips] (https://twitter.com/i/moments/994601867987619840)
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 gcd(a, b) { | |
return (b === 0) ? a : gcd(b, a % b); | |
} | |
function getAspectRatio(width, height) { | |
const r = gcd(width, height); | |
return `${width / r} : ${height / r}` | |
/* | |
return { | |
x: width / r, |
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
/** | |
* We use this workaround to detect the Chromecast device generation. | |
* Unfortunately the Cast Application Framework (CAF) does not have an API for that. | |
* | |
* cc-1: Chromecast 1st Gen. | |
* cc-2: Chromecast 2nd Gen. | |
* cc-3: Chromecast 3rd Gen. | |
* cc-ultra: Chromecast Ultra | |
* cc-builtin: Android TV with Chromecast built-in | |
* cc-googletv: Google TV with Chromecast |
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(XHR) { | |
"use strict"; | |
var stats = []; | |
var timeoutId = null; | |
var open = XHR.prototype.open; | |
var send = XHR.prototype.send; | |
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
export const countNumOfLines = (el) => (el ? Math.ceil(el.clientHeight / parseInt(getComputedStyle(el, null).getPropertyValue('line-height'))) : 0) |
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
.flexbox { | |
display: flex; | |
justify-content: space-between; | |
& > :only-child { | |
margin-left: auto; | |
margin-right: auto; | |
} | |
} |
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 uniqId = () => (Date.now() * Math.random()).toString(36) | |
// Generates uniqId as | |
// coyppu5a.lan | |
// b3v7gp76.lif | |
// If '.' wants to be removed remove then use replace or Math.ceil |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Custom mouse move cursor"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Custom mouse move cursor</title> | |
<style> | |
.cursor { | |
position: absolute; |
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 { useState, useCallback } from 'react' | |
export default function useForceUpdate() { | |
const [, dispatch] = useState({}) | |
return useCallback(() => dispatch({}), []) | |
} | |
/** | |
* Usage: | |
* |
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
var equalityCheck = function(a, b) { | |
if (typeof a === 'object' && typeof b === 'object') { | |
if (!compareObjects(a, b)) { | |
return false; | |
} | |
} else if (a !== b) { | |
return false; | |
} | |
return true; | |
}; |
NewerOlder