-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to paginateQuery and DRY log info metadata panel (#309)
- Loading branch information
1 parent
bcaf89c
commit 3eccea7
Showing
13 changed files
with
307 additions
and
165 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...Id]/versions/[commitUuid]/documents/[documentUuid]/_components/MetadataInfoTabs/index.tsx
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,53 @@ | ||
import { ReactNode, useRef, useState } from 'react' | ||
|
||
import { cn, TabSelector, TabSelectorOption } from '@latitude-data/web-ui' | ||
import useDynamicHeight from '$/hooks/useDynamicHeight' | ||
|
||
type RenderProps = { selectedTab: string } | ||
export function MetadataInfoTabs({ | ||
className, | ||
tabs = [ | ||
{ label: 'Metadata', value: 'metadata' }, | ||
{ label: 'Messages', value: 'messages' }, | ||
], | ||
children, | ||
beforeTabs, | ||
}: { | ||
children: (args: RenderProps) => ReactNode | ||
tabs?: TabSelectorOption<string>[] | ||
beforeTabs?: ReactNode | ||
className?: string | ||
}) { | ||
const [selectedTab, setSelectedTab] = useState<string>('metadata') | ||
const ref = useRef<HTMLDivElement>(null) | ||
const height = useDynamicHeight({ ref, paddingBottom: 16 }) | ||
return ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
'relative flex-shrink-0 flex flex-col', | ||
'border border-border rounded-lg items-center custom-scrollbar overflow-y-auto', | ||
className, | ||
)} | ||
style={{ | ||
maxHeight: height ? `${height}px` : 'auto', | ||
}} | ||
> | ||
<div className='z-10 w-full sticky top-0 px-4 bg-white flex justify-center'> | ||
<div className='pt-6'> | ||
<TabSelector | ||
options={tabs} | ||
selected={selectedTab} | ||
onSelect={setSelectedTab} | ||
/> | ||
</div> | ||
</div> | ||
<div className='my-5 px-4 flex flex-col gap-y-5 relative w-full'> | ||
{beforeTabs} | ||
<div className='flex flex-col gap-4 w-full'> | ||
{children({ selectedTab })} | ||
</div> | ||
</div> | ||
</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 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 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.