Skip to content

Instantly share code, notes, and snippets.

@KevinSchildhorn
KevinSchildhorn / ButtonPrimary.kt
Last active March 9, 2023 09:53
Relay Compose Sample
/**
* Primary Button
*
* This composable was generated from the UI Package 'button_primary'.
* Generated code; do not edit directly
*/
@Composable
fun ButtonPrimary(
modifier: Modifier = Modifier,
onButtonPrimaryTapped: () -> Unit = {}
@jacob-ebey
jacob-ebey / api.chat.ts
Created May 8, 2022 22:20
Simple Remix SSE Chat Application on new fetch polyfill
import type { LoaderFunction } from "@remix-run/node";
import type { ChatMessageEvent } from "~/events.server";
import { chatEvents } from "~/events.server";
export let loader: LoaderFunction = ({ request }) => {
if (!request.signal) {
throw new Error("No request signal provided by the platform");
}
@jacob-ebey
jacob-ebey / image.ts
Last active February 29, 2024 05:25
Remix Image Component
import { createHash } from "crypto";
import fs from "fs";
import fsp from "fs/promises";
import path from "path";
import https from "https";
import { PassThrough } from "stream";
import type { Readable } from "stream";
import type { LoaderFunction } from "remix";
import sharp from "sharp";
import type { Request as NodeRequest } from "@remix-run/node";
@sergiodxa
sergiodxa / entry.server.tsx
Last active January 4, 2024 16:11
Dynamically generate a PDF with Remix
import { renderToStream } from "@react-pdf/renderer";
import ReactDOMServer from "react-dom/server";
import { EntryContext, Headers, RemixServer, Request, Response } from "remix";
import PDF, { loader } from "./pdfs/my-pdf.server";
async function handlePDFRequest(request: Request, headers: Headers) {
// get the data for the PDF
let response = await loader({ request, context: {}, params: {} });
// if it's a response return it, this means we redirected
if (response instanceof Response) return response;
@itsMapleLeaf
itsMapleLeaf / README.md
Last active July 10, 2023 18:18
Typed remix helpers

This is no longer needed! Remix's built-in types have improved significantly. But I'll keep this here for historical reasons.


Typed helpers for low-boilerplate type inference with Remix data.

  • I suffix them with *Typed so I don't accidentally import the core remix helpers.
  • This doesn't support regular Response objects to prevent accidentally using them with the typed helpers.
import type {
ActionFunction,
LinksFunction,
LoaderFunction,
MetaFunction
} from "@remix-run/react";
import {
Meta,
Links,
Scripts,
@steveruizok
steveruizok / example.tsx
Last active December 2, 2020 03:48
A utility function for getting the type-asserted value of a ref in React.
import * as React from "react"
import { getRef } from "./getRef"
export default function App() {
const rCanvas = React.useRef<HTMLCanvasElement>(null)
React.useEffect(() => {
const canvas = getRef(rCanvas)
canvas.width = window.innerWidth
canvas.width = window.innerHeight
@addisonschultz
addisonschultz / useScript.tsx
Last active October 28, 2023 10:02
A React hook that lets you add script tags to a component. Useful when needing to load scripts for components in Framer X.
import * as React from "react"
import { useState, useEffect } from "react"
// Hook
let cachedScripts = []
export function useScript(src) {
// Keeping track of script loaded and error state
const [state, setState] = useState({
loaded: false,

Index Pages on Uniform.hudl.com

We built the new documentation site for Uniform using Gatsby. In the past, we'd used Jekyll for our documentation. Ultimately, we decided this technology change made sense for a variety of reasons

  • No more Ruby Gems! As more hands, with varying degrees of technical ability, touched our documentation, we kept running various pain points of using a ruby based site generator. We wanted to choose a solution that had a lower overhead to get up and running, as well as something that was more in our wheelhouse when it came to troubleshooting. Gatsby's tech stack was closer to the tech stack of the design system, overall

  • Dogfooding our React components. One of the limitations of Jekyll was there wasn't a great way to leverage our React components to help us build the documentation. I'd done some experimentation, using an in-browser transpiler that enabled me to re-create a documentation page for Buttons, but this wasn't going to be a tenable solution

#!/bin/bash
docker run --rm --name test-container -v $(pwd):/home/circleci/codesandbox-client -w /home/circleci/codesandbox-client -d -t codesandbox/node-puppeteer yarn start:test && \
sleep 6 && docker exec -it test-container yarn test:integrations && \
docker stop test-container