Add hover bg for apollo, implement share

This commit is contained in:
Jackson Harper 2024-06-21 15:31:57 +08:00
parent bc934a4706
commit b39bffdc1a
3 changed files with 30 additions and 5 deletions

View file

@ -542,7 +542,7 @@ const JustAddedItemView = (props: HomeItemViewProps): JSX.Element => {
bg: '$homeCardHover',
borderRadius: '5px',
'&:hover': {
bg: '$homeCardHover',
bg: '#007AFF10',
},
'&:hover .title-text': {
textDecoration: 'underline',
@ -584,7 +584,8 @@ const TopPicksItemView = (
props: HomeItemViewProps & TopPicksItemViewProps
): JSX.Element => {
const router = useRouter()
const { archiveItem, deleteItem, moveItem } = useLibraryItemActions()
const { archiveItem, deleteItem, moveItem, shareItem } =
useLibraryItemActions()
return (
<VStack
@ -724,9 +725,11 @@ const TopPicksItemView = (
{props.homeItem.canShare && (
<Button
style="homeAction"
onClick={(event) => {
onClick={async (event) => {
event.preventDefault()
event.stopPropagation()
await shareItem(props.homeItem.title, props.homeItem.url)
}}
>
<ShareActionIcon color={theme.colors.homeActionIcons.toString()} />

View file

@ -431,7 +431,7 @@ const apolloThemeSpec = {
homeCardHover: '#525252',
homeDivider: '#6A6968',
homeActionHoverBg: '#515151',
homeActionHoverBg: '#474747',
thBackground: '#474747',
thBackground2: '#515151',

View file

@ -65,5 +65,27 @@ export default function useLibraryItemActions() {
return !!result
}, [])
return { archiveItem, deleteItem, moveItem }
const shareItem = useCallback(
async (title: string, originalArticleUrl: string | undefined) => {
if (!originalArticleUrl) {
showErrorToast('Article has no public URL to share', {
position: 'bottom-right',
})
} else if (navigator.share) {
navigator.share({
title: title + '\n',
text: title + '\n',
url: originalArticleUrl,
})
} else {
await navigator.clipboard.writeText(originalArticleUrl)
showSuccessToast('URL copied to clipboard', {
position: 'bottom-right',
})
}
},
[]
)
return { archiveItem, deleteItem, moveItem, shareItem }
}