|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { AlertTriangle, Info, Lightbulb } from "lucide-react"; |
| 4 | +import type React from "react"; |
| 5 | + |
| 6 | +interface CheatSheetSectionProps { |
| 7 | + title: string; |
| 8 | + icon: string; |
| 9 | + color: |
| 10 | + | "red" |
| 11 | + | "orange" |
| 12 | + | "purple" |
| 13 | + | "blue" |
| 14 | + | "green" |
| 15 | + | "cyan" |
| 16 | + | "pink" |
| 17 | + | "yellow"; |
| 18 | + children: React.ReactNode; |
| 19 | +} |
| 20 | + |
| 21 | +const colorClasses = { |
| 22 | + red: "bg-red-500/10 border-red-500/20 dark:bg-red-500/10 dark:border-red-400/30", |
| 23 | + orange: |
| 24 | + "bg-orange-500/10 border-orange-500/20 dark:bg-orange-500/10 dark:border-orange-400/30", |
| 25 | + purple: |
| 26 | + "bg-purple-500/10 border-purple-500/20 dark:bg-purple-500/10 dark:border-purple-400/30", |
| 27 | + blue: "bg-blue-500/10 border-blue-500/20 dark:bg-blue-500/10 dark:border-blue-400/30", |
| 28 | + green: |
| 29 | + "bg-green-500/10 border-green-500/20 dark:bg-green-500/10 dark:border-green-400/30", |
| 30 | + cyan: "bg-cyan-500/10 border-cyan-500/20 dark:bg-cyan-500/10 dark:border-cyan-400/30", |
| 31 | + pink: "bg-pink-500/10 border-pink-500/20 dark:bg-pink-500/10 dark:border-pink-400/30", |
| 32 | + yellow: |
| 33 | + "bg-yellow-500/10 border-yellow-500/20 dark:bg-yellow-500/10 dark:border-yellow-400/30", |
| 34 | +}; |
| 35 | + |
| 36 | +const headerColorClasses = { |
| 37 | + red: "bg-red-500 text-white", |
| 38 | + orange: "bg-orange-500 text-white", |
| 39 | + purple: "bg-purple-500 text-white", |
| 40 | + blue: "bg-blue-500 text-white", |
| 41 | + green: "bg-green-500 text-white", |
| 42 | + cyan: "bg-cyan-500 text-white", |
| 43 | + pink: "bg-pink-500 text-white", |
| 44 | + yellow: "bg-yellow-500 text-black", |
| 45 | +}; |
| 46 | + |
| 47 | +export function CheatSheetSection({ |
| 48 | + title, |
| 49 | + icon, |
| 50 | + color, |
| 51 | + children, |
| 52 | +}: CheatSheetSectionProps) { |
| 53 | + return ( |
| 54 | + <div |
| 55 | + className={`cheat-sheet-section rounded-lg border ${colorClasses[color]} overflow-hidden print:break-inside-avoid print:border-gray-300 print:text-[6pt]`} |
| 56 | + > |
| 57 | + <div |
| 58 | + className={`px-4 py-2 font-semibold text-sm ${headerColorClasses[color]} print:!bg-gray-100 print:!text-black print:!text-[7pt] print:!py-[3pt] print:!px-[4pt]`} |
| 59 | + > |
| 60 | + <span className="mr-2">{icon}</span> |
| 61 | + {title} |
| 62 | + </div> |
| 63 | + <div className="print:!p-[4pt] print:!text-[6pt] print:!space-y-[2pt] space-y-3 p-4 text-sm"> |
| 64 | + {children} |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + ); |
| 68 | +} |
| 69 | + |
| 70 | +export function CheatSheetGrid({ |
| 71 | + children, |
| 72 | + pageNumber, |
| 73 | +}: { |
| 74 | + children: React.ReactNode; |
| 75 | + pageNumber?: number; |
| 76 | +}) { |
| 77 | + const pageClass = pageNumber ? `cheat-sheet-page-${pageNumber}` : ""; |
| 78 | + return ( |
| 79 | + <div |
| 80 | + className={`cheat-sheet-grid ${pageClass} grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 print:grid-cols-5 print:gap-2`} |
| 81 | + > |
| 82 | + {children} |
| 83 | + </div> |
| 84 | + ); |
| 85 | +} |
| 86 | + |
| 87 | +export function CommandBlock({ children }: { children: React.ReactNode }) { |
| 88 | + return ( |
| 89 | + <pre className="print:!bg-gray-100 print:!border-0 print:!p-[2pt] print:!text-[5.5pt] overflow-auto whitespace-pre rounded border border-gray-200 bg-black/5 p-2 font-mono text-xs dark:border-gray-700 dark:bg-white/5"> |
| 90 | + {children} |
| 91 | + </pre> |
| 92 | + ); |
| 93 | +} |
| 94 | + |
| 95 | +export function CommandList({ children }: { children: React.ReactNode }) { |
| 96 | + return <div className="space-y-2">{children}</div>; |
| 97 | +} |
| 98 | + |
| 99 | +export function CommandItem({ |
| 100 | + command, |
| 101 | + description, |
| 102 | +}: { |
| 103 | + command: string; |
| 104 | + description?: string; |
| 105 | +}) { |
| 106 | + return ( |
| 107 | + <div className="print:!space-y-[1pt] space-y-1"> |
| 108 | + <code className="print:!bg-gray-100 print:!border-0 print:!px-[2pt] print:!py-[1pt] print:!text-[5.5pt] block rounded bg-black/5 px-2 py-1 font-mono text-xs dark:bg-white/5"> |
| 109 | + {command} |
| 110 | + </code> |
| 111 | + {description && ( |
| 112 | + <div className="print:!text-gray-600 print:!text-[5pt] print:!pl-[2pt] pl-2 text-gray-600 text-xs dark:text-gray-400"> |
| 113 | + {description} |
| 114 | + </div> |
| 115 | + )} |
| 116 | + </div> |
| 117 | + ); |
| 118 | +} |
| 119 | + |
| 120 | +export function InfoBox({ |
| 121 | + type = "tip", |
| 122 | + children, |
| 123 | +}: { |
| 124 | + type?: "tip" | "note" | "warning"; |
| 125 | + children: React.ReactNode; |
| 126 | +}) { |
| 127 | + const styles = { |
| 128 | + tip: "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800 text-green-800 dark:text-green-200", |
| 129 | + note: "bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800 text-blue-800 dark:text-blue-200", |
| 130 | + warning: |
| 131 | + "bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800 text-yellow-800 dark:text-yellow-200", |
| 132 | + }; |
| 133 | + |
| 134 | + const icons = { |
| 135 | + tip: Lightbulb, |
| 136 | + note: Info, |
| 137 | + warning: AlertTriangle, |
| 138 | + }; |
| 139 | + |
| 140 | + const Icon = icons[type]; |
| 141 | + |
| 142 | + return ( |
| 143 | + <div |
| 144 | + className={`rounded border p-2 text-xs ${styles[type]} print:!bg-gray-50 print:!text-black print:!border-gray-300 print:!text-[5.5pt] print:!p-[2pt] flex items-start gap-1.5`} |
| 145 | + > |
| 146 | + <Icon className="print:!h-[8pt] print:!w-[8pt] h-3 w-3 flex-shrink-0" /> |
| 147 | + <span className="flex-1">{children}</span> |
| 148 | + </div> |
| 149 | + ); |
| 150 | +} |
0 commit comments