Rotating text for long-running pending buttons
const STOP_TEXTS = [
"Closing Positions",
"Canceling Orders",
"Finalizing Trades",
"Updating Balances",| import type { HTMLAttributes } from "react"; | |
| import { cn } from "@/lib/cn"; | |
| // Example: <LayerCard><LayerCardSecondary>Title</LayerCardSecondary><LayerCardContent>Content</LayerCardContent></LayerCard> | |
| export function LayerCard({ className, ...props }: HTMLAttributes<HTMLDivElement>) { | |
| return ( | |
| <div | |
| className={cn( | |
| "rounded-lg border border-neutral-200 bg-neutral-100", | |
| className, |
An ergonomic wrapper for react-query's useMutationState
export function useCreatePostMutation(...) {
return useMutation({ mutationKey: ['create-post'], ... })
}
export function useCreatePostMutationState(...) {Latches a boolean flag for a short duration, then resets to false
Useful for when an action succeeds, then you want to reset back to normal after a short while
User completes swapping X to Y: temporarily show "Success" then allow user to interact with the form again
const { mutate, status } = useMutation(...)| // Bn -> Float multiplication works like this: 150e6 * (0.5 * 100) / 100 | |
| // Also does some coercions for readability | |
| const multiplyBnToFloat = (a: string, b: string) => { | |
| return (BigInt(a) * BigInt(Number(b) * 100)) / BigInt(100) | |
| } | |
| // 75000000 | |
| multiplyBnToFloat('150000000', '0.5000000000') |
| { | |
| "React Component": { | |
| "prefix": "0rc", | |
| "body": [ | |
| "import React from 'react';", | |
| "", | |
| "interface ${TM_FILENAME_BASE}Props {", | |
| " name: string;", | |
| "}", | |
| "", |