Update AI context for Tailwind v4 and React 19

- AGENTS.md: describe ui components as React 19 ref-as-prop function
  components using data-slot and the unified radix-ui package
- theming skill: register fonts and color tokens via @theme in
  src/index.css (no tailwind.config.ts); fix color values to use the
  hsl() wrapper that matches the real index.css
- ai-chat skill: import VisuallyHidden from the unified radix-ui package
- nwc skill: convert ZapDialog/WalletModal forwardRef to ref-as-prop
- edit-profile skill: drop React.FC in favor of plain function typing
This commit is contained in:
Alex Gleason committed 2026-06-05 09:43:15 -05:00
1 parent 459221305f
commit 772479e232
6 files changed
+41 -44

No files matched your search

+3 -3
View File
@@ -268,12 +268,12 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } f
**Important**: Even if you want to hide the title visually, use the `VisuallyHidden` component to maintain accessibility: **Important**: Even if you want to hide the title visually, use the `VisuallyHidden` component to maintain accessibility:
```tsx ```tsx
import { VisuallyHidden } from "@radix-ui/react-visually-hidden"; import { VisuallyHidden } from "radix-ui";
<DialogHeader> <DialogHeader>
<VisuallyHidden> <VisuallyHidden.Root>
<DialogTitle>Hidden Title for Screen Readers</DialogTitle> <DialogTitle>Hidden Title for Screen Readers</DialogTitle>
</VisuallyHidden> </VisuallyHidden.Root>
</DialogHeader> </DialogHeader>
``` ```
@@ -22,7 +22,7 @@ import { NSchema as n, type NostrMetadata } from '@nostrify/nostrify';
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { useUploadFile } from '@/hooks/useUploadFile'; import { useUploadFile } from '@/hooks/useUploadFile';
export const EditProfileForm: React.FC = () => { export const EditProfileForm = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { user, metadata } = useCurrentUser(); const { user, metadata } = useCurrentUser();
@@ -284,14 +284,14 @@ interface ImageUploadFieldProps {
onUpload: (file: File) => void; onUpload: (file: File) => void;
} }
const ImageUploadField: React.FC<ImageUploadFieldProps> = ({ const ImageUploadField = ({
field, field,
label, label,
placeholder, placeholder,
description, description,
previewType, previewType,
onUpload, onUpload,
}) => { }: ImageUploadFieldProps) => {
const fileInputRef = useRef<HTMLInputElement>(null); const fileInputRef = useRef<HTMLInputElement>(null);
return ( return (
@@ -1,4 +1,4 @@
import { useState, forwardRef } from 'react'; import { useState } from 'react';
import { Wallet, Plus, Trash2, Zap, Globe, WalletMinimal, CheckCircle, X } from 'lucide-react'; import { Wallet, Plus, Trash2, Zap, Globe, WalletMinimal, CheckCircle, X } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { import {
@@ -37,12 +37,13 @@ interface WalletModalProps {
} }
// Extracted AddWalletContent to prevent re-renders // Extracted AddWalletContent to prevent re-renders
const AddWalletContent = forwardRef<HTMLDivElement, { const AddWalletContent = ({ alias, setAlias, connectionUri, setConnectionUri, ref }: {
alias: string; alias: string;
setAlias: (value: string) => void; setAlias: (value: string) => void;
connectionUri: string; connectionUri: string;
setConnectionUri: (value: string) => void; setConnectionUri: (value: string) => void;
}>(({ alias, setAlias, connectionUri, setConnectionUri }, ref) => ( ref?: React.Ref<HTMLDivElement>;
}) => (
<div className="space-y-4 px-4" ref={ref}> <div className="space-y-4 px-4" ref={ref}>
<div> <div>
<Label htmlFor="alias">Wallet Name (optional)</Label> <Label htmlFor="alias">Wallet Name (optional)</Label>
@@ -64,11 +65,20 @@ const AddWalletContent = forwardRef<HTMLDivElement, {
/> />
</div> </div>
</div> </div>
)); );
AddWalletContent.displayName = 'AddWalletContent';
// Extracted WalletContent to prevent re-renders // Extracted WalletContent to prevent re-renders
const WalletContent = forwardRef<HTMLDivElement, { const WalletContent = ({
webln,
hasNWC,
connections,
connectionInfo,
activeConnection,
handleSetActive,
handleRemoveConnection,
setAddDialogOpen,
ref,
}: {
webln: WebLNProvider | null; webln: WebLNProvider | null;
hasNWC: boolean; hasNWC: boolean;
connections: NWCConnection[]; connections: NWCConnection[];
@@ -77,16 +87,8 @@ const WalletContent = forwardRef<HTMLDivElement, {
handleSetActive: (cs: string) => void; handleSetActive: (cs: string) => void;
handleRemoveConnection: (cs: string) => void; handleRemoveConnection: (cs: string) => void;
setAddDialogOpen: (open: boolean) => void; setAddDialogOpen: (open: boolean) => void;
}>(({ ref?: React.Ref<HTMLDivElement>;
webln, }) => (
hasNWC,
connections,
connectionInfo,
activeConnection,
handleSetActive,
handleRemoveConnection,
setAddDialogOpen
}, ref) => (
<div className="space-y-6 px-4 pb-4" ref={ref}> <div className="space-y-6 px-4 pb-4" ref={ref}>
{/* Current Status */} {/* Current Status */}
<div className="space-y-3"> <div className="space-y-3">
@@ -201,8 +203,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
</> </>
)} )}
</div> </div>
)); );
WalletContent.displayName = 'WalletContent';
export function WalletModal({ children, className }: WalletModalProps) { export function WalletModal({ children, className }: WalletModalProps) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -1,4 +1,4 @@
import { useState, useEffect, useRef, forwardRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { Zap, Copy, Check, ExternalLink, Sparkle, Sparkles, Star, Rocket, ArrowLeft, X } from 'lucide-react'; import { Zap, Copy, Check, ExternalLink, Sparkle, Sparkles, Star, Rocket, ArrowLeft, X } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
@@ -64,10 +64,11 @@ interface ZapContentProps {
setComment: (comment: string) => void; setComment: (comment: string) => void;
inputRef: React.RefObject<HTMLInputElement | null>; inputRef: React.RefObject<HTMLInputElement | null>;
zap: (amount: number, comment: string) => void; zap: (amount: number, comment: string) => void;
ref?: React.Ref<HTMLDivElement>;
} }
// Moved ZapContent outside of ZapDialog to prevent re-renders causing focus loss // Moved ZapContent outside of ZapDialog to prevent re-renders causing focus loss
const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({ const ZapContent = ({
invoice, invoice,
amount, amount,
comment, comment,
@@ -82,7 +83,8 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
setComment, setComment,
inputRef, inputRef,
zap, zap,
}, ref) => ( ref,
}: ZapContentProps) => (
<div ref={ref}> <div ref={ref}>
{invoice ? ( {invoice ? (
<div className="flex flex-col h-full min-h-0"> <div className="flex flex-col h-full min-h-0">
@@ -232,8 +234,7 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
</> </>
)} )}
</div> </div>
)); );
ZapContent.displayName = 'ZapContent';
export function ZapDialog({ target, children, className }: ZapDialogProps) { export function ZapDialog({ target, children, className }: ZapDialogProps) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
+9 -14
View File
@@ -24,18 +24,13 @@ Any Google Font can be installed via the `@fontsource` / `@fontsource-variable`
import '@fontsource-variable/inter'; import '@fontsource-variable/inter';
``` ```
3. **Register the family** in `tailwind.config.ts`: 3. **Register the family** in the `@theme` block of `src/index.css` (Tailwind v4 is CSS-first — there is no `tailwind.config.ts`):
```ts ```css
export default { @theme {
theme: { --font-sans: 'Inter Variable', 'Inter', system-ui, sans-serif;
extend: { }
fontFamily: {
sans: ['Inter Variable', 'Inter', 'system-ui', 'sans-serif'],
},
},
},
};
``` ```
This makes `font-sans` (and the default body font) resolve to the new family.
### Suggested families by use case ### Suggested families by use case
@@ -44,7 +39,7 @@ Any Google Font can be installed via the `@fontsource` / `@fontsource-variable`
- **Creative / Artistic:** Poppins, Nunito, Comfortaa - **Creative / Artistic:** Poppins, Nunito, Comfortaa
- **Monospace / Code:** JetBrains Mono, Fira Code, Source Code Pro - **Monospace / Code:** JetBrains Mono, Fira Code, Source Code Pro
For expressive hierarchies, pair a sans body font with a display/serif heading font (e.g. Inter + Playfair Display) and expose the second family as `fontFamily.serif` or `fontFamily.display` in Tailwind. For expressive hierarchies, pair a sans body font with a display/serif heading font (e.g. Inter + Playfair Display) and expose the second family as another `@theme` token (e.g. `--font-serif` or `--font-display`), which Tailwind turns into a `font-serif` / `font-display` utility.
## Color Schemes ## Color Schemes
@@ -55,9 +50,9 @@ Colors are defined as CSS custom properties in `src/index.css` under two selecto
When the user requests a new color scheme: When the user requests a new color scheme:
1. **Update both `:root` and `.dark`** in `src/index.css`. Each variable is an HSL triplet (no `hsl()` wrapper), e.g. `--primary: 222 47% 11%;`. 1. **Update both `:root` and `.dark`** in `src/index.css`. Each variable is a full color value wrapped in `hsl(...)`, e.g. `--primary: hsl(222.2 47.4% 11.2%);`. The `@theme inline` block above maps each `--<token>` to its `--color-<token>` utility, so you don't edit it when only changing values.
2. **Keep contrast ratios ≥ 4.5:1** for body text and interactive elements. Test both modes. 2. **Keep contrast ratios ≥ 4.5:1** for body text and interactive elements. Test both modes.
3. **Prefer extending Tailwind's palette** (`tailwind.config.ts`) over hard-coding hex values in components — this keeps the theme consistent and dark-mode-friendly. 3. **Add new color tokens** under the `@theme inline` block in `src/index.css` (Tailwind v4 is CSS-first — there is no `tailwind.config.ts`). Define the raw value as a `--<token>` on `:root`/`.dark`, then expose it as `--color-<token>: var(--<token>);` inside `@theme inline`.
4. **Apply colors through semantic tokens** (`bg-primary`, `text-muted-foreground`, `border-input`) rather than raw palette names when possible, so future theme changes propagate. 4. **Apply colors through semantic tokens** (`bg-primary`, `text-muted-foreground`, `border-input`) rather than raw palette names when possible, so future theme changes propagate.
The shadcn/ui components already consume these semantic tokens, so changing the variables automatically restyles the entire component library. The shadcn/ui components already consume these semantic tokens, so changing the variables automatically restyles the entire component library.
+1 -1
View File
@@ -29,7 +29,7 @@ This project is a Nostr client application built with React 19.x, TailwindCSS 4.
## UI Components ## UI Components
Components in `@/components/ui` are unstyled, accessible primitives styled with Tailwind. They follow a consistent pattern using `React.forwardRef` and the `cn()` class-merge utility, and many are built on Radix UI primitives. When you need a specific component, list the directory (`ls src/components/ui/`) or import from `@/components/ui/<name>` — all common primitives are present (buttons, inputs, dialogs, dropdowns, forms, tables, etc.). Components in `@/components/ui` are unstyled, accessible primitives styled with Tailwind. They follow a consistent React 19 pattern: plain function components that type props via `React.ComponentProps<...>` and forward `ref` as a normal prop (no `React.forwardRef`), tag their root with a `data-slot` attribute, merge classes with the `cn()` utility, and define variants with `class-variance-authority`. Components built on Radix import from the unified `radix-ui` package (e.g. `import { Dialog as DialogPrimitive } from "radix-ui"`), not individual `@radix-ui/react-*` packages. When you need a specific component, list the directory (`ls src/components/ui/`) or import from `@/components/ui/<name>` — all common primitives are present (buttons, inputs, dialogs, dropdowns, forms, tables, etc.).
## System Prompt Management ## System Prompt Management