feat: view on xxx

This commit is contained in:
DIYgod
2022-08-06 14:09:59 +01:00
parent bad49bdce5
commit 00f7574645
8 changed files with 102 additions and 26 deletions
+2 -8
View File
@@ -12,6 +12,7 @@ import toast from "react-hot-toast"
import { EmptyState } from "../ui/EmptyState"
import type { Note } from "unidata.js"
import { useGetPagesBySite, useDeletePage } from "~/queries/page"
import { MoreIcon } from "~/components/icons/MoreIcon"
export const PagesManager: React.FC<{
isPost: boolean
@@ -205,14 +206,7 @@ export const PagesManager: React.FC<{
e.stopPropagation()
}}
>
<svg
className="w-5 h-5"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z" />
</svg>
<MoreIcon className="w-5 h-5" />
</button>
</Menu.Button>
<Menu.Items className="text-sm absolute z-20 right-0 bg-white shadow-modal rounded-lg overflow-hidden py-2 w-64">
+9
View File
@@ -0,0 +1,9 @@
import React from "react"
export const BlockchainIcon: React.FC<React.ComponentPropsWithoutRef<"svg">> = (
props
) => {
return (
<svg width="1em" height="1em" {...props} viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M128 320v286.208a106.666667 106.666667 0 1 0 106.965333 182.912l256.128 144.085333a42.666667 42.666667 0 0 0 41.813334 0l256.128-144.085333A106.666667 106.666667 0 1 0 896 606.208V320a42.666667 42.666667 0 0 0-21.76-37.205333l-256.085333-144.042667a106.666667 106.666667 0 0 0-212.309334 0L149.76 282.794667A42.666667 42.666667 0 0 0 128 320z m362.666667-170.666667a21.333333 21.333333 0 1 1 42.666666 0 21.333333 21.333333 0 0 1-42.666666 0zM469.333333 247.125333v91.050667l-106.837333 62.293333A42.666667 42.666667 0 0 0 341.333333 437.333333v113.92l-111.744 63.829334c-5.12-3.413333-10.538667-6.4-16.256-8.874667V344.96l219.904-123.733333c10.026667 11.008 22.314667 19.882667 36.096 25.898666z m341.333334 359.082667a106.325333 106.325333 0 0 0-16.256 8.874667L682.666667 551.253333v-113.92a42.666667 42.666667 0 0 0-21.162667-36.864L554.666667 338.176V247.125333c13.781333-6.016 26.069333-14.933333 36.096-25.856L810.666667 344.96v261.248z m-62.634667 80.64a107.946667 107.946667 0 0 0-0.853333 27.904L512 847.018667l-235.221333-132.266667a107.946667 107.946667 0 0 0-0.853334-27.861333l98.602667-56.32 115.968 67.626666a42.666667 42.666667 0 0 0 43.008 0l115.968-67.669333 98.56 56.32zM597.333333 461.866667v100.352l-85.333333 49.749333-85.333333-49.749333v-100.352l85.333333-49.749334 85.333333 49.749334zM170.666667 682.666667a21.333333 21.333333 0 1 0 0 42.666666 21.333333 21.333333 0 0 0 0-42.666666z m661.333333 21.333333a21.333333 21.333333 0 1 1 42.666667 0 21.333333 21.333333 0 0 1-42.666667 0z" p-id="1166"></path><path d="M512 128a21.333333 21.333333 0 1 0 0 42.666667 21.333333 21.333333 0 0 0 0-42.666667zM597.333333 562.176v-100.352l-85.333333-49.749333-85.333333 49.749333v100.352l85.333333 49.749333 85.333333-49.749333zM149.333333 704a21.333333 21.333333 0 1 1 42.666667 0 21.333333 21.333333 0 0 1-42.666667 0zM853.333333 682.666667a21.333333 21.333333 0 1 0 0 42.666666 21.333333 21.333333 0 0 0 0-42.666666z" p-id="1167"></path></svg>
)
}
-9
View File
@@ -1,9 +0,0 @@
import React from "react"
export const CrossbellIcon: React.FC<React.ComponentPropsWithoutRef<"svg">> = (
props
) => {
return (
<svg width="1em" height="1em" {...props} viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11148"><path d="M512 1024c70.64 0 127.94-57.3 127.94-128H384.06c0 70.7 57.3 128 127.94 128z m430.78-299.42c-38.64-41.52-110.94-103.98-110.94-308.58 0-155.4-108.96-279.8-255.88-310.32V64c0-35.34-28.64-64-63.96-64s-63.96 28.66-63.96 64v41.68C301.12 136.2 192.16 260.6 192.16 416c0 204.6-72.3 267.06-110.94 308.58-12 12.9-17.32 28.32-17.22 43.42 0.22 32.8 25.96 64 64.2 64h767.6c38.24 0 64-31.2 64.2-64 0.1-15.1-5.22-30.54-17.22-43.42z" p-id="11149"></path></svg>
)
}
+9
View File
@@ -0,0 +1,9 @@
import React from "react"
export const CrossbellIcon: React.FC<React.ComponentPropsWithoutRef<"svg">> = (
props
) => {
return (
<svg width="1em" height="1em" {...props} viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024c70.64 0 127.94-57.3 127.94-128H384.06c0 70.7 57.3 128 127.94 128z m430.78-299.42c-38.64-41.52-110.94-103.98-110.94-308.58 0-155.4-108.96-279.8-255.88-310.32V64c0-35.34-28.64-64-63.96-64s-63.96 28.66-63.96 64v41.68C301.12 136.2 192.16 260.6 192.16 416c0 204.6-72.3 267.06-110.94 308.58-12 12.9-17.32 28.32-17.22 43.42 0.22 32.8 25.96 64 64.2 64h767.6c38.24 0 64-31.2 64.2-64 0.1-15.1-5.22-30.54-17.22-43.42z"></path></svg>
)
}
+18
View File
@@ -0,0 +1,18 @@
import React from "react"
export const MoreIcon: React.FC<React.ComponentPropsWithoutRef<"svg">> = (
props
) => {
return (
<svg
{...props}
width="1em"
height="1em"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z" />
</svg>
)
}
+63 -8
View File
@@ -13,14 +13,17 @@ import { Button } from "../ui/Button"
import { UniLink } from "../ui/UniLink"
import { Profile } from "unidata.js"
import { ConnectButton } from "../common/ConnectButton"
import { RSS3Icon } from "../icons/RSS3"
import { CrossbellIcon } from "../icons/Crossbell"
import { useAccount } from "wagmi"
import unidata from "~/lib/unidata"
import { useEffect, useState } from "react"
import { Fragment, useEffect, useState } from "react"
import toast from "react-hot-toast"
import { useGetSubscription, useSubscribeToSite, useUnsubscribeFromSite } from "~/queries/site"
import { useConnectModal } from '@rainbow-me/rainbowkit';
import { Menu } from "@headlessui/react"
import { MoreIcon } from "~/components/icons/MoreIcon"
import { RSS3Icon } from "~/components/icons/RSS3Icon"
import { CrossbellIcon } from "~/components/icons/CrossbellIcon"
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
export type HeaderLinkType = {
icon?: React.ReactNode
@@ -59,6 +62,7 @@ export const SiteHeader: React.FC<{
const unsubscribeFromSite = useUnsubscribeFromSite()
const { openConnectModal } = useConnectModal()
const [followProgress, setFollowProgress] = useState<boolean>(false)
const router = useRouter()
const handleClickSubscribe = async () => {
if (!address) {
@@ -99,6 +103,24 @@ export const SiteHeader: React.FC<{
...(navigation || []),
]
const moreMenuItems = [
{
text: "View on Crossbell.io",
icon: <CrossbellIcon />,
url: `https://crossbell.kindjeff.com/@${site}`,
},
{
text: "View on RSS3",
icon: <RSS3Icon />,
url: `https://rss3.io/result?search=${address}`,
},
{
text: "View on blockchain explorer",
icon: <BlockchainIcon />,
url: `https://scan.crossbell.io/address/${address}/transactions`,
},
]
return (
<header className="border-b">
<div className="px-5 max-w-screen-md mx-auto">
@@ -123,16 +145,16 @@ export const SiteHeader: React.FC<{
size="sm"
variant="secondary"
onClick={handleClickSubscribe}
className="space-x-1 group"
className="space-x-1 group align-middle mr-2"
isLoading={unsubscribeFromSite.isLoading || subscribeToSite.isLoading}
>
<span className="pl-1">
<CrossbellIcon />
</span>
<span className="pr-1 group-hover:hidden">
<span className="pr-1 group-hover:hidden w-16">
Following
</span>
<span className="pr-1 hidden group-hover:block">
<span className="pr-1 hidden group-hover:block w-16">
Unfollow
</span>
</Button> :
@@ -141,7 +163,7 @@ export const SiteHeader: React.FC<{
size="sm"
variant="crossbell"
onClick={handleClickSubscribe}
className="space-x-1"
className="space-x-1 align-middle"
isLoading={unsubscribeFromSite.isLoading || subscribeToSite.isLoading || subscription.isLoading}
>
<span className="pl-1">
@@ -152,7 +174,40 @@ export const SiteHeader: React.FC<{
</span>
</Button>
}
<div className="relative inline-block align-middle h-7">
<Menu>
{() => (
<>
<Menu.Button as={Fragment}>
<Button
rounded="full"
size="sm"
variant="secondary"
onClick={(e) => {
e.stopPropagation()
}}
>
<MoreIcon className="w-5 h-5" />
</Button>
</Menu.Button>
<Menu.Items className="text-sm absolute z-20 left-0 top-8 bg-white shadow-modal rounded-lg overflow-hidden py-2 w-60 text-gray-500">
{moreMenuItems.map((item) => {
return (
<UniLink
key={item.text}
href={item.url}
className="h-10 flex w-full space-x-2 items-center px-3 hover:bg-gray-100"
>
<span className="fill-gray-500">{item.icon}</span>
<span>{item.text}</span>
</UniLink>
)
})}
</Menu.Items>
</>
)}
</Menu>
</div>
</div>
</div>
</div>
+1 -1
View File
@@ -69,7 +69,7 @@ body {
}
.button.is-secondary {
@apply bg-gray-50 hover:bg-gray-100 focus:bg-gray-200;
@apply bg-gray-50 hover:bg-gray-100;
@apply text-gray-500;
@apply fill-gray-500;
}