-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
43 changed files
with
1,218 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// src/components/custom/CardList.tsx | ||
import * as React from 'react' | ||
import { cn } from '@/utils/cn' | ||
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card' | ||
|
||
type CardProps = { | ||
title?: string | ||
description?: string | ||
footer?: React.ReactNode | ||
headerRight?: React.ReactNode | ||
content?: React.ReactNode | ||
contentClassName?: string // Added contentClassName prop | ||
className?: string | ||
} | ||
|
||
type CardListProps = { | ||
cards: CardProps[] | ||
className?: string | ||
} | ||
|
||
export default function CardList({ cards, className }: CardListProps) { | ||
return ( | ||
<div className={cn('w-full space-y-4', className)}> | ||
{cards.map((card, index) => ( | ||
<Card key={index} className={cn('flex flex-col', card.className)}> | ||
{(card.title || card.description || card.headerRight) && ( | ||
<CardHeader> | ||
<div className='flex items-center justify-between'> | ||
{card.title && <CardTitle>{card.title}</CardTitle>} | ||
{card.headerRight && <div>{card.headerRight}</div>} | ||
</div> | ||
{card.description && <CardDescription>{card.description}</CardDescription>} | ||
</CardHeader> | ||
)} | ||
{card.content && <CardContent className={card.contentClassName}>{card.content}</CardContent>} | ||
{card.footer && <CardFooter>{card.footer}</CardFooter>} | ||
</Card> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// src/components/custom/PanelLayout.tsx | ||
import React from 'react' | ||
import { PanelNode, PanelNodeCreateInput, SplitDirectionEnum } from '@/graphql/generated/graphql' | ||
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable' | ||
import { cn } from '@/utils/cn' | ||
|
||
interface PanelLayoutProps { | ||
nodes: (PanelNodeCreateInput | PanelNode)[] | ||
rootNodeId: string | ||
renderContent: (node: PanelNodeCreateInput | PanelNode) => React.ReactNode | ||
showBorders?: boolean | ||
className?: string | ||
} | ||
|
||
export function PanelLayout({ nodes, rootNodeId, renderContent, showBorders = true, className }: PanelLayoutProps) { | ||
// Create a mapping from node IDs to nodes for quick access | ||
const nodeMap = React.useMemo(() => { | ||
const map: { [id: string]: PanelNodeCreateInput | PanelNode } = {} | ||
nodes.forEach(node => { | ||
if (node.id) { | ||
map[node.id] = node | ||
} | ||
}) | ||
return map | ||
}, [nodes]) | ||
|
||
const renderNode = ( | ||
nodeId: string, | ||
parentSplit: SplitDirectionEnum | null = null, | ||
position: 'first' | 'second' | null = null | ||
): React.ReactNode => { | ||
const node = nodeMap[nodeId] | ||
if (!node) return null | ||
|
||
if (node.split) { | ||
const direction = node.split === SplitDirectionEnum.Horizontal ? 'horizontal' : 'vertical' | ||
|
||
// Determine border classes based on position and showBorders prop | ||
let borderClasses = '' | ||
if (showBorders) { | ||
if (parentSplit === SplitDirectionEnum.Horizontal) { | ||
if (position === 'first') { | ||
borderClasses = 'border-r' | ||
} | ||
} else if (parentSplit === SplitDirectionEnum.Vertical) { | ||
if (position === 'first') { | ||
borderClasses = 'border-b' | ||
} | ||
} else { | ||
borderClasses = 'border' | ||
} | ||
} | ||
|
||
const firstChildNodeId = node.firstChildId | ||
const secondChildNodeId = node.secondChildId | ||
|
||
// Ensure ResizablePanelGroup and ResizablePanel have correct flex properties | ||
return ( | ||
<ResizablePanelGroup | ||
key={node.id} | ||
direction={direction} | ||
className={borderClasses} | ||
style={{ flex: 1, display: 'flex', flexDirection: direction === 'horizontal' ? 'row' : 'column' }} | ||
> | ||
<ResizablePanel style={{ flex: 1, display: 'flex' }}> | ||
{firstChildNodeId ? renderNode(firstChildNodeId, node.split, 'first') : null} | ||
</ResizablePanel> | ||
<ResizableHandle /> | ||
<ResizablePanel style={{ flex: 1, display: 'flex' }}> | ||
{secondChildNodeId ? renderNode(secondChildNodeId, node.split, 'second') : null} | ||
</ResizablePanel> | ||
</ResizablePanelGroup> | ||
) | ||
} else { | ||
// Leaf node | ||
let borderClasses = '' | ||
if (showBorders) { | ||
if (parentSplit === SplitDirectionEnum.Horizontal) { | ||
if (position === 'first') { | ||
borderClasses = 'border-r' | ||
} | ||
} else if (parentSplit === SplitDirectionEnum.Vertical) { | ||
if (position === 'first') { | ||
borderClasses = 'border-b' | ||
} | ||
} else { | ||
borderClasses = 'border' | ||
} | ||
} | ||
|
||
return ( | ||
<div | ||
key={node.id} | ||
className={cn(borderClasses, 'flex')} | ||
style={{ flex: 1, position: 'relative', display: 'flex', flexDirection: 'column' }} | ||
> | ||
{renderContent(node)} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
return ( | ||
<div className={cn('flex overflow-hidden', className)} style={{ flex: 1, position: 'relative' }}> | ||
{renderNode(rootNodeId)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.