From 772479e232f7ffb982dd27bf533d327ffab9606e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 5 Jun 2026 09:43:15 -0500 Subject: [PATCH] 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 --- .agents/skills/ai-chat/SKILL.md | 6 +-- .../files/components/EditProfileForm.tsx | 6 +-- .../nwc/files/components/WalletModal.tsx | 37 ++++++++++--------- .../skills/nwc/files/components/ZapDialog.tsx | 11 +++--- .agents/skills/theming/SKILL.md | 23 +++++------- AGENTS.md | 2 +- 6 files changed, 41 insertions(+), 44 deletions(-) diff --git a/.agents/skills/ai-chat/SKILL.md b/.agents/skills/ai-chat/SKILL.md index 180f661..b9670e9 100644 --- a/.agents/skills/ai-chat/SKILL.md +++ b/.agents/skills/ai-chat/SKILL.md @@ -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"; - + Hidden Title for Screen Readers - + ``` diff --git a/.agents/skills/edit-profile/files/components/EditProfileForm.tsx b/.agents/skills/edit-profile/files/components/EditProfileForm.tsx index a8e3a46..3744f6f 100644 --- a/.agents/skills/edit-profile/files/components/EditProfileForm.tsx +++ b/.agents/skills/edit-profile/files/components/EditProfileForm.tsx @@ -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 = ({ +const ImageUploadField = ({ field, label, placeholder, description, previewType, onUpload, -}) => { +}: ImageUploadFieldProps) => { const fileInputRef = useRef(null); return ( diff --git a/.agents/skills/nwc/files/components/WalletModal.tsx b/.agents/skills/nwc/files/components/WalletModal.tsx index 280052c..d39e26f 100644 --- a/.agents/skills/nwc/files/components/WalletModal.tsx +++ b/.agents/skills/nwc/files/components/WalletModal.tsx @@ -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 void; connectionUri: string; setConnectionUri: (value: string) => void; -}>(({ alias, setAlias, connectionUri, setConnectionUri }, ref) => ( + ref?: React.Ref; +}) => (
@@ -64,11 +65,20 @@ const AddWalletContent = forwardRef
-)); -AddWalletContent.displayName = 'AddWalletContent'; +); // Extracted WalletContent to prevent re-renders -const WalletContent = forwardRef void; handleRemoveConnection: (cs: string) => void; setAddDialogOpen: (open: boolean) => void; -}>(({ - webln, - hasNWC, - connections, - connectionInfo, - activeConnection, - handleSetActive, - handleRemoveConnection, - setAddDialogOpen -}, ref) => ( + ref?: React.Ref; +}) => (
{/* Current Status */}
@@ -201,8 +203,7 @@ const WalletContent = forwardRef )}
-)); -WalletContent.displayName = 'WalletContent'; +); export function WalletModal({ children, className }: WalletModalProps) { const [open, setOpen] = useState(false); diff --git a/.agents/skills/nwc/files/components/ZapDialog.tsx b/.agents/skills/nwc/files/components/ZapDialog.tsx index a7eb287..2aa8e9c 100644 --- a/.agents/skills/nwc/files/components/ZapDialog.tsx +++ b/.agents/skills/nwc/files/components/ZapDialog.tsx @@ -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; zap: (amount: number, comment: string) => void; + ref?: React.Ref; } // Moved ZapContent outside of ZapDialog to prevent re-renders causing focus loss -const ZapContent = forwardRef(({ +const ZapContent = ({ invoice, amount, comment, @@ -82,7 +83,8 @@ const ZapContent = forwardRef(({ setComment, inputRef, zap, -}, ref) => ( + ref, +}: ZapContentProps) => (
{invoice ? (
@@ -232,8 +234,7 @@ const ZapContent = forwardRef(({ )}
-)); -ZapContent.displayName = 'ZapContent'; +); export function ZapDialog({ target, children, className }: ZapDialogProps) { const [open, setOpen] = useState(false); diff --git a/.agents/skills/theming/SKILL.md b/.agents/skills/theming/SKILL.md index 6c309a7..fac3809 100644 --- a/.agents/skills/theming/SKILL.md +++ b/.agents/skills/theming/SKILL.md @@ -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 `--` to its `--color-` 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 `--` on `:root`/`.dark`, then expose it as `--color-: var(--);` 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. diff --git a/AGENTS.md b/AGENTS.md index 3a066a0..6478f9b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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/` — 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/` — all common primitives are present (buttons, inputs, dialogs, dropdowns, forms, tables, etc.). ## System Prompt Management