responsive-resizable-preview
domain-ui/responsive-resizable-previewFreeComponent
domain-ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/teurons/domain-ui/main/apps/web/public/r/responsive-resizable-preview.jsonSource
1"use client";2import { useState, useEffect, useRef, useMemo } from "react";3import type { ImperativePanelHandle } from "react-resizable-panels";4import {5 ResizableHandle,6 ResizablePanel,7 ResizablePanelGroup,8} from "@/components/ui/resizable";9import { defaultBreakpoints, getBreakpoint } from "./breakpoints";10import type { Breakpoint, BreakpointConfig } from "./breakpoints";11import { Toolbar, ScaleBar, Settings } from "./settings";12import { cn } from "@/lib/utils";1314// Types15export interface PreviewConfig {16 darkMode?: boolean;17 showToolbar?: boolean;18 showScale?: boolean;19 showLabels?: boolean;20}2122interface BasePreviewProps {23 className?: string;24 breakpoints?: BreakpointConfig[];25 config?: PreviewConfig;26}2728interface ResponsiveResizablePreviewProps extends BasePreviewProps {29 children?: React.ReactNode;30}3132interface RRChildPreviewProps extends BasePreviewProps {33 children?: React.ReactNode;34}3536interface RRIFramePreviewProps extends BasePreviewProps {37 srcUrl: string;38 height?: number;39}4041const defaultConfig = {42 darkMode: false,43 showToolbar: true,44 showScale: true,45 showLabels: true,46};4748// PreviewPanel component - the core resizable container49interface PreviewPanelProps {50 children: React.ReactNode;51 className?: string;52 panelRef: React.RefObject<ImperativePanelHandle | null>;53 contentRef: React.RefObject<HTMLDivElement | null>;54}5556function PreviewPanel({57 children,58 className,59 panelRef,60 contentRef,61}: PreviewPanelProps) {62 const [isHandleResizing, setIsHandleResizing] = useState(false);6364 const bgPattern = `url("data:image/svg+xml,%3Csvg width='6' height='6' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%239C92AC' fill-opacity='0.2' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E")`;6566 return (67 <ResizablePanelGroup68 direction="horizontal"69 className="!overflow-visible relative z-5 border-0 border-[#0000001f] bg-gray-300 bg-clip-padding dark:bg-gray-600"70 style={{ backgroundImage: bgPattern }}71 >72 <ResizablePanel73 ref={panelRef}74 className={cn(75 `border ${className}`,76 !isHandleResizing && "transition-all duration-200 ease-in-out"77 )}78 defaultSize={100}79 minSize={20}80 >81 <div ref={contentRef} className="@container">{children}</div>82 </ResizablePanel>83 <ResizableHandle84 withHandle85 className="z-50 w-0"86 onDragging={(e) => setIsHandleResizing(e)}87// … truncated
What it pulls in
Other registry items
Files it writes
More from domain-ui
All 16 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| pan-inputpan-input | domain-ui | Components | Free | no deps | |
| pan-input-incrementalpan-input-incremental | domain-ui | Components | Free | no deps | |
| passport-inputpassport-input | domain-ui | Components | Free | no deps | |
| passport-input-incrementalpassport-input-incremental | domain-ui | Components | Free | no deps | |
| phone-inputphone-input | domain-ui | Components | Free | 2 deps | |
| portfolio-chartportfolio-chart | domain-ui | Components | Free | no deps | |
| regex-inputregex-input | domain-ui | Components | Free | no deps · 2 files | |
| regex-input-incrementalregex-input-incremental | domain-ui | Components | Free | no deps · 5 files |
