scph5500.bin 26-Aug-2018 20:47 512.0K
scph5501.bin 26-Aug-2018 20:47 512.0K
scph5502.bin 26-Aug-2018 20:47 512.0K
import {ChevronLeft, ChevronRight} from 'lucide-react'; | |
import {useEffect, useState} from 'react'; | |
export function Pagination({carousel}: {carousel: HTMLElement}) { | |
// Scroll by 1 page in the given direction (-1 or +1). | |
// This uses the width of the carousel minus the padding and gap between items. | |
// Use behavior: 'smooth' and the browser will animate the scrolling. | |
let scroll = (dir: number) => { | |
let style = window.getComputedStyle(carousel); | |
carousel.scrollBy({ |
import * as React from 'react' | |
import { SpringValue, easings, useSpring } from 'react-spring' | |
/** | |
* Hook that animates height when args.animationKey changes | |
* | |
* Ex: | |
* const animatedBlock = useAnimatedHeight({ | |
* animationKey: key, | |
* }) |
ing | |
er | |
a | |
ly | |
ed | |
i | |
es | |
re | |
tion | |
in |
// Adapted from https://gist.github.com/jakubriedl/812c2a7b26927a2249a4719555d9a0ca | |
import DataLoader from 'dataloader' | |
import { Exchange, Operation } from 'urql' | |
import { pipe, map } from 'wonka' | |
interface BatchRequest { | |
url: RequestInfo | string | |
options?: RequestInit | |
} |
scph5500.bin 26-Aug-2018 20:47 512.0K
scph5501.bin 26-Aug-2018 20:47 512.0K
scph5502.bin 26-Aug-2018 20:47 512.0K
import * as React from "react"; | |
import { useMousePosition } from "~/hooks/useMousePosition"; | |
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */ | |
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) { | |
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {}; | |
const [mouseX, mouseY] = useMousePosition(); | |
const positions = { x, y, h, w, mouseX, mouseY }; | |
return ( | |
<div |
/* A naively-implemented urql exchange for monitoring whether urql is fetching | |
* a query or a mutation on a global level. | |
* | |
* https://formidable.com/open-source/urql/docs/concepts/exchanges | |
* https://wonka.kitten.sh | |
* https://wonka.kitten.sh/api/operators#onpush | |
* | |
* Example usage: | |
* | |
* // If this number is greater than 0, an operation is in-flight and so urql is fetching |
Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.
This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would
With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.
This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async
+ await
.
That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:
Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):