RelaySelector should not accept any props

This commit is contained in:
Alex Gleason 2025-06-04 18:32:45 -05:00
parent 61508020ae
commit da87f2c7b1
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 39 additions and 12 deletions

View File

@ -472,6 +472,36 @@ The router includes automatic scroll-to-top functionality and a 404 NotFound pag
</Card> </Card>
``` ```
### Empty States and No Content Found
When no content is found (empty search results, no data available, etc.), display a minimalist empty state with the `RelaySelector` component. This allows users to easily switch relays to discover content from different sources.
```tsx
import { RelaySelector } from '@/components/RelaySelector';
import { Card, CardContent } from '@/components/ui/card';
// Empty state example
<div className="col-span-full">
<Card className="border-dashed">
<CardContent className="py-12 px-8 text-center">
<div className="max-w-sm mx-auto space-y-6">
<p className="text-muted-foreground">
No results found. Try another relay?
</p>
<RelaySelector className="w-full" />
</div>
</CardContent>
</Card>
</div>
```
**Key principles for empty states:**
- Keep text minimal and clear
- Use dashed borders to indicate empty/placeholder state
- Include the RelaySelector to provide actionable next steps
- Center content with generous whitespace (`py-12 px-8`)
- Constrain width with `max-w-sm mx-auto` for focused layout
## Design Customization ## Design Customization
**Tailor the site's look and feel based on the user's specific request.** This includes: **Tailor the site's look and feel based on the user's specific request.** This includes:

View File

@ -15,16 +15,20 @@ import {
PopoverTrigger, PopoverTrigger,
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { useState } from "react"; import { useState } from "react";
import { useAppContext } from "@/hooks/useAppContext";
interface RelaySelectorProps { interface RelaySelectorProps {
className?: string; className?: string;
selectedRelay?: string;
setSelectedRelay: (relay: string) => void;
presetRelays?: { name: string; url: string }[];
} }
export function RelaySelector(props: RelaySelectorProps) { export function RelaySelector(props: RelaySelectorProps) {
const { selectedRelay, setSelectedRelay, className, presetRelays = [] } = props; const { className } = props;
const { config, updateConfig, presetRelays = [] } = useAppContext();
const selectedRelay = config.relayUrl;
const setSelectedRelay = (relay: string) => {
updateConfig((current) => ({ ...current, relayUrl: relay }));
};
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [inputValue, setInputValue] = useState(""); const [inputValue, setInputValue] = useState("");

View File

@ -12,7 +12,6 @@ import {
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx';
import { RelaySelector } from '@/components/RelaySelector'; import { RelaySelector } from '@/components/RelaySelector';
import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts'; import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts';
import { useAppContext } from '@/hooks/useAppContext';
import { genUserName } from '@/lib/genUserName'; import { genUserName } from '@/lib/genUserName';
interface AccountSwitcherProps { interface AccountSwitcherProps {
@ -20,7 +19,6 @@ interface AccountSwitcherProps {
} }
export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) { export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {
const { config, updateConfig, presetRelays } = useAppContext();
const { currentUser, otherUsers, setLogin, removeLogin } = useLoggedInAccounts(); const { currentUser, otherUsers, setLogin, removeLogin } = useLoggedInAccounts();
if (!currentUser) return null; if (!currentUser) return null;
@ -45,12 +43,7 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent className='w-56 p-2 animate-scale-in'> <DropdownMenuContent className='w-56 p-2 animate-scale-in'>
<div className='font-medium text-sm px-2 py-1.5'>Switch Relay</div> <div className='font-medium text-sm px-2 py-1.5'>Switch Relay</div>
<RelaySelector <RelaySelector className="w-full" />
className="w-full"
selectedRelay={config.relayUrl}
setSelectedRelay={(relayUrl) => updateConfig((config) => ({ ...config, relayUrl }))}
presetRelays={presetRelays}
/>
<DropdownMenuSeparator /> <DropdownMenuSeparator />
<div className='font-medium text-sm px-2 py-1.5'>Switch Account</div> <div className='font-medium text-sm px-2 py-1.5'>Switch Account</div>
{otherUsers.map((user) => ( {otherUsers.map((user) => (