Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: referrals tweaks #155

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-dom": "latest",
"react-hook-form": "^7.51.3",
"react-hot-toast": "^2.4.1",
"react-tooltip": "^5.28.0",
"swr": "^2.2.4",
"web3.storage": "^4.5.5"
},
Expand Down
325 changes: 268 additions & 57 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
@tailwind components;
@tailwind utilities;

@import 'react-tooltip/dist/react-tooltip.css';

:root {
--hot-red: #E91315;
--hot-red-light: #EFE3F3;
--hot-yellow: #FFC83F;
--hot-yellow-light: #FFE4AE;
--hot-blue: #0176CE;
--hot-blue-light: #BDE0FF;
--rt-opacity: 0.97;
}

.font-epilogue {
Expand Down
16 changes: 10 additions & 6 deletions src/app/referrals/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import CopyButton from '@/components/CopyButton'
import DefaultLoader from '@/components/Loader'
import { H1, H3 } from '@/components/Text'
import { H1, H2, H3 } from '@/components/Text'
import Tooltip from '@/components/Tooltip'
import { RefcodeResult, useReferrals } from '@/lib/referrals/hooks'
import { useEffect } from 'react'
import { KeyedMutator } from 'swr'
Expand Down Expand Up @@ -90,7 +91,7 @@ export function ReferralsList () {
return (
(referrals && referrals.length > 0) ? (
<>
<H3>Referrals</H3>
<H2>Referrals</H2>
<div className="divide-solid divide-hot-red py-4">
{
/**
Expand All @@ -101,17 +102,20 @@ export function ReferralsList () {
referrals.map((referral, i) =>
<div key={i} className="flex flex-row justify-between items-center py-4">
<div>Referred Racha</div>
<div className="rounded-full bg-hot-red-light text-hot-red px-4 py-2 font-mono text-sm">In Progress</div>
<div className={`referral-${i} rounded-full bg-hot-red-light text-hot-red px-4 py-2 font-mono text-sm`}>In Progress</div>
<Tooltip anchorSelect={`.referral-${i}`} place="bottom-start">
<p className="max-w-sm">Your referral was successful! You will receive your reward once the referred user has paid for the requisite period of time.</p>
</Tooltip>
</div>
)
}
</div>
</>
) : (
<>
<H3>Earn Free Storage and Racha Points!</H3>
<H2>Earn Free Storage and Racha Points!</H2>
<p className='text-hot-red mb-4 max-w-lg'>
Turn your friends into Lite or Business Rachas and receive up to 16 months of Lite or
Turn your friends into Lite or Business Rachas and receive up to 16 months of Lite and
3 months of Business for free! You can also earn Racha Points.
</p>
</>
Expand All @@ -124,7 +128,7 @@ export default function ReferralsPage () {
return (
<div className='p-10 bg-racha-fire/50 w-full h-screen'>
<H1>Generate a Referral Code</H1>
<div className='border border-hot-red rounded-2xl bg-white p-5'>
<div className='border border-hot-red rounded-2xl bg-white p-5 max-w-2xl'>
{refcodeIsLoading ? (
<DefaultLoader className="text-hot-red h-6 w-6" />
) : (
Expand Down
7 changes: 6 additions & 1 deletion src/components/PlanGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ export function PlanGate ({ children }: { children: ReactNode }): ReactNode {
<h1 className="my-4 font-bold">Welcome, {email}!</h1>
<p className='my-4'>
Congratulations! You are eligible for a free trial of our Lite or Business subscriptions. That means
we won&apos;t charge you anything today. We do need you to provide a valid credit card before we can start your
we won&apos;t charge you anything today.
If you choose a Lite plan, you will get two months for free! If you choose Business, you will get one month for free!
We do need you to provide a valid credit card before we can start your
trial - pick a plan below and complete the checkout flow to get started!
</p>
<p className='my-4'>
Please note that after your free trial ends, you will be charged 10 USD per month for Lite or 100 USD per month for Business tier.
</p>
</div>
<StripeTrialPricingTable />
</>
Expand Down
9 changes: 7 additions & 2 deletions src/components/SpaceCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DidIcon } from './DidIcon'
import Link from 'next/link'
import { FolderPlusIcon, InformationCircleIcon } from '@heroicons/react/24/outline'
import Tooltip from './Tooltip'
import { H3 } from './Text'

export function SpaceCreatorCreating(): JSX.Element {
return (
Expand Down Expand Up @@ -167,8 +168,12 @@ export function SpacePreview({ did, name, capabilities }: SpacePreviewProps) {
<Link href={`/space/${did}`} className='block'>
<span className='font-epilogue text-lg text-hot-red font-semibold leading-5 m-0 flex items-center'>
{name ?? 'Untitled'}
<Tooltip title="Capabilities" text={capabilities}>
<InformationCircleIcon className='h-5 w-5 ml-2' />
<InformationCircleIcon className={`h-5 w-5 ml-2 space-preview-capability-icon`} />
<Tooltip anchorSelect={`.space-preview-capability-icon`}>
<H3>Capabilities</H3>
{capabilities.map((c, i) => (
<p key={i}>{c}</p>
))}
</Tooltip>
</span>
<span className='block font-mono text-xs truncate'>
Expand Down
24 changes: 8 additions & 16 deletions src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import { useState } from "react";
import { ITooltip, Tooltip as ReactTooltip } from 'react-tooltip'

function Tooltip({ text, title, children }: { text: string[], title?: string, children: React.ReactNode }) {
const [visible, setVisible] = useState(false);

function Tooltip (options: ITooltip) {
return (
<span
onMouseEnter={() => setVisible(true)}
onMouseLeave={() => setVisible(false)}
className="relative cursor-pointer flex items-center"
>
{children}
{visible && (
<div className="absolute left-1/2 bottom-full transform -translate-x-1/2 bg-gray-800 text-white p-1.5 rounded whitespace-pre-wrap z-10">
{title && <><strong>{title}</strong><br /></>}
{text.join('\n')}
</div>
)}
</span>
<ReactTooltip
noArrow={true}
className="p-8 rounded-2xl bg-white/80 backdrop-blur-tooltip border border-hot-red"
variant="light"
disableStyleInjection={'core'}
{...options} />
);
}

Expand Down
12 changes: 8 additions & 4 deletions src/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { extract } from '@ucanto/core/delegation'
import type { PropsWithChildren } from 'react'
import type { Delegation } from '@ucanto/interface'
import { SpacePreview } from './components/SpaceCreator'
import { H2 } from '@/components/Text'
import { H2, H3 } from '@/components/Text'
import CopyButton from './components/CopyButton'
import Tooltip from './components/Tooltip'
import { ArrowDownOnSquareStackIcon, CloudArrowDownIcon, PaperAirplaneIcon, InformationCircleIcon } from '@heroicons/react/24/outline'
Expand Down Expand Up @@ -235,12 +235,16 @@ export function ShareSpace({ spaceDID }: { spaceDID: SpaceDID }): JSX.Element {
Shared With:
</p>
<ul>
{sharedEmails.map(({ email, capabilities }) => (
{sharedEmails.map(({ email, capabilities }, i) => (
<li key={email} className="flex flex-col sm:flex-row items-start sm:items-center space-y-2 sm:space-y-0 sm:space-x-2 w-full mt-1">
<span className="flex items-center w-full">
<span className="truncate mt-1">{email}</span>
<Tooltip title="Capabilities" text={capabilities}>
<InformationCircleIcon className='h-5 w-5 ml-1' />
<InformationCircleIcon className={`h-5 w-5 ml-1 share-capabilities-${i}`} />
<Tooltip anchorSelect={`.share-capabilities-${i}`}>
<H3>Capabilities</H3>
{capabilities.map((c, j) => (
<p key={j}>{c}</p>
))}
</Tooltip>
</span>
</li>
Expand Down
5 changes: 4 additions & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const config: Config = {
'hot-yellow-light': '#FFE4AE',
'hot-blue': '#0176CE',
'hot-blue-light': '#BDE0FF'
}
},
backdropBlur: {
tooltip: '60px',
}
}
},
plugins: [],
Expand Down
Loading