Code Accordion
framecn/code-accordionFreeComponent
A code window that springs a range of lines closed and replaces them with a "N lines collapsed" placeholder.
Install it
npx shadcn@latest add https://framecn.dev/r/code-accordion.jsonSource
1"use client";23import { Timegroup } from "@editframe/react";4import type { CSSProperties } from "react";56const FONT_MONO =7 "var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace";89const DEFAULT_LINES = [10 "export function processOrders(orders) {",11 " const valid = [];",12 " for (const order of orders) {",13 " if (!order.id) continue;",14 " if (!order.customer) continue;",15 " if (!order.items?.length) continue;",16 " if (order.total <= 0) continue;",17 " if (order.status === 'cancelled') continue;",18 " if (order.status === 'refunded') continue;",19 " const enriched = enrich(order);",20 " const validated = validate(enriched);",21 " if (!validated.ok) continue;",22 " const priced = price(validated.value);",23 " const taxed = applyTax(priced);",24 " const shipped = applyShipping(taxed);",25 " valid.push(shipped);",26 " }",27 " return valid;",28 "}",29];3031export interface CodeAccordionProps {32 lines?: string[];33 collapseRange?: [number, number];34 collapseAt?: number;35 title?: string;36 fontSize?: number;37 width?: number;38 background?: string;39 cardColor?: string;40 textColor?: string;41 mutedColor?: string;42 speed?: number;43 fps?: number;44 durationInFrames?: number;45 height?: number;46 className?: string;47}4849const Light = ({ color }: { color: string }) => (50 <div51 style={{52 background: color,53 borderRadius: "50%",54 height: 11,55 opacity: 0.6,56 width: 11,57 }}58 />59);6061const Line = ({62 line,63 index,64 lineHeight,65 textColor,66 mutedColor,67}: {68 line: string;69 index: number;70 lineHeight: number;71 textColor: string;72 mutedColor: string;73}) => (74 <div75 style={{76 alignItems: "center",77 color: textColor,78 display: "flex",79 height: lineHeight,80 whiteSpace: "pre",81 }}82 >83 <span84 style={{85 color: mutedColor,86 paddingRight: 16,87 textAlign: "right",88 userSelect: "none",89 width: 56,90 }}91 >92 {index + 1}93 </span>94 <span>{line}</span>95 </div>96);9798export const CodeAccordion = ({99 lines = DEFAULT_LINES,100 collapseRange = [3, 14],101 collapseAt = 30,102 title = "process-orders.ts",103 fontSize = 16,104 width = 720,105 background = "#050505",106 cardColor = "#0a0a0a",107 textColor = "#e4e4e7",108 mutedColor = "#52525b",109 speed = 1,110 fps = 30,111 durationInFrames = 150,112 height = 720,113 className,114}: CodeAccordionProps) => {115 const safeSpeed = Math.max(0.01, speed);116// … truncated
What it pulls in
npm packages
Files it writes
More from framecn
All 101 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Generate Overlayai-generate-overlay | framecn | Components | Free | 1 dep | |
| AI Generation Canvasai-generation-canvas | framecn | Components | Free | 1 dep | |
| Animated Bar Chartanimated-bar-chart | framecn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | framecn | Components | Free | 1 dep | |
| Backdropbackdrop | framecn | Components | Free | 1 dep | |
| Blur Out Upblur-out-up | framecn | Components | Free | 1 dep | |
| Blur Revealblur-reveal | framecn | Components | Free | 1 dep | |
| Bounding Box Selectorbounding-box-selector | framecn | Components | Free | 1 dep |
