1---2name: svelte-ui-standards3description: Coding standards and UI guidelines for the PolyFlup Svelte dashboard.4---56## Svelte & Frontend Standards78### Formatting (Biome)9- **Indentation**: 2 spaces (enforced by biome.json)10- **Style**: Space indent, recommended rules enabled11- Ignore CSS files from formatting1213### File Structure14- Components in `ui/src/lib/components/`15- UI components in `ui/src/lib/components/ui/`16- Each component exports from `index.ts`17- Stores in `ui/src/lib/stores/`1819### Naming20- **Components**: `PascalCase.svelte` (e.g., `App.svelte`)21- **Utilities**: `camelCase.js` (e.g., `theme.js`)22- **CSS classes**: Tailwind utility classes2324### Svelte Patterns25- Use reactive declarations: `$: winRate = ...`26- Prefer `{#snippet}` for chart tooltips (Svelte 5 syntax)27- Use `onMount` for initialization and intervals28- Clean up intervals in return function29- Store pattern for global state (e.g., theme store)3031### Component Library Stack32- **shadcn-svelte**: Accessible UI components with customizable styling33- **Lucide Icons**: Modern icon set (Activity, TrendingUp, Award, etc.)34- **LayerChart**: D3-based charting library (AreaChart, BarChart)35- **d3-scale**: Scaling functions for charts (scaleBand, etc.)3637### Theme System38- Dark/Light mode toggle with persistent storage39- Uses CSS variables for theming (`var(--color-chart-1)`, etc.)40- Theme store pattern: `theme.init()`, `theme.toggle()`, `$theme`41- Tailwind dark mode classes: `dark:bg-slate-900`4243### API Integration44- **Endpoint**: `http://${hostname}:3001/api/stats`45- **Polling**: Every 5 seconds for real-time updates46- **Error Handling**: Display error banner on connection failure47- **Loading States**: Show loading indicator while fetching initial data4849### Data Visualization50- **Equity Curve**: AreaChart with cumulative PnL (last 50 trades)51- **Asset Breakdown**: BarChart with per-symbol PnL52- **Color Coding**: 53 - BTC: `rgb(255, 153, 0)` (orange)54 - ETH: `rgb(99, 127, 235)` (blue)55 - SOL: `rgb(153, 69, 255)` (purple)56 - XRP: `rgb(2, 140, 255)` (cyan)57- **Conditional Colors**: Green for profits, red for losses5859### Table Display60- Recent trades table with live streaming data61- Columns: ID, Time (UTC), Market, Side, Edge, Price, PnL, Status62- Status badges: LIVE (amber), STOP LOSS (destructive), TAKE PROFIT (emerald), REVERSED (outline), SETTLED (secondary)63- Side badges with emojis: 📈 UP (default), 📉 DOWN (destructive)6465### Stats Cards66- Grid layout: 1 col mobile, 2 cols tablet, 4 cols desktop67- Key metrics: Total PnL, Win Rate, Stop Losses, Take Profits68- Conditional colors: emerald-600 for positive, rose-600 for negative69- Uppercase tracking labels with icons70- Arrow indicators: ArrowUpRight (positive), ArrowDownRight (negative)