Skip to content

Instantly share code, notes, and snippets.

View roginfarrer's full-sized avatar

Rogin Farrer roginfarrer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am roginfarrer on github.
  • I am rogin (https://keybase.io/rogin) on keybase.
  • I have a public key ASA0mmmYqPTABcJfn1b8sUGOzyxQLpVgya9rF8VVTcr7vAo

To claim this, I am signing this object:

Reach UI Philosophy

Reach UI is an accessible foundation for React applications and design systems.

The three equally important goals are to be:

  • Accessible
  • Composable
  • Stylable
@roginfarrer
roginfarrer / transformAliasProps.js
Created May 4, 2020 01:54
Support styled-system object breakpoints
const breakpoints = {
all: '_',
bp320: '320px',
bp480: '480px'
}
export const transformAliasProps = props => {
let result = {};
for (let prop in props) {
if (typeof props[prop] === "object" && !Array.isArray(props[prop])) {
////////////////////////////////////////////////////////////////////////////////
// Create a directory called "pages" next to
// this file, put markdown files in there, and
// then run:
//
// ```
// $ node build.mjs
// ```
//
// Then deploy the "build" directory somewhere.
@roginfarrer
roginfarrer / css-vars-system-props.js
Created January 16, 2021 20:40
CSS Vars with System Props
// Box takes in props that then assigns each responsive prop to the appropriate breakpoint
// Negates needing to update breakpoints based on theme within the styled-component
const Box = styled.div`
// base styles
@media screen and (min-width: ${props => props.breakpoints.breakpointOne}) {
// other styles
}
@media screen and (min-width: ${props => props.breakpoints.breakpointTwo}) {
@roginfarrer
roginfarrer / nestedGlobalStyle.ts
Last active July 2, 2024 13:04
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
@roginfarrer
roginfarrer / CHANGELOG.md
Created September 23, 2024 23:05
Design system changelog

Collage Changelog

Sep 23, 2024

Made button purple – DT-1234 via #123456 by Eliott Ruthersford

Sep 22, 2024

Created new FormInput component – DT-1234 via #123456 by Eliott Ruthersford

@roginfarrer
roginfarrer / useResizeObserver.ts
Created November 11, 2024 17:16
Reusable resize observer hook for React
import { useEffect } from "react";
/**
* Reusing a single instance of a ResizeObserver is better for performance
* than creating multiple instances. https://github.com/WICG/resize-observer/issues/59
*
* ReusableResizeObserver handles logic for collecting each observed entity
* and its associated callback
*
* @example
@roginfarrer
roginfarrer / file.ts
Created March 7, 2025 21:49
Web Component Props
// Props derived from custom element class. Currently has limitations of making
// all properties optional and also surfaces life cycle methods in autocomplete.
// TODO(augustjk) Consider omitting keyof LitElement to remove "internal"
// lifecycle methods or allow user to explicitly provide props.
type ElementProps<I> = Partial<Omit<I, keyof HTMLElement | "events">>;
type WebComponentProps<I extends HTMLElement> = React.DetailedHTMLProps<
React.HTMLAttributes<I>,
I
> &
@roginfarrer
roginfarrer / jsx-to-string.js
Last active March 20, 2025 23:28
jsx to string
function insert(propValue, key, value) {
return propValue != null ? `${key}="${value.toString()}"` : "";
}
function conditionalAttr(prop, value) {
return `{{#${prop}}}${prop}="${value}"{{/${prop}}}`;
}
export default function (babel) {
const { types: t } = babel;