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:
```tsx
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import { VisuallyHidden } from "radix-ui";
<DialogHeader>
<VisuallyHidden>
<VisuallyHidden.Root>
<DialogTitle>Hidden Title for Screen Readers</DialogTitle>
</VisuallyHidden>
</VisuallyHidden.Root>
</DialogHeader>
```
@@ -22,7 +22,7 @@ import { NSchema as n, type NostrMetadata } from '@nostrify/nostrify';
import { useQueryClient } from '@tanstack/react-query';
import { useUploadFile } from '@/hooks/useUploadFile';
export const EditProfileForm: React.FC = () => {
export const EditProfileForm = () => {
const queryClient = useQueryClient();
const { user, metadata } = useCurrentUser();
@@ -284,14 +284,14 @@ interface ImageUploadFieldProps {
onUpload: (file: File) => void;
}
const ImageUploadField: React.FC<ImageUploadFieldProps> = ({
const ImageUploadField = ({
field,
label,
placeholder,
description,
previewType,
onUpload,
}) => {
}: ImageUploadFieldProps) => {
const fileInputRef = useRef<HTMLInputElement>(null);
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 { Button } from '@/components/ui/button';
import {
@@ -37,12 +37,13 @@ interface WalletModalProps {
}
// Extracted AddWalletContent to prevent re-renders
const AddWalletContent = forwardRef<HTMLDivElement, {
const AddWalletContent = ({ alias, setAlias, connectionUri, setConnectionUri, ref }: {
alias: string;
setAlias: (value: string) => void;
connectionUri: string;
setConnectionUri: (value: string) => void;
}>(({ alias, setAlias, connectionUri, setConnectionUri }, ref) => (
ref?: React.Ref<HTMLDivElement>;
}) => (
<div className="space-y-4 px-4" ref={ref}>
<div>
<Label htmlFor="alias">Wallet Name (optional)</Label>
@@ -64,11 +65,20 @@ const AddWalletContent = forwardRef<HTMLDivElement, {
/>
</div>
</div>
));
AddWalletContent.displayName = 'AddWalletContent';
);
// Extracted WalletContent to prevent re-renders
const WalletContent = forwardRef<HTMLDivElement, {
const WalletContent = ({
webln,
hasNWC,
connections,
connectionInfo,
activeConnection,
handleSetActive,
handleRemoveConnection,
setAddDialogOpen,
ref,
}: {
webln: WebLNProvider | null;
hasNWC: boolean;
connections: NWCConnection[];
@@ -77,16 +87,8 @@ const WalletContent = forwardRef<HTMLDivElement, {
handleSetActive: (cs: string) => void;
handleRemoveConnection: (cs: string) => void;
setAddDialogOpen: (open: boolean) => void;
}>(({
webln,
hasNWC,
connections,
connectionInfo,
activeConnection,
handleSetActive,
handleRemoveConnection,
setAddDialogOpen
}, ref) => (
ref?: React.Ref<HTMLDivElement>;
}) => (
<div className="space-y-6 px-4 pb-4" ref={ref}>
{/* Current Status */}
<div className="space-y-3">
@@ -201,8 +203,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
</>
)}
</div>
));
WalletContent.displayName = 'WalletContent';
);
export function WalletModal({ children, className }: WalletModalProps) {
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 { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
@@ -64,10 +64,11 @@ interface ZapContentProps {
setComment: (comment: string) => void;
inputRef: React.RefObject<HTMLInputElement | null>;
zap: (amount: number, comment: string) => void;
ref?: React.Ref<HTMLDivElement>;
}
// Moved ZapContent outside of ZapDialog to prevent re-renders causing focus loss
const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
const ZapContent = ({
invoice,
amount,
comment,
@@ -82,7 +83,8 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
setComment,
inputRef,
zap,
}, ref) => (
ref,
}: ZapContentProps) => (
<div ref={ref}>
{invoice ? (
<div className="flex flex-col h-full min-h-0">
@@ -232,8 +234,7 @@ const ZapContent = forwardRef<HTMLDivElement, ZapContentProps>(({
</>
)}
</div>
));
ZapContent.displayName = 'ZapContent';
);
export function ZapDialog({ target, children, className }: ZapDialogProps) {
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';
```
3. **Register the family** in `tailwind.config.ts`:
```ts
export default {
theme: {
extend: {
fontFamily: {
sans: ['Inter Variable', 'Inter', 'system-ui', 'sans-serif'],
},
},
},
};
3. **Register the family** in the `@theme` block of `src/index.css` (Tailwind v4 is CSS-first — there is no `tailwind.config.ts`):
```css
@theme {
--font-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
@@ -44,7 +39,7 @@ Any Google Font can be installed via the `@fontsource` / `@fontsource-variable`
- **Creative / Artistic:** Poppins, Nunito, Comfortaa
- **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
@@ -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:
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.
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.
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
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