# RAVN UI: Comprehensive AI & Developer Guide RAVN UI is a high-fidelity, minimal, and "CDN-first" UI system designed for building elite SaaS dashboards in minutes. It eliminates the complexity of modern build chains (Tailwind, Webpack, PostCSS) in favor of pure, semantic CSS and high-performance Javascript. ## 🎯 Purpose & Philosophy The primary goal of RAVN UI is **speed to high-fidelity**. - **No Tailwind Dependency**: Avoids utility-class bloat while maintaining a professional look. - **Zero Configuration**: A fully functional, themed environment is one `` tag away. - **SaaS First**: Every component is optimized for high-density, data-heavy dashboard interfaces. - **PHP-Style Organization**: Encourages a clean, logical file structure (Assets/Pages/Functions) that is easy for both humans and AI to navigate. --- ## 🏗️ Core Architecture ### 1. The Design System (CSS) The CSS is split into four layers: - **Tokens (`tokens.css`)**: Defines the core design language—colors, spacing scale (1-12), typography, and shadows using CSS variables. - **Base (`base.css`)**: Resets the browser defaults and sets up the foundation (typography, scrollbars, etc.). - **Components (`components.css`)**: Semantic classes for complex elements (`.card`, `.btn`, `.sidebar`, `.layout-shell`, `.table`). - **Utilities (`utilities.css`)**: Low-level helper classes for layout (`.flex`, `.grid`, `.gap-*`, `.mt-*`, `.text-*`). ### 2. Theming System (`themes.css`) RAVN UI supports 12+ premium themes (Dark, Zinc, Claude, Midnight, Indigo, etc.) via the `data-theme` attribute on the `` or `` tag. - Themes redefine the core semantic variables (e.g., `--primary`, `--background`, `--card`). - The library uses **glassmorphism** and subtle gradients in dark modes for a premium feel. ### 3. Logic & SPA Utilities (`ui.js`) The `RAVN` global object provides high-level control: - **`RAVN.store`**: Global reactive state management (`.set`, `.get`, `.subscribe`). - **`RAVN.route(path)`**: Handles SPA navigation, URL hash syncing, and view swapping. - **`RAVN.on(event, selector, handler)`**: Built-in event delegation to avoid inline `onclick`. - **`RAVN.fetch(url, options)`**: Minimal wrapper over native fetch that returns JSON. - **`RAVN.toggleSidebar()`**: Manages the `.sidebar-collapsed` state on the ``. --- ## 📂 Project Structure (Recommended) When an AI or developer works on a RAVN UI project, they should adhere to this "Classic/PHP-style" organization: - `/index.html`: The root entry point. - `/css/app.css`: Custom project-specific overrides. - `/app.js`: Application logic entry point with the standard `render()` pattern. - `/components/`: Pure functions returning HTML strings (e.g., `card.js`, `modal.js`). - `/functions/`: Reusable Javascript utility modules (e.g., `store.js`, `api.js`). - `/pages/`: Secondary HTML views (for MPA architecture). --- ## 🧩 Key Components for AI to Know ### The Layout Shell ```html
...
...
``` - **`.layout-shell`**: Flex container for the entire app. - **`.layout-sidebar`**: Fixed-width navigation area. Supports collapse. - **`.layout-main`**: Scrollable content area. ### Dashboard Metrics ```html
REVENUE
$45,231.89
↑ 12%
``` - **`.metrics-grid`**: Responsive grid (usually 2 or 3 columns) optimized for "at-a-glance" stats. --- ## 🛠️ CLI Operations (`bin/ravn.js`) The CLI is a project initializer that handles: 1. **Name/Path**: Supports `.` for current directory initialization. 2. **Templates**: Choice of SaaS Dashboard (SPA-ready), Landing Page (Marketing), or Minimal. 3. **Themes**: Injects the selected theme into the `data-theme` attribute. 4. **Install Method**: - **CDN**: Uses remote `unpkg` links. - **Local**: Runs `bun add @ravn-ui/core` and configures local `node_modules` paths for offline development. --- ## 🏎️ Hybrid SPA Architecture RAVN UI projects use a **Hybrid SPA** model, giving developers the performance of an SPA with the maintainability of a multi-page app. ### 1. The SPA Hub (`index.html`) - **Core Strategy**: The main dashboard shell is an SPA. - **`data-view`**: Internal dashboard tabs (Overview, Analytics, Stats) are handled within `index.html` using the `RAVN.view()` engine. - **Benefits**: Instant transitions, zero-refresh feel, and persistent sidebar state. ### 2. Multi-Page Extensions (`/pages/`) - **Core Strategy**: Distinctly different functional areas (Settings, User Management, Billing) are stored in separate `.html` files within the `pages/` directory. - **Benefits**: Keeps the codebase modular, prevents `index.html` from becoming monolithic, and simplifies deployment to static hosts like Vercel. ### 3. Navigation Logic - **Internal (SPA)**: Elements with `data-target-view="id"` trigger `RAVN.view(id)` to swap content blocks without a page load. - **External (MPA)**: Standard `` links are used to navigate between the SPA hub and modular pages. --- ## 🤖 Instructions for AI Assistants When assisting with a RAVN UI project: 1. **Golden Patterns**: ALWAYS use the Micro-Component pattern (JS functions returning HTML strings) instead of innerHTML soup. Use `RAVN.on()` for event delegation. NEVER use inline `onclick` handlers. 2. **Prefer Hybrid Navigation**: Use `RAVN.route()` and `data-route` for fast dashboard tabs and separate `pages/` files for distinct application sections. 3. **Persistent Layouts**: When creating new pages in `pages/`, ensure they replicate the `.layout-shell` and sidebar structure. 4. **Semantic Over Utilities**: Use `.card`, `.btn-success`, `.table` before reaching for utility classes. 5. **Theming Consistency**: Never hardcode colors. Use semantic variables. --- ## 🔗 Official Distribution - **NPM**: `@ravn-ui/core` - **CDN Base**: `https://unpkg.com/@ravn-ui/core/dist/`