2023-06-26 04:30:15 +00:00
|
|
|
import { useState } from 'react'
|
|
|
|
|
import { Box, SpanBox } from '../../elements/LayoutPrimitives'
|
|
|
|
|
import { LibraryItemNode } from '../../../lib/networking/queries/useGetLibraryItemsQuery'
|
|
|
|
|
import { LinkedItemCardAction } from './CardTypes'
|
|
|
|
|
import { Button } from '../../elements/Button'
|
|
|
|
|
import { theme } from '../../tokens/stitches.config'
|
2024-02-26 06:44:58 +00:00
|
|
|
import { DotsThree, Share } from 'phosphor-react'
|
2023-06-26 04:30:15 +00:00
|
|
|
import { CardMenu } from '../CardMenu'
|
|
|
|
|
import { UserBasicData } from '../../../lib/networking/queries/useGetViewerQuery'
|
2023-08-01 04:31:12 +00:00
|
|
|
import { ArchiveIcon } from '../../elements/icons/ArchiveIcon'
|
|
|
|
|
import { NotebookIcon } from '../../elements/icons/NotebookIcon'
|
|
|
|
|
import { TrashIcon } from '../../elements/icons/TrashIcon'
|
|
|
|
|
import { LabelIcon } from '../../elements/icons/LabelIcon'
|
|
|
|
|
import { UnarchiveIcon } from '../../elements/icons/UnarchiveIcon'
|
2024-02-28 03:13:07 +00:00
|
|
|
import { BrowserIcon } from '../../elements/icons/BrowserIcon'
|
2023-06-26 04:30:15 +00:00
|
|
|
|
|
|
|
|
type LibraryHoverActionsProps = {
|
|
|
|
|
viewer: UserBasicData
|
|
|
|
|
|
|
|
|
|
isHovered: boolean
|
|
|
|
|
|
|
|
|
|
item: LibraryItemNode
|
|
|
|
|
handleAction: (action: LinkedItemCardAction) => void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const LibraryHoverActions = (props: LibraryHoverActionsProps) => {
|
|
|
|
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
|
|
|
|
|
|
|
|
return (
|
2023-06-26 07:38:28 +00:00
|
|
|
<Box
|
|
|
|
|
css={{
|
|
|
|
|
overflow: 'clip',
|
2023-06-26 06:26:05 +00:00
|
|
|
|
2023-06-26 07:38:28 +00:00
|
|
|
height: '33px',
|
2024-02-28 03:13:07 +00:00
|
|
|
width: '200px',
|
2023-06-26 07:38:28 +00:00
|
|
|
bg: '$thBackground',
|
|
|
|
|
display: 'flex',
|
2023-06-26 04:30:15 +00:00
|
|
|
|
2023-06-26 07:38:28 +00:00
|
|
|
pt: '0px',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
border: '1px solid $thBackground5',
|
|
|
|
|
borderRadius: '5px',
|
2023-06-26 04:30:15 +00:00
|
|
|
|
2023-06-26 07:38:28 +00:00
|
|
|
gap: '5px',
|
|
|
|
|
px: '5px',
|
2023-08-01 04:31:12 +00:00
|
|
|
visibility: props.isHovered || menuOpen ? 'visible' : 'hidden',
|
2023-06-26 07:38:28 +00:00
|
|
|
'&:hover': {
|
|
|
|
|
boxShadow:
|
|
|
|
|
'0 1px 3px 0 rgba(0, 0, 0, 0.1),0 1px 2px 0 rgba(0, 0, 0, 0.06);',
|
|
|
|
|
},
|
|
|
|
|
}}
|
2024-03-05 02:53:10 +00:00
|
|
|
onClick={(event) => {
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
}}
|
2023-06-26 07:38:28 +00:00
|
|
|
>
|
|
|
|
|
<Button
|
2023-11-01 07:16:05 +00:00
|
|
|
title="View notebook (t)"
|
2023-06-26 07:38:28 +00:00
|
|
|
style="hoverActionIcon"
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
props.handleAction('open-notebook')
|
|
|
|
|
event.preventDefault()
|
2023-08-04 14:25:14 +00:00
|
|
|
event.stopPropagation()
|
2023-06-26 07:38:28 +00:00
|
|
|
}}
|
2023-08-01 04:31:12 +00:00
|
|
|
css={{
|
|
|
|
|
visibility: props.isHovered || menuOpen ? 'visible' : 'hidden',
|
|
|
|
|
}}
|
2023-06-26 07:38:28 +00:00
|
|
|
>
|
2023-08-01 04:31:12 +00:00
|
|
|
<NotebookIcon
|
2023-08-01 09:44:21 +00:00
|
|
|
size={21}
|
2023-08-01 04:31:12 +00:00
|
|
|
color={theme.colors.thNotebookSubtle.toString()}
|
|
|
|
|
/>
|
2023-06-26 07:38:28 +00:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
2023-09-28 13:50:39 +00:00
|
|
|
title={props.item.isArchived ? 'Unarchive (e)' : 'Archive (e)'}
|
2023-06-26 07:38:28 +00:00
|
|
|
style="hoverActionIcon"
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
const action = props.item.isArchived ? 'unarchive' : 'archive'
|
|
|
|
|
props.handleAction(action)
|
|
|
|
|
event.preventDefault()
|
2023-08-04 14:25:14 +00:00
|
|
|
event.stopPropagation()
|
2023-06-26 04:30:15 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2023-06-26 07:38:28 +00:00
|
|
|
{props.item.isArchived ? (
|
2023-08-01 04:31:12 +00:00
|
|
|
<UnarchiveIcon
|
2023-08-01 09:44:21 +00:00
|
|
|
size={21}
|
2023-08-01 04:31:12 +00:00
|
|
|
color={theme.colors.thNotebookSubtle.toString()}
|
|
|
|
|
/>
|
2023-06-26 07:38:28 +00:00
|
|
|
) : (
|
2023-08-01 04:31:12 +00:00
|
|
|
<ArchiveIcon
|
2023-08-01 09:44:21 +00:00
|
|
|
size={21}
|
2023-06-26 04:30:15 +00:00
|
|
|
color={theme.colors.thNotebookSubtle.toString()}
|
|
|
|
|
/>
|
2023-06-26 07:38:28 +00:00
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
2023-08-01 09:44:21 +00:00
|
|
|
title="Remove (#)"
|
2023-06-26 07:38:28 +00:00
|
|
|
style="hoverActionIcon"
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
props.handleAction('delete')
|
|
|
|
|
event.preventDefault()
|
2023-08-04 14:25:14 +00:00
|
|
|
event.stopPropagation()
|
2023-06-26 07:38:28 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2023-08-01 09:44:21 +00:00
|
|
|
<TrashIcon size={21} color={theme.colors.thNotebookSubtle.toString()} />
|
2023-06-26 07:38:28 +00:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
2023-08-01 09:44:21 +00:00
|
|
|
title="Edit labels (l)"
|
2023-06-26 07:38:28 +00:00
|
|
|
style="hoverActionIcon"
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
props.handleAction('set-labels')
|
|
|
|
|
event.preventDefault()
|
2023-08-04 14:25:14 +00:00
|
|
|
event.stopPropagation()
|
2023-06-26 07:38:28 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2023-08-01 09:44:21 +00:00
|
|
|
<LabelIcon size={21} color={theme.colors.thNotebookSubtle.toString()} />
|
2023-06-26 07:38:28 +00:00
|
|
|
</Button>
|
2024-02-26 06:44:58 +00:00
|
|
|
<Button
|
|
|
|
|
title="Open original (o)"
|
|
|
|
|
style="hoverActionIcon"
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
props.handleAction('showOriginal')
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-02-28 03:13:07 +00:00
|
|
|
<BrowserIcon
|
|
|
|
|
size={21}
|
|
|
|
|
color={theme.colors.thNotebookSubtle.toString()}
|
|
|
|
|
/>
|
2024-02-26 06:44:58 +00:00
|
|
|
</Button>
|
2023-06-26 07:38:28 +00:00
|
|
|
<CardMenu
|
|
|
|
|
item={props.item}
|
|
|
|
|
viewer={props.viewer}
|
|
|
|
|
onOpenChange={(open) => setMenuOpen(open)}
|
|
|
|
|
actionHandler={props.handleAction}
|
|
|
|
|
triggerElement={
|
|
|
|
|
<SpanBox
|
|
|
|
|
css={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
pt: '2.5px',
|
|
|
|
|
height: '33px',
|
|
|
|
|
'&:hover': {
|
|
|
|
|
bg: '$grayBgHover',
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DotsThree
|
|
|
|
|
size={25}
|
|
|
|
|
weight="bold"
|
2023-06-26 04:30:15 +00:00
|
|
|
color={theme.colors.thNotebookSubtle.toString()}
|
|
|
|
|
/>
|
2023-06-26 07:38:28 +00:00
|
|
|
</SpanBox>
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-06-26 04:30:15 +00:00
|
|
|
</Box>
|
|
|
|
|
)
|
|
|
|
|
}
|