-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
588bfe3
commit 0fa0f26
Showing
15 changed files
with
293 additions
and
80 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
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 |
---|---|---|
|
@@ -28,4 +28,6 @@ export { | |
CaretCircleDown, | ||
Door, | ||
DoorOpen, | ||
List, | ||
GridFour, | ||
} from '@phosphor-icons/react'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { ObjectExplorer } from './explorer'; | ||
export { ObjectPreview } from './object-preview'; | ||
export { PreviewPane, TogglePreviewPaneButton } from './preview-pane'; | ||
export { ToggleGridViewButton } from './toggle-grid-view'; |
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 @@ | ||
'use client'; | ||
|
||
import { twMerge } from 'tailwind-merge'; | ||
import type { FileObject } from '@/utils'; | ||
import type { Row } from '@tanstack/react-table'; | ||
import { useObjectExplorer, useExplorerEvents } from '../providers'; | ||
import { ObjectPreviewInner } from './object-preview-inner'; | ||
|
||
type Props = { | ||
row: Row<FileObject>; | ||
handleClick: (e: React.MouseEvent<HTMLElement>, object: FileObject) => void; | ||
style: React.CSSProperties; | ||
previewSize: number; | ||
}; | ||
|
||
export const ObjectGridItem = ({ row, handleClick, style, previewSize }: Props): JSX.Element => { | ||
const { selectedObjects } = useObjectExplorer(); | ||
const { handleDoubleClick } = useExplorerEvents(); | ||
|
||
const object = row.original; | ||
const isSelected = selectedObjects.has(object.path); | ||
|
||
return ( | ||
<button | ||
className="flex flex-col justify-between truncate" | ||
type="button" | ||
onMouseDown={(e) => handleClick(e, object)} | ||
onDoubleClick={() => handleDoubleClick(object)} | ||
style={{ position: 'absolute', top: 0, left: 0, ...style }} | ||
> | ||
<div | ||
className="relative flex w-full items-center justify-center overflow-hidden rounded-md bg-secondary/30 dark:bg-secondary-dark/30" | ||
style={{ width: `${previewSize}px`, height: `${previewSize}px` }} | ||
> | ||
<ObjectPreviewInner path={object.path} type={object.getType()} /> | ||
</div> | ||
<span | ||
className={twMerge( | ||
'mx-auto max-w-full truncate text-sm font-semibold', | ||
'select-none rounded-md px-1 py-[0.0725rem]', | ||
'border-1 border-transparent', | ||
isSelected && | ||
'border-accent !bg-secondary dark:border-accent-dark dark:!bg-secondary-dark', | ||
)} | ||
title={object.getName()} | ||
> | ||
{object.getName()} | ||
</span> | ||
</button> | ||
); | ||
}; | ||
|
||
export type { Props as ObjectGridItemProps }; |
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.