Grid Builder
ridiculous/grid-builderFreeComponent
Ridiculously typed CSS grid-template editor for track lists and grid-template-areas across three modes, with TrackListLiteral validating the full track grammar and GridAreasLiteral checking quoting, equal column counts, and cell idents at the type level. Ships a live display:grid preview and a clickable areas painter.
Install it
npx shadcn@latest add http://ridiculous.turtlesocks.dev/r/grid-builder.jsonSource
1"use client"23import { useEffect, useMemo, 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 { AreasEditor } from "./areas-editor"12import { MODES } from "./grid-builder.constants"13import {14 formatAreas,15 formatTracks,16 parseAreas,17 parseTracks,18 type TrackToken,19} from "./grid-builder.helpers"20import type { GridMode, GridTemplateString } from "./grid-builder.types"21import { GridPreview } from "./grid-preview"22import { TrackListEditor } from "./track-list-editor"2324export type { AreasEditorProps, AreasPainterProps } from "./areas-editor"25// Re-export the sub-component public API so the entry module remains the26// single import surface (`./grid-builder`) for consumers + tests.27export { AreasEditor, AreasPainter } from "./areas-editor"28export type { GridPreviewProps } from "./grid-preview"29export { GridPreview } from "./grid-preview"30export type {31 TrackListEditorProps,32 TrackTokenRowProps,33} from "./track-list-editor"34export { TrackListEditor, TrackTokenRow } from "./track-list-editor"3536// ---------------------------------------------------------------------------37// Shared props38// ---------------------------------------------------------------------------3940export interface GridBuilderPanelProps {41 value: GridTemplateString | (string & {})42 onChange: (value: GridTemplateString) => void43 /**44 * Which template property the editor targets and the live preview renders.45 * `columns`/`rows` share the track-list grammar; `areas` is the painter.46 * This selects the active tab + preview target — it does not change47 * validation. Defaults to `"columns"`.48 */49 mode?: GridMode50 className?: string51 "aria-label"?: string52}5354export type GridBuilderProps = GridBuilderPanelProps5556// ---------------------------------------------------------------------------57// GridBuilder — popover-wrapped58// ---------------------------------------------------------------------------5960export function GridBuilder(props: GridBuilderProps) {61 const {62 value,63 className,64 mode = "columns",65 "aria-label": ariaLabel = "Edit a CSS grid template",66 } = props6768 return (69 <Popover>70 <PopoverTrigger asChild>71 <Button72 variant="outline"73 className={cn("h-9 gap-2 px-3 font-mono", className)}74 aria-label={ariaLabel}75 >76// … 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 |
