'use client'; import { useState, useRef, useEffect } from 'react'; export interface AppModule { id: string; name: string; badge: string; // favicon-style abbreviation: rS, rN, rP, etc. color: string; // Tailwind bg class for the pastel badge emoji: string; // function emoji shown right of title description: string; domain?: string; } const MODULES: AppModule[] = [ // Creating { id: 'space', name: 'rSpace', badge: 'rS', color: 'bg-teal-300', emoji: '🎨', description: 'Real-time collaborative canvas', domain: 'rspace.online' }, { id: 'notes', name: 'rNotes', badge: 'rN', color: 'bg-amber-300', emoji: 'πŸ“', description: 'Group note-taking & knowledge capture', domain: 'rnotes.online' }, { id: 'pubs', name: 'rPubs', badge: 'rP', color: 'bg-rose-300', emoji: 'πŸ“–', description: 'Collaborative publishing platform', domain: 'rpubs.online' }, { id: 'tube', name: 'rTube', badge: 'rTu', color: 'bg-pink-300', emoji: '🎬', description: 'Community video platform', domain: 'rtube.online' }, { id: 'swag', name: 'rSwag', badge: 'rSw', color: 'bg-red-200', emoji: 'πŸ‘•', description: 'Community merch & swag store', domain: 'rswag.online' }, // Planning { id: 'cal', name: 'rCal', badge: 'rC', color: 'bg-sky-300', emoji: 'πŸ“…', description: 'Collaborative scheduling & events', domain: 'rcal.online' }, { id: 'trips', name: 'rTrips', badge: 'rT', color: 'bg-emerald-300', emoji: '✈️', description: 'Group travel planning in real time', domain: 'rtrips.online' }, { id: 'maps', name: 'rMaps', badge: 'rM', color: 'bg-green-300', emoji: 'πŸ—ΊοΈ', description: 'Collaborative real-time mapping', domain: 'rmaps.online' }, // Communicating { id: 'chats', name: 'rChats', badge: 'rCh', color: 'bg-emerald-200', emoji: 'πŸ’¬', description: 'Real-time encrypted messaging', domain: 'rchats.online' }, { id: 'inbox', name: 'rInbox', badge: 'rI', color: 'bg-indigo-300', emoji: 'πŸ“¬', description: 'Private group messaging', domain: 'rinbox.online' }, { id: 'mail', name: 'rMail', badge: 'rMa', color: 'bg-blue-200', emoji: 'βœ‰οΈ', description: 'Community email & newsletters', domain: 'rmail.online' }, { id: 'forum', name: 'rForum', badge: 'rFo', color: 'bg-amber-200', emoji: 'πŸ’­', description: 'Threaded community discussions', domain: 'rforum.online' }, // Deciding { id: 'choices', name: 'rChoices', badge: 'rCo', color: 'bg-fuchsia-300', emoji: 'βš–οΈ', description: 'Collaborative decision making', domain: 'rchoices.online' }, { id: 'vote', name: 'rVote', badge: 'rV', color: 'bg-violet-300', emoji: 'πŸ—³οΈ', description: 'Real-time polls & governance', domain: 'rvote.online' }, // Funding & Commerce { id: 'funds', name: 'rFunds', badge: 'rF', color: 'bg-lime-300', emoji: 'πŸ’Έ', description: 'Collaborative fundraising & grants', domain: 'rfunds.online' }, { id: 'wallet', name: 'rWallet', badge: 'rW', color: 'bg-yellow-300', emoji: 'πŸ’°', description: 'Multi-chain crypto wallet', domain: 'rwallet.online' }, { id: 'cart', name: 'rCart', badge: 'rCt', color: 'bg-orange-300', emoji: 'πŸ›’', description: 'Group commerce & shared shopping', domain: 'rcart.online' }, { id: 'auctions', name: 'rAuctions', badge: 'rA', color: 'bg-red-300', emoji: 'πŸ”¨', description: 'Live auction platform', domain: 'rauctions.online' }, // Sharing { id: 'photos', name: 'rPhotos', badge: 'rPh', color: 'bg-pink-200', emoji: 'πŸ“Έ', description: 'Community photo commons', domain: 'rphotos.online' }, { id: 'network', name: 'rNetwork', badge: 'rNe', color: 'bg-blue-300', emoji: 'πŸ•ΈοΈ', description: 'Community network & social graph', domain: 'rnetwork.online' }, { id: 'files', name: 'rFiles', badge: 'rFi', color: 'bg-cyan-300', emoji: 'πŸ“', description: 'Collaborative file storage', domain: 'rfiles.online' }, { id: 'socials', name: 'rSocials', badge: 'rSo', color: 'bg-sky-200', emoji: 'πŸ“’', description: 'Social media management', domain: 'rsocials.online' }, // Observing { id: 'data', name: 'rData', badge: 'rD', color: 'bg-purple-300', emoji: 'πŸ“Š', description: 'Analytics & insights dashboard', domain: 'rdata.online' }, // Work & Productivity { id: 'work', name: 'rWork', badge: 'rWo', color: 'bg-slate-300', emoji: 'πŸ“‹', description: 'Project & task management', domain: 'rwork.online' }, // Identity & Infrastructure { id: 'ids', name: 'rIDs', badge: 'rId', color: 'bg-emerald-300', emoji: 'πŸ”', description: 'Passkey identity & zero-knowledge auth', domain: 'ridentity.online' }, { id: 'stack', name: 'rStack', badge: 'r*', color: 'bg-gradient-to-br from-cyan-300 via-violet-300 to-rose-300', emoji: 'πŸ“¦', description: 'Open-source community infrastructure', domain: 'rstack.online' }, ]; const MODULE_CATEGORIES: Record = { space: 'Creating', notes: 'Creating', pubs: 'Creating', tube: 'Creating', swag: 'Creating', cal: 'Planning', trips: 'Planning', maps: 'Planning', chats: 'Communicating', inbox: 'Communicating', mail: 'Communicating', forum: 'Communicating', choices: 'Deciding', vote: 'Deciding', funds: 'Funding & Commerce', wallet: 'Funding & Commerce', cart: 'Funding & Commerce', auctions: 'Funding & Commerce', photos: 'Sharing', network: 'Sharing', files: 'Sharing', socials: 'Sharing', data: 'Observing', work: 'Work & Productivity', ids: 'Identity & Infrastructure', stack: 'Identity & Infrastructure', }; const CATEGORY_ORDER = [ 'Creating', 'Planning', 'Communicating', 'Deciding', 'Funding & Commerce', 'Sharing', 'Observing', 'Work & Productivity', 'Identity & Infrastructure', ]; /** Build the URL for a module, using username subdomain if logged in */ function getModuleUrl(m: AppModule, username: string | null): string { if (!m.domain) return '#'; if (username) { // Generate . URL return `https://${username}.${m.domain}`; } return `https://${m.domain}`; } interface AppSwitcherProps { current?: string; } export function AppSwitcher({ current = 'notes' }: AppSwitcherProps) { const [open, setOpen] = useState(false); const [username, setUsername] = useState(null); const ref = useRef(null); useEffect(() => { function handleClick(e: MouseEvent) { if (ref.current && !ref.current.contains(e.target as Node)) { setOpen(false); } } document.addEventListener('click', handleClick); return () => document.removeEventListener('click', handleClick); }, []); // Fetch current user's username for subdomain links useEffect(() => { fetch('/api/me') .then((r) => r.json()) .then((data) => { if (data.authenticated && data.user?.username) { setUsername(data.user.username); } }) .catch(() => { /* not logged in */ }); }, []); const currentMod = MODULES.find((m) => m.id === current); // Group modules by category const groups = new Map(); for (const m of MODULES) { const cat = MODULE_CATEGORIES[m.id] || 'Other'; if (!groups.has(cat)) groups.set(cat, []); groups.get(cat)!.push(m); } return (
{/* Trigger button */} {/* Dropdown */} {open && (
{/* rStack header */}
r*
rStack
Self-hosted community app suite
{/* Categories */} {CATEGORY_ORDER.map((cat) => { const items = groups.get(cat); if (!items || items.length === 0) return null; return ( ); })} {/* Footer */}
)}
); }