Skip to content

Commit

Permalink
showing user count in typing
Browse files Browse the repository at this point in the history
  • Loading branch information
omranjamal committed Sep 9, 2024
1 parent 6f13856 commit 602226b
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions apps/jonogon-web-next/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getSortType,
} from './_components/petitionSortUtils';
import {TypeAnimation} from 'react-type-animation';
import {trpc} from '@/trpc/client';

function SortOption({
sort,
Expand Down Expand Up @@ -79,6 +80,8 @@ function Tab({
);
}

const DISCORD_COMMUNITY_SIZE = 2500;

export default function Home() {
const params = useSearchParams();

Expand All @@ -90,6 +93,31 @@ export default function Home() {

const sortLabel = getDefaultSortLabelForDabiType(sort, type);

const {data: userCountResponse} =
trpc.users.getTotalNumberOfUsers.useQuery();

const defaultTypeSeq = [
'Submit.',
500,
'Submit. Vote.',
500,
'Submit. Vote.\nReform.',
2000,
`যত বেশি ভোট,\nতত তাড়াতাড়ি জবাব`,
2000,
];

const userCount = Number(userCountResponse?.data.count?.count ?? 0);

const typeSeq =
userCount > 0
? [
...defaultTypeSeq,
`${userCount + DISCORD_COMMUNITY_SIZE} নাগরিক এর সাথে\nগোরে তুলুন নতুন দেশ`,
2000,
]
: defaultTypeSeq;

return (
<>
<div className="flex flex-col gap-4 max-w-screen-sm mx-auto pb-16 px-4">
Expand All @@ -98,19 +126,11 @@ export default function Home() {
'Your Own দাবিs'
) : (
<TypeAnimation
key={userCount > 0 ? 'tomato' : 'potato'}
style={{whiteSpace: 'pre-line', display: 'inline'}}
cursor={true}
speed={80}
sequence={[
`যত বেশি ভোট,\nতত তাড়াতাড়ি জবাব`,
2000,
'Submit.',
500,
'Submit. Vote.',
500,
'Submit. Vote.\nReform.',
2000,
]}
sequence={typeSeq}
omitDeletionAnimation
repeat={Infinity}
/>
Expand Down

0 comments on commit 602226b

Please sign in to comment.