feat: patron button and modal
This commit is contained in:
@@ -14,8 +14,17 @@ export const CharacterCard: React.FC<{
|
||||
open?: boolean
|
||||
setButtonLoading?: (loading: boolean) => void
|
||||
hideFollowButton?: boolean
|
||||
simple?: boolean
|
||||
style?: "flat" | "normal"
|
||||
}> = ({ siteId, address, open, setButtonLoading, hideFollowButton, style }) => {
|
||||
}> = ({
|
||||
siteId,
|
||||
address,
|
||||
open,
|
||||
setButtonLoading,
|
||||
hideFollowButton,
|
||||
simple,
|
||||
style,
|
||||
}) => {
|
||||
const [firstOpen, setFirstOpen] = useState("")
|
||||
const [site, setSite] = useState<Profile>()
|
||||
const date = useDate()
|
||||
@@ -41,8 +50,9 @@ export const CharacterCard: React.FC<{
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"border-gray-100 rounded-lg space-y-2 text-sm block",
|
||||
"border-gray-100 rounded-lg text-sm block",
|
||||
style === "flat" ? "" : "p-4 bg-white shadow-xl",
|
||||
simple ? "space-y-1" : "space-y-2",
|
||||
)}
|
||||
>
|
||||
{site ? (
|
||||
@@ -69,10 +79,12 @@ export const CharacterCard: React.FC<{
|
||||
dangerouslySetInnerHTML={{ __html: site?.description || "" }}
|
||||
></span>
|
||||
)}
|
||||
<span className="block">
|
||||
<FollowingCount siteId={site.username} disableList={true} />
|
||||
</span>
|
||||
{site?.date_created && (
|
||||
{!simple && (
|
||||
<span className="block">
|
||||
<FollowingCount siteId={site.username} disableList={true} />
|
||||
</span>
|
||||
)}
|
||||
{!simple && site?.date_created && (
|
||||
<span className="block text-gray-500">
|
||||
<time dateTime={date.formatToISO(site.date_created)}>
|
||||
{t("joined ago", {
|
||||
|
||||
@@ -65,10 +65,14 @@ export const FollowingButton: React.FC<{
|
||||
<Button
|
||||
variant={subscription.data ? "text" : variant}
|
||||
onClick={handleClickSubscribe}
|
||||
className={cn(className, "align-middle space-x-1 group", {
|
||||
"text-accent": subscription.data,
|
||||
"-mx-2": subscription.data,
|
||||
})}
|
||||
className={cn(
|
||||
className,
|
||||
"align-middle space-x-1 group border-accent border",
|
||||
{
|
||||
"text-accent": subscription.data,
|
||||
"opacity-60": subscription.data,
|
||||
},
|
||||
)}
|
||||
isLoading={
|
||||
subscription.data
|
||||
? unsubscribeFromSite.isLoading || subscribeToSite.isLoading
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { HeartIcon } from "@heroicons/react/24/outline"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { useState } from "react"
|
||||
import { PatronModal } from "~/components/common/PatronModal"
|
||||
|
||||
export const PatronButton: React.FC<{
|
||||
site: Profile | undefined | null
|
||||
className?: string
|
||||
size?: "sm" | "xl"
|
||||
loadingStatusChange?: (status: boolean) => void
|
||||
}> = ({ site, className, size, loadingStatusChange }) => {
|
||||
const { t } = useTranslation("common")
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<>
|
||||
<PatronModal open={open} setOpen={setOpen} site={site} />
|
||||
<Button
|
||||
variant="text"
|
||||
aria-label={"Patron"}
|
||||
key={t("Patron")}
|
||||
className={cn(className, "-mx-2")}
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
<HeartIcon className="text-red-400 flex w-5 h-5 -mb-[1px]" />
|
||||
<span className="text-zinc-500 ml-1">Patron</span>
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { HeartIcon } from "@heroicons/react/24/solid"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { useState } from "react"
|
||||
import { BoxRadio } from "~/components/ui/BoxRadio"
|
||||
import { CharacterCard } from "~/components/common/CharacterCard"
|
||||
import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline"
|
||||
import { Tabs } from "../ui/Tabs"
|
||||
|
||||
export const PatronModal: React.FC<{
|
||||
site: Profile | undefined | null
|
||||
open: boolean
|
||||
setOpen: (open: boolean) => void
|
||||
}> = ({ site, open, setOpen }) => {
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const radios = [
|
||||
{
|
||||
text: "🍭 1 Mira",
|
||||
value: "1",
|
||||
},
|
||||
{
|
||||
text: "☕️ 5 Mira",
|
||||
value: "5",
|
||||
},
|
||||
{
|
||||
text: "🍕 10 Mira",
|
||||
value: "10",
|
||||
},
|
||||
{
|
||||
text: "🎁 50 Mira",
|
||||
value: "50",
|
||||
},
|
||||
{
|
||||
text: "👑 100 Mira",
|
||||
value: "100",
|
||||
},
|
||||
{
|
||||
text: "Custom",
|
||||
},
|
||||
]
|
||||
|
||||
const [value, setValue] = useState(radios[1].value!)
|
||||
|
||||
const submit = () => {
|
||||
console.log(value)
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
setOpen={setOpen}
|
||||
title={
|
||||
t("Become a patron to {{name}}", {
|
||||
name: site?.name,
|
||||
}) || ""
|
||||
}
|
||||
titleIcon={<HeartIcon className="text-red-500 flex w-6 h-6 -mb-[1px]" />}
|
||||
size="lg"
|
||||
>
|
||||
<div className="px-5 py-4 space-y-4">
|
||||
<CharacterCard
|
||||
address={site?.metadata?.owner}
|
||||
open={true}
|
||||
hideFollowButton={true}
|
||||
simple={true}
|
||||
style="flat"
|
||||
/>
|
||||
<div className="text-lg">{t("Current patrons")}</div>
|
||||
<div className="text-zinc-500 text-sm">
|
||||
{t("You are here to be the first patron.")}
|
||||
</div>
|
||||
<div className="text-lg">{t("Select a tier")}</div>
|
||||
<div>
|
||||
<Tabs
|
||||
items={[
|
||||
{
|
||||
text: "One-time",
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
text: "Monthly and NFT Rewards",
|
||||
tooltip: "Coming soon",
|
||||
},
|
||||
]}
|
||||
></Tabs>
|
||||
</div>
|
||||
<div>
|
||||
<BoxRadio items={radios} value={value} setValue={setValue} />
|
||||
</div>
|
||||
<div className="text-zinc-500 text-xs space-y-2">
|
||||
<p>1 Mira ≈ 1 USDC</p>
|
||||
<p className="flex items-center">
|
||||
<QuestionMarkCircleIcon className="w-4 h-4 inline-block mr-1" />
|
||||
What is Mira? Where can I get some?
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button variant="primary" className="w-full" onClick={submit}>
|
||||
{t("Become a patron to {{name}}", {
|
||||
name: site?.name,
|
||||
})}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user