# warcraftcn-ui-svelte > A Svelte 5 UI component library styled after the classic Warcraft III RTS aesthetics — fantasy borders, scroll textures, faction-based color themes, and gold/amber color palettes. - Svelte Port Repository: https://github.com/magooney-loon/warcraftcn-ui-svelte - Original Repository (React/Next.js): https://github.com/TheOrcDev/warcraftcn-ui - Website: https://warcraftcn.com - License: MIT ## Installation ```bash npm install warcraftcn-ui-svelte ``` Requires Svelte 5 as a peer dependency. Designed for Tailwind CSS v4. ## Quick Setup Add the `` to your root layout for toast notifications: ```svelte ``` Import the library's CSS in your app (e.g., `app.html` or root layout): ```ts import 'warcraftcn-ui-svelte/warcraft.css'; ``` ## Faction Theming Many components accept a `faction` prop with unique styling per faction: | Faction | Description | | --------- | ---------------------------------- | | default | Gold/amber — standard Warcraft III | | orc | Red tones — Orcish Horde | | human | Blue tones — Human Alliance | | elf | Green tones — Night Elf | | undead | Purple tones — Undead Scourge | --- ## Components All components are exported from `warcraftcn-ui-svelte`. ### Accordion Expandable/collapsible sections with animated sword/shield/rune icons and scroll textures. ```svelte Section Title Content here ``` **Accordion Props:** - `type?: 'single' | 'multiple'` — Single allows one open item; multiple allows any number. Default: `'multiple'`. - `class?: string` **AccordionItem Props:** - `value: string` — Unique identifier for this item. - `class?: string` **AccordionTrigger Props:** - `value: string` — Must match the parent AccordionItem's value. - `icon?: 'sword' | 'shield' | 'rune-stone'` — Icon displayed on the trigger. Default: `'sword'`. - `class?: string` **AccordionContent Props:** - `value: string` — Must match the parent AccordionItem's value. - `class?: string` --- ### Avatar Faction-themed avatar with image, fallback slot, and frame overlay. ```svelte H ``` **Props:** - `src?: string` — Image URL. If empty, shows the fallback snippet. - `alt?: string` — Image alt text. - `fallback?: Snippet` — Content shown when no `src` is provided. - `faction?: 'default' | 'orc' | 'elf' | 'human' | 'undead'` — Default: `'default'`. - `size?: 'sm' | 'md' | 'lg'` — Default: `'md'`. - `class?: string` --- ### Badge Inline badge with variant, faction, size, and shape options. ```svelte Quest Danger Alliance Horde ``` **Props:** - `variant?: 'default' | 'secondary' | 'destructive' | 'outline'` — Default: `'default'`. - `size?: 'default' | 'sm' | 'lg'` — Default: `'default'`. - `faction?: 'none' | 'alliance' | 'horde'` — Default: `'none'`. - `shape?: 'default' | 'shield' | 'banner'` — Default: `'default'`. - `class?: string` --- ### Button Fantasy-themed button with `border-image` frame styles. ```svelte Default Button Frame Button ``` **Props:** - `variant?: 'default' | 'frame'` — Default uses standard border; frame uses the ornate frame border-image. Default: `'default'`. - `class?: string` - `style?: string` - All native `` HTML attributes are forwarded via `...rest`. --- ### Card Compound component with header, content, footer, and optional action slot. Uses `border-image` for the Warcraft card frame. ```svelte Quest Log Active quests in your journal Accept Defeat the dragon lord. 3 remaining ``` **Card Props:** - `size?: 'default' | 'sm'` — Controls border thickness and padding. Default: `'default'`. - `class?: string` **CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter Props:** - `class?: string` - All accept `children: Snippet`. --- ### Checkbox Faction-themed checkbox with bindable `checked` state. ```svelte Accept quest terms ``` **Props:** - `checked?: boolean` — Bindable. Default: `false`. - `faction?: 'default' | 'orc' | 'elf' | 'human' | 'undead'` — Default: `'default'`. - `disabled?: boolean` — Default: `false`. - `id?: string` - `class?: string` --- ### Cursor Wraps content with a faction-based custom CSS cursor. ```svelte This area has the Orc cursor ``` **Props:** - `faction?: 'default' | 'orc' | 'elf' | 'human' | 'undead'` — Default: `'default'`. - `class?: string` --- ### Dropdown Menu Full dropdown menu with fantasy-themed borders, click-outside closing, and keyboard support. ```svelte Open Menu Actions Edit ⌘E Delete ``` **DropdownMenu Props:** - `class?: string` **DropdownMenuTrigger Props:** - `class?: string` **DropdownMenuContent Props:** - `class?: string` - Uses `clickOutside` action to auto-close. **DropdownMenuItem Props:** - `disabled?: boolean` - `class?: string` - Clicking an item closes the menu. **DropdownMenuLabel Props:** - `class?: string` **DropdownMenuSeparator Props:** - `class?: string` **DropdownMenuShortcut Props:** - `class?: string` --- ### Input Text input with Warcraft-themed `border-image` frame. ```svelte ``` **Props:** - `type?: string` — HTML input type. Default: `'text'`. - `class?: string` - All native `` HTML attributes are forwarded. --- ### Label Fantasy-styled label with required indicator and muted variant. ```svelte Character Name Required Field Optional Info Disabled Label ``` **Props:** - `variant?: 'default' | 'muted'` — Default shows amber text with glow; muted shows dimmer text. Default: `'default'`. - `required?: boolean` — Shows a red ✦ indicator. Default: `false`. - `disabled?: boolean` — Adds disabled styling. Default: `false`. - `class?: string` --- ### Modal Modal dialog built on top of Card. Supports backdrop dismiss, Escape key, and two sizes. ```svelte Open Modal Quest Offer A mysterious task... Retrieve the enchanted amulet. Accept Quest ``` **Modal Props:** - `open?: boolean` — Bindable. Controls the open/closed state. Default: `false`. - `class?: string` **ModalTrigger Props:** - `class?: string` - All native `` HTML attributes are forwarded. **ModalContent Props:** - `size?: 'default' | 'sm'` — Matches the Card size. Default: `'default'`. - `class?: string` --- ### Pagination Navigation component for paging through content. Uses Button's frame border styling. ```svelte 1 2 ``` **Pagination Props:** `class?: string` **PaginationContent Props:** `class?: string` **PaginationItem Props:** `class?: string` **PaginationLink Props:** - `isActive?: boolean` — Highlights as current page. Default: `false`. - `disabled?: boolean` - `href?: string` - `class?: string` **PaginationPrevious / PaginationNext Props:** - `href?: string` - `disabled?: boolean` - `class?: string` **PaginationEllipsis Props:** - `class?: string` --- ### Radio Group Faction-themed radio buttons with bindable `value` state. ```svelte Orc Human ``` **RadioGroup Props:** - `value?: string` — Bindable. Currently selected value. Default: `''`. - `orientation?: 'vertical' | 'horizontal'` — Default: `'vertical'`. - `disabled?: boolean` — Disables all items. Default: `false`. - `name?: string` — Form field name. - `class?: string` **RadioGroupItem Props:** - `value: string` — The value this radio represents. - `disabled?: boolean` - `class?: string` --- ### Skeleton Pulsing fantasy-themed placeholder with faction variants. ```svelte ``` **Props:** - `variant?: 'default' | 'circular'` — Default: `'default'`. - `faction?: 'default' | 'orc' | 'elf' | 'human' | 'undead'` — Default: `'default'`. - `class?: string` --- ### Spinner SVG-based loading spinner with Warcraft III rune aesthetics. ```svelte ``` **Props:** - `class?: string` --- ### Tabs Faction-themed tabs supporting horizontal and vertical orientation with bindable `value`. ```svelte Inventory Spells Stats Sword, Shield, Potion Fireball, Heal ``` **Tabs Props:** - `value?: string` — Bindable. The active tab value. Default: `''`. - `faction?: 'default' | 'orc' | 'elf' | 'human' | 'undead'` — Default: `'default'`. - `orientation?: 'horizontal' | 'vertical'` — Default: `'horizontal'`. - `class?: string` **TabsList Props:** - `class?: string` **TabsTrigger Props:** - `value: string` — Matches against the parent Tabs' `value`. - `disabled?: boolean` — Default: `false`. - `class?: string` **TabsContent Props:** - `value: string` — Shown when this value matches the active tab. - `class?: string` --- ### Textarea Styled textarea with Warcraft frame border. ```svelte ``` **Props:** - `class?: string` - All native `` HTML attributes are forwarded. --- ### Toast / Toaster Scroll-unroll animated toast system with 5 faction themes and 5 variants. Place `` in your root layout, then trigger toasts from anywhere. ```svelte ``` ```svelte triggerScrollToast({ message: 'Quest accepted!', faction: 'orc', variant: 'success' })}> Accept Quest ``` **Toaster Props:** - `position?: ToastPosition` — Filter toasts to a specific position. If omitted, renders all toasts grouped by position. - `class?: string` **ToastPosition type:** `'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'` **triggerScrollToast(options):** - `message?: string` — Toast message text. - `faction?: ScrollFaction` — `'default' | 'orc' | 'elf' | 'human' | 'undead'`. Default: `'default'`. - `variant?: ToastVariant` — `'default' | 'success' | 'error' | 'warning' | 'info'`. Default: `'default'`. - `durationMs?: number` — Duration in milliseconds. Default: `5000`. - `position?: ToastPosition` — Default: `'top-center'`. **Other exports:** - `addToast(options)` — Adds a toast and returns its ID. - `removeToast(id)` — Removes a toast by ID. - `getToasts()` — Returns the current array of toasts. --- ### Tooltip Fantasy-themed tooltip with WoW-style rarity variants (default, uncommon, rare, epic, legendary). Positioned via fixed positioning relative to the trigger. ```svelte Hover me Legendary Sword Increases attack power by 42 ``` **Tooltip Props:** - `variant?: 'default' | 'uncommon' | 'rare' | 'epic' | 'legendary'` — Color theme. Default: `'default'`. - `side?: 'top' | 'bottom' | 'left' | 'right'` — Placement relative to trigger. Default: `'bottom'`. - `sideOffset?: number` — Distance in px from trigger. Default: `8`. - `class?: string` **TooltipTrigger Props:** `class?: string` **TooltipContent Props:** `class?: string` **TooltipTitle Props:** `class?: string` **TooltipBody Props:** `class?: string` --- ## Actions ### clickOutside A Svelte action that fires a callback when clicking outside the target element. ```svelte console.log('clicked outside')}> Inner content ``` **Signature:** `clickOutside(node: HTMLElement, callback: () => void): { destroy(): void }` --- ## CSS Architecture The library uses `warcraft.css` for its core styling: - **Border images**: `wc-*` class prefixes define `border-image-source` rules (e.g., `wc-btn-border`, `wc-card-border`, `wc-dropdown-border`). - **Animations**: Keyframe-based animations for accordion open/close, light sweep, skeleton shimmer, spinner rotation. - **Component sizes**: CSS `border-image-slice` and `border-width` control the ornate frame effect. - **Faction classes**: Each faction maps to different `border-image`, background images, and color schemes via CSS classes like `wc-tabs-orc`, `wc-skeleton-human`, etc. ## Tech Stack | Layer | Technology | | ---------- | ----------------- | | Framework | Svelte 5 (Runes) | | Language | TypeScript | | Styling | Tailwind CSS v4 | | Animations | Svelte transitions and motion (tweened) | | Packaging | `@sveltejs/package` |
Defeat the dragon lord.
This area has the Orc cursor
Retrieve the enchanted amulet.