diff --git a/src/app.css b/src/app.css index 7e837d6..11e7763 100644 --- a/src/app.css +++ b/src/app.css @@ -9,6 +9,8 @@ @import "./styles/visualize.css"; @import "./styles/asciidoc.css"; @import "theme-tokens.css"; +@import "./styles/a/cards.css"; +@import "./styles/a/forms.css"; @import "./styles/a/primitives.css"; @layer theme, base, components, utilities; @@ -183,28 +185,6 @@ @apply border border-primary-700; } - div.card-leather { - @apply shadow-none text-primary-1000 border-s-4 bg-highlight - border-primary-200 has-[:hover]:border-primary-700; - @apply dark:bg-primary-1000 dark:border-primary-800 - dark:has-[:hover]:bg-primary-950 dark:has-[:hover]:border-primary-500; - } - - div.card-leather h1, - div.card-leather h2, - div.card-leather h3, - div.card-leather h4, - div.card-leather h5, - div.card-leather h6 { - @apply text-gray-900 hover:text-primary-600 dark:text-gray-100 - dark:hover:text-primary-400; - } - - div.card-leather .font-thin { - @apply text-gray-900 hover:text-primary-700 dark:text-gray-100 - dark:hover:text-primary-300; - } - main { @apply max-w-full flex; } @@ -245,15 +225,6 @@ @apply text-gray-900 dark:text-gray-100; } - /* Responsive card styles */ - .responsive-card { - @apply w-full min-w-0 overflow-hidden; - } - - .responsive-card-content { - @apply break-words overflow-hidden; - } - h1.h-leather { @apply text-4xl font-bold; } @@ -323,14 +294,6 @@ dark:hover:text-primary-400; } - div.skeleton-leather div { - @apply bg-primary-100 dark:bg-primary-800; - } - - div.skeleton-leather { - @apply h-48; - } - div.textarea-leather { @apply bg-primary-50 dark:bg-primary-1000; } @@ -453,21 +416,6 @@ dark:hover:text-primary-400; } - /* Card with transition */ - .ArticleBox.grid .ArticleBoxImage { - @apply max-h-0; - transition: max-height 0.5s ease; - } - - .ArticleBox.grid.active .ArticleBoxImage { - @apply max-h-40; - } - - .tags span { - @apply bg-primary-50 text-primary-800 text-sm font-medium me-2 px-2.5 py-0.5 - rounded-sm dark:bg-primary-900 dark:text-primary-200; - } - .npub-badge { @apply inline-flex space-x-1 items-center text-primary-600 dark:text-primary-500 hover:underline me-2 px-2 py-0.5 rounded-sm border diff --git a/src/lib/a/AGENTS.md b/src/lib/a/AGENTS.md new file mode 100644 index 0000000..e34db9c --- /dev/null +++ b/src/lib/a/AGENTS.md @@ -0,0 +1,938 @@ +# Alexandria Component Library - AI Agent Guide + +**Version:** 1.0.0 +**Last Updated:** October 4, 2025 + +This guide provides comprehensive instructions for AI agents working with the Alexandria UI component library. Following these guidelines ensures consistency, maintainability, and proper integration with the existing codebase. + +--- + +## Core Principles + +### 1. Always Check Before Creating +Before creating any new UI component, **you must**: +1. Search the existing component library in `src/lib/a/` +2. Review `alexandria-components.json` for available components +3. Check if an existing component can be reused or extended +4. Only create new components when absolutely necessary + +### 2. Use alexandria-components.json as Your Reference +The `alexandria-components.json` file is the **single source of truth** for all available components. It contains: +- Complete component inventory (18 components across 5 categories) +- Full prop definitions with types and defaults +- Usage examples and patterns +- Features and accessibility information + +**Always consult this file first** when selecting components. + +### 3. Maintain TSDoc Documentation Standards +All components use **TSDoc format** for documentation. You must maintain this standard when creating or modifying components. + +--- + +## Component Inventory + +### Available Categories +1. **Primitives** (8 components) - Basic UI building blocks +2. **Navigation** (2 components) - App navigation elements +3. **Forms** (4 components) - Input and editing interfaces +4. **Cards** (2 components) - Content display cards +5. **Reader** (2 components) - Technical content controls + +--- + +## Component Selection Workflow + +### Step 1: Identify the Need +Determine what UI functionality is required: +- User input? → Check **Forms** category +- Display content? → Check **Cards** category +- Navigation? → Check **Navigation** category +- Basic UI element? → Check **Primitives** category +- Technical content toggle? → Check **Reader** category + +### Step 2: Search alexandria-components.json + +For example: Finding a component for user profiles + +- Search for: "profile", "user", or relevant keywords +- Result: AProfilePreview and ANostrUser are available + +### Step 3: Review Component Props +Check the component's props in `alexandria-components.json`: +```json +{ + "name": "AEventPreview", + "props": [ + { + "name": "event", + "type": ["NDKEvent"], + "required": true, + "description": "The nostr event to display (required)" + }, + { + "name": "showContent", + "type": ["boolean"], + "description": "Whether to show event content", + "required": false + } + // ... more props + ] +} +``` + +### Step 4: Review Examples +Check the `examples` array in `alexandria-components.json` for usage patterns. + +--- + +## TSDoc Documentation Standard + +### Required Documentation Structure + +Every component **must** include TSDoc comments following this exact format: + +````typescript +/** + * @fileoverview ComponentName Component - Alexandria + * + * A brief description of what the component does and its primary purpose. + * Can span multiple lines for detailed explanation. + * + * @component + * @category [Primitives|Navigation|Forms|Cards|Reader] + * + * @prop {type} [propName] - Prop description (if optional) + * @prop {type} propName - Prop description (if required) + * @prop {type} [propName=defaultValue] - Prop with default value + * + * @example + * ```svelte + * + * ``` + * + * + * @features + * - Feature 1 + * - Feature 2 + * - Feature 3 + * + * @accessibility + * - Accessibility feature 1 + * - ARIA compliance notes + * - Keyboard navigation details + */ +```` + +### TSDoc Tags Reference + +| Tag | Purpose | Required | Example | +|-----|---------|----------|---------| +| `@fileoverview` | Component name and description | ✅ Yes | `@fileoverview AAlert Component - Alexandria` | +| `@component` | Marks file as Svelte component | ✅ Yes | `@component` | +| `@category` | Component category | ✅ Yes | `@category Primitives` | +| `@prop` | Define component properties | ✅ Yes | `@prop {string} [color] - Alert color theme` | +| `@example` | Usage examples with code | ✅ Yes | See format above | +| `@features` | List key functionality | ✅ Yes | `- Responsive layout` | +| `@accessibility` | Accessibility notes | ✅ Yes | `- ARIA compliant` | +| `@since` | Version introduced | ⚠️ Optional | `@since 1.0.0` | + +--- + +## Component Import Patterns + +### Import +```typescript +import { AAlert, AEventPreview, AMarkupForm } from '$lib/a'; +``` + +--- + +## Creating New Components + +### When to Create a New Component + +**DO create a new component when:** +- No existing component provides the required functionality +- The component will be reused in 3+ places +- It represents a distinct, standalone UI pattern +- It follows the Alexandria design system + +**DON'T create a new component when:** +- An existing component can be configured to meet needs +- It's only used once (keep in parent component) +- It's too generic (use Flowbite components directly) +- It doesn't fit the Alexandria design system + +### New Component Checklist + +- [ ] **Verify** no existing component can be used +- [ ] **Choose** appropriate category (Primitives/Navigation/Forms/Cards/Reader) +- [ ] **Name** following convention: `A[ComponentName].svelte` +- [ ] **Add TSDoc** documentation following standard format +- [ ] **Create** component file in correct category folder +- [ ] **Add styles** to appropriate `/src/styles/a/` CSS file (or create new file if needed) +- [ ] **Import new CSS file** in `app.css` if created +- [ ] **Export** component in `index.ts` +- [ ] **Update** `alexandria-components.json` (run parse script) +- [ ] **Test** component functionality +- [ ] **Validate** accessibility compliance + +### Component Template + +````svelte + + + +
+ +
+```` + +--- + +## Updating alexandria-components.json + +### When to Update +You **must** update `alexandria-components.json` whenever: +- A new component is created +- Component props are added, modified, or removed +- Component examples are updated +- Component features or accessibility notes change +- Component documentation is enhanced + +### How to Update + +1. **Make your changes** to component TSDoc comments +2. **Run the parser script**: + ```bash + cd src/lib/a + node parse-components.js + ``` +3. **Verify** the generated JSON is valid +4. **Commit** both the component file and updated JSON + +### Parser Script Location +- **File:** `src/lib/a/parse-components.js` +- **Purpose:** Extracts TSDoc from all `.svelte` files in the library +- **Output:** `alexandria-components.json` + +### Manual Updates (When Necessary) +If the parser doesn't capture something correctly: +1. First, try to fix the TSDoc format +2. Re-run the parser +3. Only manually edit JSON as last resort +4. Document any manual changes in comments + +--- + +## Design System Integration + +### Theme Compatibility +All Alexandria components support: +- Light and dark themes +- "Leather" aesthetic (warm browns, tans) +- Flowbite-based styling +- Tailwind CSS utilities + +### Styling Guidelines + +**DO:** +- Use Tailwind CSS classes +- Leverage Flowbite Svelte components as base +- Follow existing color patterns in library +- Ensure responsive design (mobile-first) +- Test in both light and dark modes + +**DON'T:** +- Add arbitrary custom CSS without justification +- Override Flowbite's accessibility features +- Hard-code colors (use theme tokens) +- Create layout inconsistencies + +### Component Styling Pattern +```svelte + + + + +``` + +--- + +## Styling Architecture (CRITICAL) + +### **Mandatory Styling Rules** + +⚠️ **ALL custom styles for Alexandria components MUST go in the `/src/styles/a/` folder.** + +**DO NOT add ` +``` + +### Checklist for Adding Styles + +- [ ] Identified component category (primitives/forms/cards/nav/reader) +- [ ] Checked if corresponding CSS file exists in `src/styles/a/` +- [ ] Created new CSS file if needed (e.g., `nav.css`, `reader.css`) +- [ ] Added import to `src/app.css` for new CSS file +- [ ] Used `@layer components` directive +- [ ] Followed naming conventions (`-leather` or `-alexandria` suffix) +- [ ] Used Tailwind `@apply` directive instead of custom CSS +- [ ] Added comments to organize styles by component +- [ ] Tested in both light and dark themes +- [ ] Verified no `