|
| 1 | +import type { schema } from "@lib/zero-sync/schema"; |
| 2 | +import { useQuery, useZero } from "@rocicorp/zero/react"; |
| 3 | +import { Newline, Text, Box } from "ink" |
| 4 | +import Link from "ink-link" |
| 5 | +import { useEffect, useState } from "react" |
| 6 | +import { colors } from "./theme"; |
| 7 | +import { Spinner } from "@inkjs/ui"; |
| 8 | + |
| 9 | +export const Footer = () => { |
| 10 | + const z = useZero<typeof schema>(); |
| 11 | + const [speakers] = useQuery(z.query.profiles); |
| 12 | + const [speakerIndex, setSpeakerIndex] = useState(Math.floor(Math.random() * 10) + 1) |
| 13 | + |
| 14 | + useEffect(() => { |
| 15 | + const interval = setInterval(() => { |
| 16 | + setSpeakerIndex((speakerIndex + 1) % speakers.length) |
| 17 | + }, 2000) |
| 18 | + return () => clearInterval(interval) |
| 19 | + }, [speakerIndex, speakers.length]) |
| 20 | + |
| 21 | + const speaker = speakers[speakerIndex] |
| 22 | + |
| 23 | + const link = (()=>{ |
| 24 | + if (speaker?.linkedinHandle) { |
| 25 | + return `https://www.linkedin.com/in/${speaker.linkedinHandle}` |
| 26 | + } |
| 27 | + if (speaker?.twitterHandle) { |
| 28 | + return `https://x.com/${speaker.twitterHandle}` |
| 29 | + } |
| 30 | + if (speaker?.blueskyHandle) { |
| 31 | + return `https://bsky.app/profile/${speaker.blueskyHandle}` |
| 32 | + } |
| 33 | + })(); |
| 34 | + return ( |
| 35 | + <> |
| 36 | + <Newline /> |
| 37 | + <Text dimColor>------------------------ </Text> |
| 38 | + <Box> |
| 39 | + {!speaker && <Spinner type='dots10' label="Loading speakers..." />} |
| 40 | + {speaker && <Text italic dimColor> |
| 41 | + <Text> |
| 42 | + {speaker.name} - <Text color={colors.mainOrange} dimColor>{speaker?.title}</Text> |
| 43 | + <Newline /> |
| 44 | + {link && <Link url={link}> |
| 45 | + <Text color={colors.mainOrange} dimColor>{link}</Text> |
| 46 | + </Link>} |
| 47 | + </Text> |
| 48 | + </Text>} |
| 49 | + </Box> |
| 50 | + </> |
| 51 | + ) |
| 52 | +} |
0 commit comments