This file contains 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 { useRouteData } from "remix-utils"; | |
import type { SerializeFrom } from "@remix-run/server-runtime"; | |
import type { loader } from "~/root"; | |
export let useRootData = () => | |
useRouteData<SerializeFrom<typeof loader>>("root"); |
This file contains 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
let removeInvalidSearchParams = ( | |
error: unknown, | |
request: Request, | |
prefix = "Unrecognized key(s) in object:" | |
) => { | |
let unrecongnizedKeysSchema = z.tuple([ | |
z.tuple([z.string().length(0), z.string().startsWith(prefix)]), | |
]); | |
let result = unrecongnizedKeysSchema.safeParse(formatError(error)); |
This file contains 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 type { FetcherWithComponents, FormProps } from "@remix-run/react"; | |
import type { ReactElement, ReactNode } from "react"; | |
import { Form } from "@remix-run/react"; | |
import { useHydrated } from "remix-utils"; | |
export let NoJS = ({ children }: { children: ReactElement }) => { | |
let isHydrated = useHydrated(); | |
if (!isHydrated) { |
This file contains 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 { | |
createPortal as createReactPortal, | |
unmountComponentAtNode, | |
} from "react-dom"; | |
import { useState, useCallback, useEffect } from "react"; | |
export let usePortal = (el: Element = document.body) => { | |
let [portal, setPortal] = useState<{ | |
render: Function; | |
remove: Function; |
This file contains 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 { AnimatePresence, usePresence } from "framer-motion"; | |
import { classNames } from "~/lib/utils/class-names"; | |
import { useCounter } from "@kyleshevlin/use-common"; | |
import { useCallback } from "react"; | |
const Box = ({ count }: { count: number }) => { | |
const [isPresent, safeToRemove] = usePresence(); | |
const onAnimationEnd = useCallback(() => { | |
if (!isPresent) safeToRemove(); |
This file contains 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
function useIsPendingPathname(to) { | |
let { location } = useTransition(); | |
let { pathname } = useResolvedPath(to); | |
return location?.pathname === pathname; | |
} | |
function useIsSlowTransition(ms = 300) { | |
let transition = useTransition(); | |
let [isSlow, setIsSlow] = useState(false); |
This file contains 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
// Menu: JA → EN | |
// Description: Translate selected text into with Google Translate. | |
// Author: Brandon Pittman | |
// Shortcut: ctrl j | |
import "@johnlindquist/kit"; | |
const origin = "https://translate.google.com"; | |
const text = await getSelectedText(); | |
const sl = "ja"; |
This file contains 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 clsx from 'clsx'; | |
import { differenceInWeeks } from 'date-fns'; | |
const fillIn = (complete: boolean) => | |
clsx( | |
complete ? 'bg-gray-300' : 'bg-transparent', | |
'h-1.5 w-1.5 border border-gray-300 rounded-full' | |
); | |
const weekCount = differenceInWeeks(new Date(), new Date('8/31/1983')); |
This file contains 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
#!/usr/bin/env node | |
const os = require("os"); | |
if (os.platform() !== "darwin") { | |
console.error("This script only works with macOS."); | |
process.exit(1); | |
} | |
const { spawn } = require("child_process"); |
This file contains 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
await $`mkdir example` | |
await cd('example') |
NewerOlder