Transform Builder
ridiculous/transform-builderFreeComponent
Ridiculously typed CSS transform editor — a space-separated function list with compile-time function-name dispatch (per-function arity and per-argument dimension typing: rotate wants an angle, translateX a length-%). Ships a tolerant runtime parser and a live 3D-preview card driven by the typed string.
Install it
npx shadcn@latest add http://ridiculous.turtlesocks.dev/r/transform-builder.jsonSource
1"use client"23import { useEffect, useRef, useState } from "react"4import { Button } from "@/components/ui/button"5import {6 Popover,7 PopoverContent,8 PopoverTrigger,9} from "@/components/ui/popover"10import { cn } from "@/lib/utils"11import {12 AddFunctionMenu,13 ArgEditor,14 FunctionSelect,15} from "./transform-builder.arg-editor"16import {17 argSpec,18 defaultItem,19 formatTransform,20 itemArgs,21 itemFromArgs,22 parseTransform,23} from "./transform-builder.helpers"24import { TransformPreview3D } from "./transform-builder.preview"25import type {26 TransformFunctionName,27 TransformItem,28 TransformString,29} from "./transform-builder.types"3031export type {32 AddFunctionMenuProps,33 ArgEditorProps,34} from "./transform-builder.arg-editor"35// Re-export the controls and the preview so the public surface of this36// module is unchanged after the split (tests + index.ts import from here).37export {38 AddFunctionMenu,39 ArgEditor,40} from "./transform-builder.arg-editor"41export type { TransformPreview3DProps } from "./transform-builder.preview"42export { TransformPreview3D } from "./transform-builder.preview"4344// ---------------------------------------------------------------------------45// Shared props46// ---------------------------------------------------------------------------4748export interface TransformBuilderPanelProps {49 value: TransformString | (string & {})50 onChange: (value: TransformString) => void51 className?: string52 "aria-label"?: string53}5455export interface TransformBuilderProps extends TransformBuilderPanelProps {}5657// ---------------------------------------------------------------------------58// TransformBuilder — popover-wrapped59// ---------------------------------------------------------------------------6061export function TransformBuilder(props: TransformBuilderProps) {62 const {63 value,64 className,65 "aria-label": ariaLabel = "Edit a CSS transform",66 } = props67 const items = parseTransform(String(value)) ?? []6869 return (70 <Popover>71 <PopoverTrigger asChild>72 <Button73 variant="outline"74 className={cn("h-9 gap-2 px-3 font-mono", className)}75 aria-label={ariaLabel}76 >77 <span aria-hidden="true" className="text-foreground/60">78 ⤡79 </span>80 <span className="text-[10px] text-muted-foreground">81 {items.length} {items.length === 1 ? "fn" : "fns"}82 </span>83 <span className="max-w-[180px] truncate text-xs">{value}</span>84// … truncated
What it pulls in
Other registry items
Files it writes
More from ridiculous
All 22 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| All ridiculous componentsall | ridiculous | Components | Free | no deps | |
| Anchor Position Editoranchor-position-editor | ridiculous | Components | Free | no deps · 9 files | |
| Background Editorbackground-editor | ridiculous | Components | Free | no deps · 9 files | |
| Box Shadow Editorbox-shadow-editor | ridiculous | Components | Free | no deps · 7 files | |
| Calc Editorcalc-editor | ridiculous | Components | Free | no deps · 4 files | |
| Clip Path Editorclip-path-editor | ridiculous | Components | Free | no deps · 20 files | |
| Color Functioncolor-function | ridiculous | Components | Free | no deps · 10 files | |
| Color Pickercolor-picker | ridiculous | Components | Free | no deps · 11 files |
