Skip to content

Instantly share code, notes, and snippets.

View chrstntdd's full-sized avatar

Christian Todd chrstntdd

  • San Francisco, CA
View GitHub Profile
@chrstntdd
chrstntdd / nestedGlobalStyle.ts
Created June 18, 2022 19:48 — forked from roginfarrer/nestedGlobalStyle.ts
nested selectors for vanilla extract globalStyle
import { globalStyle, GlobalStyleRule } from "@vanilla-extract/css";
interface RecursiveGlobalStyle {
[k: string]: GlobalStyleRule | RecursiveGlobalStyle;
}
function globalUtil(selector: string, styles: RecursiveGlobalStyle) {
const write = (
key: string[],
value: RecursiveGlobalStyle | GlobalStyleRule
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
function load(key) {
inflight[key] = getPromise(key).then(val => {
delete inflight[key];
@chrstntdd
chrstntdd / Reveal.tsx
Created December 14, 2018 00:17
A react component that uses hooks to observe the element entering the viewport
import React from 'react'
interface Props {
children: React.ReactElement<any>
once?: boolean
onReveal: () => void
options?: { [key: string]: any }
}
export const Reveal = ({ children, once = false, onReveal, options = {} }: Props) => {
import React from 'react';
import PropTypes from 'prop-types';
SomeUi.propTypes = {
propA: PropTypes.string.isRequired,
propB: PropTypes.string
};
SomeUi.defaultProps = {
propB: "a default"
@chrstntdd
chrstntdd / link.elm
Last active May 10, 2018 12:20
Elm Link