feat: use @crossbell/notification
This commit is contained in:
+13
-12
@@ -22,14 +22,15 @@
|
||||
"@codemirror/language": "6.3.1",
|
||||
"@codemirror/state": "6.1.4",
|
||||
"@codemirror/view": "6.7.0",
|
||||
"@crossbell/connect-kit": "0.0.6",
|
||||
"@crossbell/contract": "0.0.6",
|
||||
"@crossbell/indexer": "0.0.6",
|
||||
"@crossbell/ui": "0.0.6",
|
||||
"@crossbell/util-ethers": "0.0.6",
|
||||
"@crossbell/util-hooks": "0.0.6",
|
||||
"@crossbell/util-ipfs": "0.0.6",
|
||||
"@crossbell/util-metadata": "0.0.6",
|
||||
"@crossbell/connect-kit": "0.0.7",
|
||||
"@crossbell/contract": "0.0.7",
|
||||
"@crossbell/indexer": "0.0.7",
|
||||
"@crossbell/notification": "^0.0.7",
|
||||
"@crossbell/ui": "0.0.7",
|
||||
"@crossbell/util-ethers": "0.0.7",
|
||||
"@crossbell/util-hooks": "0.0.7",
|
||||
"@crossbell/util-ipfs": "0.0.7",
|
||||
"@crossbell/util-metadata": "0.0.7",
|
||||
"@emoji-mart/data": "1.1.1",
|
||||
"@emoji-mart/react": "1.1.1",
|
||||
"@floating-ui/react-dom-interactions": "0.13.3",
|
||||
@@ -41,8 +42,8 @@
|
||||
"@tanstack/react-query": "4.22.0",
|
||||
"@tanstack/react-query-devtools": "4.22.0",
|
||||
"@tanstack/react-query-persist-client": "4.22.0",
|
||||
"@uiw/codemirror-extensions-events": "4.19.6",
|
||||
"@uiw/react-codemirror": "4.19.6",
|
||||
"@uiw/codemirror-extensions-events": "4.19.7",
|
||||
"@uiw/react-codemirror": "4.19.7",
|
||||
"@urql/core": "3.1.1",
|
||||
"axios": "1.2.2",
|
||||
"canvas-confetti": "^1.6.0",
|
||||
@@ -129,7 +130,7 @@
|
||||
"@unocss/preset-icons": "0.48.4",
|
||||
"autoprefixer": "10.4.13",
|
||||
"cross-spawn": "7.0.3",
|
||||
"esbuild": "0.17.1",
|
||||
"esbuild": "0.17.2",
|
||||
"esbuild-register": "3.4.2",
|
||||
"eslint": "8.32.0",
|
||||
"eslint-config-next": "13.1.2",
|
||||
@@ -140,7 +141,7 @@
|
||||
"tailwindcss": "3.2.4",
|
||||
"typescript": "4.9.4",
|
||||
"unocss": "0.48.4",
|
||||
"vitest": "0.27.1"
|
||||
"vitest": "0.27.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
|
||||
Generated
+357
-288
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,10 @@ import {
|
||||
import { BigNumber } from "ethers"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { useRefCallback } from "@crossbell/util-hooks"
|
||||
import {
|
||||
useShowNotificationModal,
|
||||
useNotifications,
|
||||
} from "@crossbell/notification"
|
||||
|
||||
export const ConnectButton: React.FC<{
|
||||
left?: boolean
|
||||
@@ -36,12 +40,26 @@ export const ConnectButton: React.FC<{
|
||||
|
||||
const userSites = useAccountSites()
|
||||
|
||||
const showNotificationModal = useShowNotificationModal()
|
||||
const { isAllRead } = useNotifications()
|
||||
|
||||
const dropdownLinks: HeaderLinkType[] = [
|
||||
{
|
||||
icon: <Square2StackIcon className="w-4 h-4" />,
|
||||
label: copyLabelDisplay,
|
||||
onClick: copyLabel,
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<span
|
||||
className={
|
||||
(isAllRead ? "i-bi:bell" : "i-bi:bell-fill") + " inline-block"
|
||||
}
|
||||
/>
|
||||
),
|
||||
label: isAllRead ? "Notifications" : "Unread notifications",
|
||||
onClick: showNotificationModal,
|
||||
},
|
||||
{
|
||||
icon: <DashboardIcon />,
|
||||
label: "Writer dashboard",
|
||||
@@ -155,7 +173,9 @@ export const ConnectButton: React.FC<{
|
||||
className="px-4 h-8 flex items-center w-full whitespace-nowrap hover:bg-zinc-100"
|
||||
aria-label={link.label}
|
||||
>
|
||||
<span className="mr-2">{link.icon}</span>
|
||||
<span className="mr-2 flex justify-center">
|
||||
{link.icon}
|
||||
</span>
|
||||
{link.label}
|
||||
</UniLink>
|
||||
)
|
||||
|
||||
@@ -15,6 +15,10 @@ import { useGetNotifications, useGetSite, useIsOperators } from "~/queries/site"
|
||||
import { getStorage } from "~/lib/storage"
|
||||
import { toGateway } from "~/lib/ipfs-parser"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import {
|
||||
useShowNotificationModal,
|
||||
useNotifications,
|
||||
} from "@crossbell/notification"
|
||||
|
||||
export function DashboardLayout({
|
||||
children,
|
||||
@@ -81,8 +85,12 @@ export function DashboardLayout({
|
||||
isOperator.data,
|
||||
])
|
||||
|
||||
const showNotificationModal = useShowNotificationModal()
|
||||
const { isAllRead } = useNotifications()
|
||||
|
||||
const links: {
|
||||
href: string
|
||||
href?: string
|
||||
onClick?: () => void
|
||||
isActive: (ctx: { href: string; pathname: string }) => boolean
|
||||
icon: React.ReactNode
|
||||
text: string
|
||||
@@ -106,12 +114,10 @@ export function DashboardLayout({
|
||||
text: "Pages",
|
||||
},
|
||||
{
|
||||
href: `/dashboard/${subdomain}/notifications`,
|
||||
onClick: showNotificationModal,
|
||||
isActive: ({ href, pathname }) => href === pathname,
|
||||
icon: notificationCount > 0 ? "i-bi:bell-fill" : "i-bi:bell",
|
||||
text:
|
||||
"Notifications" +
|
||||
(notificationCount > 0 ? ` (${notificationCount})` : ""),
|
||||
icon: isAllRead ? "i-bi:bell" : "i-bi:bell-fill",
|
||||
text: isAllRead ? "Notifications" : "Unread notifications",
|
||||
},
|
||||
{
|
||||
href: `/dashboard/${subdomain}/settings/general`,
|
||||
@@ -161,24 +167,27 @@ export function DashboardLayout({
|
||||
|
||||
<div className="px-3 space-y-[2px] text-zinc-500">
|
||||
{links.map((link) => {
|
||||
const active = link.isActive({
|
||||
pathname: router.asPath,
|
||||
href: link.href,
|
||||
})
|
||||
const active =
|
||||
link.href &&
|
||||
link.isActive({
|
||||
pathname: router.asPath,
|
||||
href: link.href,
|
||||
})
|
||||
return (
|
||||
<Link
|
||||
<UniLink
|
||||
href={link.href}
|
||||
key={link.href}
|
||||
className={clsx(
|
||||
`flex px-2 h-8 text-sm items-center rounded-lg space-x-2`,
|
||||
`flex px-2 h-8 text-sm items-center rounded-lg space-x-2 w-full`,
|
||||
active
|
||||
? `bg-gray-200 font-medium text-gray-800`
|
||||
: `hover:bg-gray-200 hover:bg-opacity-50`,
|
||||
)}
|
||||
onClick={link.onClick}
|
||||
>
|
||||
<span className={clsx(link.icon, "text-lg")}></span>
|
||||
<span>{link.text}</span>
|
||||
</Link>
|
||||
</UniLink>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,8 @@ import { toGateway } from "~/lib/ipfs-parser"
|
||||
import { connectors, provider } from "~/lib/wallet-config"
|
||||
import { createIDBPersister } from "~/lib/persister.client"
|
||||
|
||||
import { NotificationModal } from "@crossbell/notification"
|
||||
|
||||
Network.setIpfsGateway(IPFS_GATEWAY)
|
||||
|
||||
const wagmiClient = createClient({
|
||||
@@ -90,6 +92,7 @@ function MyApp({ Component, pageProps }: any) {
|
||||
/>
|
||||
{getLayout(<Component {...pageProps} />)}
|
||||
<Toaster />
|
||||
<NotificationModal />
|
||||
</Hydrate>
|
||||
</InitContractProvider>
|
||||
</ConnectKitProvider>
|
||||
|
||||
Reference in New Issue
Block a user