Skip to content

Commit

Permalink
Tip Profile Button
Browse files Browse the repository at this point in the history
  • Loading branch information
justsoantsy committed Jun 24, 2024
1 parent fef2f25 commit c40a6f9
Show file tree
Hide file tree
Showing 6 changed files with 1,619 additions and 91 deletions.
5 changes: 4 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"@privy-io/wagmi": "^0.2.1",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tanstack/react-query": "^5.40.0",
"@thirdweb-dev/sdk": "^4.0.99",
"axios": "^1.7.2",
"dayjs": "^1.11.11",
"emoji-mart": "^5.6.0",
"ethers": "5",
"filereader-stream": "^2.0.0",
"framer-motion": "^11.2.9",
"graphql": "^16.8.1",
Expand All @@ -41,21 +43,22 @@
"react-hot-toast": "^2.4.1",
"react-use-websocket": "^4.8.1",
"textarea-caret": "^3.1.0",
"thirdweb": "^5.29.5",
"uuid": "^9.0.1",
"viem": "^2.13.1",
"wagmi": "^2.9.8",
"zod": "^3.23.8",
"zustand": "^4.5.2"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.13",
"@dragverse/abis": "workspace:*",
"@dragverse/browser": "workspace:*",
"@dragverse/config": "workspace:*",
"@dragverse/constants": "workspace:*",
"@dragverse/generic": "workspace:*",
"@dragverse/lens": "workspace:*",
"@dragverse/ui": "workspace:*",
"@tailwindcss/typography": "^0.5.13",
"@types/js-cookie": "^3.0.6",
"@types/node": "20.12.13",
"@types/react": "18.3.3",
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/components/Profile/BasicInfo/Follow.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* apps/web/src/components/Profile/BasicInfo/Follow.module.css */
.container {
display: flex;
align-items: center;
gap: 1rem;
}

.tipButton {
background-color: #fca5a5; /* Adjust color for tip button */
color: #fff;
padding: 0.5rem 1rem;
border: none;
border-radius: 5px;
cursor: pointer;
}

27 changes: 24 additions & 3 deletions apps/web/src/components/Profile/BasicInfo/Follow.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// apps/web/src/components/Profile/BasicInfo/Follow.tsx
import { LENSHUB_PROXY_ABI } from '@dragverse/abis'
import {
ERROR_MESSAGE,
Expand Down Expand Up @@ -28,13 +29,17 @@ import { useState } from 'react'
import toast from 'react-hot-toast'
import { useSignTypedData, useWriteContract } from 'wagmi'

import TipEmbed from '../../Watch/OpenActions/Unknown/Tip/TipEmbed'
import styles from './Follow.module.css'

type Props = {
profile: Profile
onSubscribe: () => void
}

const Follow: FC<Props> = ({ profile, onSubscribe }) => {
const [loading, setLoading] = useState(false)
const [showTipEmbed, setShowTipEmbed] = useState(false)
const { activeProfile } = useProfileStore()
const { canUseLensManager, canBroadcast } =
checkLensManagerPermissions(activeProfile)
Expand Down Expand Up @@ -167,10 +172,26 @@ const Follow: FC<Props> = ({ profile, onSubscribe }) => {
})
}

const toggleTipEmbed = () => {
setShowTipEmbed((prev) => !prev)
}

const closeTipEmbed = () => {
setShowTipEmbed(false)
}

return (
<Button disabled={loading} loading={loading} onClick={() => follow()}>
Follow
</Button>
<div className={styles.container}>
<Button disabled={loading} loading={loading} onClick={() => follow()}>
Follow
</Button>
<Button className={styles.tipButton} onClick={toggleTipEmbed}>
Tip
</Button>
{showTipEmbed && (
<TipEmbed publicationId={profile.id} onClose={closeTipEmbed} />
)}
</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* apps/web/src/components/Watch/OpenActions/Unknown/Tip/TipEmbed.module.css */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}

.modal-content {
background: white;
padding: 2rem;
border-radius: 8px;
position: relative;
width: 90%;
max-width: 500px;
}

.modal-close {
position: absolute;
top: 10px;
right: 10px;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
}

71 changes: 71 additions & 0 deletions apps/web/src/components/Watch/OpenActions/Unknown/Tip/TipEmbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// apps/web/src/components/Watch/OpenActions/Unknown/Tip/TipEmbed.tsx
import React, { useEffect, useState } from 'react'
import { createThirdwebClient } from 'thirdweb'
import { base } from 'thirdweb/chains'
import { darkTheme, PayEmbed } from 'thirdweb/react'

import styles from './TipEmbed.module.css'

const client = createThirdwebClient({
clientId: 'ss' // Replace with your actual client ID
})

interface TipEmbedProps {
publicationId: string
onClose: () => void
}

const TipEmbed: React.FC<TipEmbedProps> = ({ publicationId, onClose }) => {
const [showPayEmbed, setShowPayEmbed] = useState(false)

useEffect(() => {
setShowPayEmbed(true)
}, [])

return (
<div className={styles.modal}>
<div className={styles.modalContent}>
<button className={styles.modalClose} onClick={onClose}>
</button>
<h2 className="text-brand-500">
Tip for Publication ID: {publicationId}
</h2>
{showPayEmbed && (
<PayEmbed
client={client}
payOptions={{
prefillBuy: {
token: {
address: '0x4200000000000000000000000000000000000006', // ETH on Base
name: 'ETH',
symbol: 'ETH'
},
chain: base,
allowEdits: {
amount: true,
token: false,
chain: false
}
}
}}
theme={darkTheme({
colors: {
modalBg: '#100c1f' // Hard-coded value matching the brand[250] color
}
})}
connectOptions={{
connectModal: {
size: 'compact',
title: 'Connect your wallet'
},
autoConnect: { timeout: 15000 }
}}
/>
)}
</div>
</div>
)
}

export default TipEmbed
Loading

0 comments on commit c40a6f9

Please sign in to comment.