diff --git a/commafeed-client/src/components/content/FeedEntryFooter.tsx b/commafeed-client/src/components/content/FeedEntryFooter.tsx
index 43bc603a..a0981f1b 100644
--- a/commafeed-client/src/components/content/FeedEntryFooter.tsx
+++ b/commafeed-client/src/components/content/FeedEntryFooter.tsx
@@ -14,14 +14,11 @@ interface FeedEntryFooterProps {
}
export function FeedEntryFooter(props: FeedEntryFooterProps) {
- const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
const tags = useAppSelector(state => state.user.tags)
const mobile = useMobile()
const { spacing } = useActionButton()
const dispatch = useAppDispatch()
- const showSharingButtons = sharingSettings && Object.values(sharingSettings).some(v => v)
-
const readStatusButtonClicked = async () =>
await dispatch(
markEntry({
@@ -60,16 +57,14 @@ export function FeedEntryFooter(props: FeedEntryFooterProps) {
}
/>
- {showSharingButtons && (
-
-
- } label={Share} />
-
-
-
-
-
- )}
+
+
+ } label={Share} />
+
+
+
+
+
{tags && (
diff --git a/commafeed-client/src/components/content/ShareButtons.tsx b/commafeed-client/src/components/content/ShareButtons.tsx
index 2f42cf76..aab66b37 100644
--- a/commafeed-client/src/components/content/ShareButtons.tsx
+++ b/commafeed-client/src/components/content/ShareButtons.tsx
@@ -1,8 +1,12 @@
-import { ActionIcon, Box, SimpleGrid } from "@mantine/core"
+import { Trans } from "@lingui/macro"
+import { ActionIcon, Box, CopyButton, Divider, SimpleGrid } from "@mantine/core"
import { Constants } from "app/constants"
import { useAppSelector } from "app/store"
import { type SharingSettings } from "app/types"
+import { useBrowserExtension } from "hooks/useBrowserExtension"
+import { useMobile } from "hooks/useMobile"
import { type IconType } from "react-icons"
+import { TbCheck, TbCopy, TbDeviceDesktopShare, TbDeviceMobileShare } from "react-icons/tb"
import { tss } from "tss"
type Color = `#${string}`
@@ -12,51 +16,98 @@ const useStyles = tss
color: Color
}>()
.create(({ theme, colorScheme, color }) => ({
- socialIcon: {
+ icon: {
color,
backgroundColor: colorScheme === "dark" ? theme.colors.gray[2] : "white",
- borderRadius: "50%",
},
}))
-function ShareButton({ url, icon, color }: { url: string; icon: IconType; color: Color }) {
+function ShareButton({ icon, color, onClick }: { icon: IconType; color: Color; onClick: () => void }) {
const { classes } = useStyles({
color,
})
- const onClick = (e: React.MouseEvent) => {
- e.preventDefault()
+ return (
+
+
+ {icon({ size: 18 })}
+
+
+ )
+}
+
+function SiteShareButton({ url, icon, color }: { icon: IconType; color: Color; url: string }) {
+ const onClick = () => {
window.open(url, "", "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=800,height=600")
}
+ return
+}
+
+function CopyUrlButton({ url }: { url: string }) {
return (
-
-
-
- {icon({ size: 18 })}
-
-
-
+
+ {({ copied, copy }) => }
+
+ )
+}
+
+function BrowserNativeShareButton({ url, description }: { url: string; description: string }) {
+ const mobile = useMobile()
+ const { isBrowserExtensionPopup } = useBrowserExtension()
+ const onClick = () => {
+ navigator.share({
+ title: description,
+ url,
+ })
+ }
+
+ return (
+
)
}
export function ShareButtons(props: { url: string; description: string }) {
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
+ const enabledSharingSites = (Object.keys(Constants.sharing) as (keyof SharingSettings)[]).filter(site => sharingSettings?.[site])
const url = encodeURIComponent(props.url)
const desc = encodeURIComponent(props.description)
+ const clipboardAvailable = typeof navigator.clipboard !== "undefined"
+ const nativeSharingAvailable = typeof navigator.share !== "undefined"
+ const showNativeSection = clipboardAvailable || nativeSharingAvailable
+ const showSharingSites = enabledSharingSites.length > 0
+ const showDivider = showNativeSection && showSharingSites
+ const showNoSharingOptionsAvailable = !showNativeSection && !showSharingSites
return (
-
- {(Object.keys(Constants.sharing) as (keyof SharingSettings)[])
- .filter(site => sharingSettings?.[site])
- .map(site => (
-
- ))}
-
+ <>
+ {showNativeSection && (
+
+ {clipboardAvailable && }
+ {nativeSharingAvailable && }
+
+ )}
+
+ {showDivider && }
+
+ {showSharingSites && (
+
+ {enabledSharingSites.map(site => (
+
+ ))}
+
+ )}
+
+ {showNoSharingOptionsAvailable && No sharing options available.}
+ >
)
}