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 { css } from "styled-components"; | |
/** | |
* Represents an RGB color as a string in the format `rgb(${number},${number},${number})` | |
* or as a tuple of numbers `[number, number, number]`. | |
*/ | |
type RGB = `rgb(${number},${number},${number})` | [number, number, number]; | |
/** | |
* Props for the `ring` mixin. |
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
class HSLGenerator { | |
constructor(hueLength = 100, options = { lightness: 0.6, saturation: 1 }) { | |
this.hueIncrement = 360 / Math.sqrt(hueLength ** 2 * 2); | |
this.saturation = options.saturation * 100; | |
this.lightness = options.lightness * 100; | |
this.cache = {}; | |
} | |
getColor(y, x) { | |
const cacheKey = [y, x].join("-"); |
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 isInt = n => parseInt(n) === n; | |
const toPrecisionN = precision => value => | |
Number(value.toPrecision(precision)); | |
function multiplyInt(a, b) { | |
const iterable = [...Array(Math.abs(Math.floor(a)))]; | |
return iterable.reduce( | |
acc => a < 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
const isInt = n => parseInt(n) === n; | |
const toPrecisionN = precision => n => | |
Number((n).toPrecision(precision)); | |
function multiplyInt(a, b) { | |
const iterable = [...new Array(Math.abs(Math.floor(a)))]; | |
return iterable.reduce( | |
acc => a < 0 | |
? acc - b |
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
class Router { | |
routes = {} | |
baseUrl = "" | |
constructor(baseUrl) { | |
this.baseUrl = baseUrl | |
} | |
register = (method) => { |
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 charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
#app { | |
font-family: 'Courier' | |
} |
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 charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
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="grouping dynamically generated datasets"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.24.1/ramda.min.js"></script> |
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="a vanilla js + html & css analog clock"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<link href="https://fonts.googleapis.com/css?family=Share+Tech+Mono" rel="stylesheet"> | |
<style id="jsbin-css"> | |
body { |
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
class Observable { | |
constructor(value) { | |
this.value = value | |
this.events = { change: [] } | |
} | |
update(updateFn) { | |
this.value = updateFn(this.value) | |
this.events.change.forEach(fn => fn(this.value)) | |
} |
NewerOlder