({
path,
className,
align = 'center',
preview,
usingFramer,
...props
}: Omit<ComponentPreviewProps, 'usingCn'>)
| 206 | } |
| 207 | |
| 208 | function ComponentPreviewUsingCn({ |
| 209 | path, |
| 210 | className, |
| 211 | align = 'center', |
| 212 | preview, |
| 213 | usingFramer, |
| 214 | ...props |
| 215 | }: Omit<ComponentPreviewProps, 'usingCn'>) { |
| 216 | const name = formatName(path) |
| 217 | const nameWithoutSpace = name.replace(/\s/g, '') |
| 218 | |
| 219 | const Preview = React.useMemo(() => { |
| 220 | if (preview) return preview |
| 221 | |
| 222 | try { |
| 223 | const Component = require(`../../showcase/${path}.tsx`).default |
| 224 | return <Component /> |
| 225 | } catch (error) { |
| 226 | console.error(`Failed to load component ${path}:`, error) |
| 227 | return ( |
| 228 | <p className="text-muted-foreground text-sm"> |
| 229 | Component{' '} |
| 230 | <RawCode className="bg-muted relative rounded px-[0.3rem] py-[0.2rem] font-mono text-sm"> |
| 231 | {path} |
| 232 | </RawCode>{' '} |
| 233 | not found. |
| 234 | </p> |
| 235 | ) |
| 236 | } |
| 237 | }, [path, preview]) |
| 238 | |
| 239 | const codeString = React.useMemo(() => { |
| 240 | try { |
| 241 | const code = require(`!!raw-loader!../../showcase/${path}.tsx`).default |
| 242 | const filteredCode = code.replace(/'use client'\n/, '') |
| 243 | return filteredCode |
| 244 | } catch (error) { |
| 245 | console.error(`Failed to load code for component ${path}:`, error) |
| 246 | return null |
| 247 | } |
| 248 | }, [path]) |
| 249 | const cnString = React.useMemo(() => { |
| 250 | try { |
| 251 | return require(`!!raw-loader!../../lib/utils.ts`).default |
| 252 | } catch (error) { |
| 253 | console.error(`Failed to load code for the cn function:`, error) |
| 254 | return null |
| 255 | } |
| 256 | }, []) |
| 257 | |
| 258 | return ( |
| 259 | <div |
| 260 | className={cn( |
| 261 | 'group relative my-10 flex w-full max-w-5xl flex-col space-y-2', |
| 262 | className, |
| 263 | )} |
| 264 | {...props} |
| 265 | > |
nothing calls this directly
no test coverage detected