windjammer-ui 0.3.3

Cross-platform UI framework for Windjammer (Web, Desktop, Mobile)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# 🎨 Windjammer UI

**Pure Windjammer UI framework - Zero HTML/CSS/JavaScript required**

[![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](LICENSE)
[![Components](https://img.shields.io/badge/components-55-brightgreen.svg)](#component-library)
[![Status](https://img.shields.io/badge/status-production%20ready-success.svg)](#status)
[![Windjammer](https://img.shields.io/badge/windjammer-0.37.2+-blue.svg)](https://crates.io/crates/windjammer)

---

## 🚀 Quick Start

### Write Pure Windjammer

```windjammer
use windjammer_ui::*

fn main() {
    let app = Container::new()
        .child(Text::new("Hello, World!").size(TextSize::XLarge).bold().render())
        .child(Button::new("Click Me").variant(ButtonVariant::Primary).render())
        .child(Alert::success("Ready to build!").render())
        .render()
    
    println!("{}", app)
}
```

**That's it!** No HTML, no CSS, no JavaScript. Just pure Windjammer.

---

## ✨ Key Features

| Feature | Description |
|---------|-------------|
| 🎯 **Pure Windjammer** | Write only `.wj` files - zero HTML/CSS/JS |
| 📦 **55 Components** | Complete UI library from buttons to chat interfaces |
| 💬 **Chat Ready** | Built-in ChatGPT-style message components |
| 🎨 **Beautiful Styling** | Production-ready designs out of the box |
| 🌙 **Dark Mode** | Built-in theme support |
| 🏗️ **Builder Pattern** | Fluent, chainable APIs |
| 🔒 **Type Safe** | Compile-time guarantees |
|**Zero Runtime** | Compiles to native Rust |
| 📱 **Responsive** | Mobile-friendly layouts |

---

## 🎨 Component Library

**[→ View Live Interactive Gallery]examples/gallery.html** | **49 Components, 100% Windjammer**

### 📝 Basic Components (7)

<table>
<tr>
<td width="25%"><strong>Text</strong><br/><code>Text::new("Hello")</code></td>
<td width="25%"><strong>Button</strong><br/><code>Button::new("Click")</code></td>
<td width="25%"><strong>Input</strong><br/><code>Input::new()</code></td>
<td width="25%"><strong>Checkbox</strong><br/><code>Checkbox::new()</code></td>
</tr>
<tr>
<td width="25%"><strong>Slider</strong><br/><code>Slider::new()</code></td>
<td width="25%"><strong>Badge</strong><br/><code>Badge::new("New")</code></td>
<td width="25%"><strong>Alert</strong><br/><code>Alert::success("Done!")</code></td>
<td width="25%"></td>
</tr>
</table>

```windjammer
// Text with styling
Text::new("Welcome").size(TextSize::XLarge).bold().render()

// Button variants
Button::new("Primary").variant(ButtonVariant::Primary).render()
Button::new("Success").variant(ButtonVariant::Success).render()
Button::new("Danger").variant(ButtonVariant::Danger).render()

// Alert types
Alert::success("Operation completed!").render()
Alert::error("Something went wrong!").render()
Alert::warning("Please review").render()
Alert::info("Did you know?").render()
```

---

### 🏗️ Layout Components (8)

<table>
<tr>
<td><strong>Container</strong> - Centered max-width wrapper</td>
<td><strong>Flex</strong> - Flexbox layouts (row/column)</td>
</tr>
<tr>
<td><strong>Grid</strong> - CSS Grid with N columns</td>
<td><strong>Panel</strong> - Bordered container with header</td>
</tr>
<tr>
<td><strong>Divider</strong> - Visual separator (H/V)</td>
<td><strong>Spacer</strong> - Flexible spacing</td>
</tr>
<tr>
<td><strong>ScrollArea</strong> - Scrollable content</td>
<td><strong>SplitPanel</strong> - Resizable split view</td>
</tr>
</table>

```windjammer
// Flex layout
Flex::new()
    .direction(FlexDirection::Row)
    .gap("16px")
    .child(Button::new("Left").render())
    .child(Button::new("Right").render())
    .render()

// Grid layout
Grid::new()
    .columns(3)
    .gap("12px")
    .child("<div>Item 1</div>")
    .child("<div>Item 2</div>")
    .child("<div>Item 3</div>")
    .render()

// Panel with title
Panel::new()
    .title("Settings")
    .child("<p>Panel content here</p>")
    .collapsible(true)
    .render()
```

---

### 📋 Form Components (7)

<table>
<tr>
<td><strong>Switch</strong> - Toggle switch</td>
<td><strong>Radio</strong> - Radio button group</td>
<td><strong>Select</strong> - Dropdown menu</td>
</tr>
<tr>
<td><strong>Checkbox</strong> - Boolean input</td>
<td><strong>Slider</strong> - Numeric range</td>
<td><strong>Input</strong> - Text field</td>
<td><strong>ColorPicker</strong> - Color selector</td>
</tr>
</table>

```windjammer
// Switch
Switch::new()
    .label("Enable notifications")
    .checked(true)
    .render()

// Radio group
RadioGroup::new("size")
    .option(RadioOption::new("small", "Small"))
    .option(RadioOption::new("large", "Large"))
    .selected("small")
    .render()

// Select dropdown
Select::new()
    .option(SelectOption::new("1", "Option 1"))
    .option(SelectOption::new("2", "Option 2"))
    .selected("1")
    .render()
```

---

### 💾 Data Display (5)

<table>
<tr>
<td><strong>Card</strong> - Content container with styling</td>
<td><strong>Progress</strong> - Progress bar with variants</td>
</tr>
<tr>
<td><strong>Spinner</strong> - Loading indicator</td>
<td><strong>Avatar</strong> - User profile image</td>
<td><strong>Skeleton</strong> - Loading placeholder</td>
</tr>
</table>

```windjammer
// Card with content
Card::new()
    .title("Welcome")
    .child("<p>Card content goes here</p>")
    .padding("24px")
    .render()

// Progress bar
Progress::new()
    .value(75)
    .max(100)
    .variant(ProgressVariant::Success)
    .show_label(true)
    .render()

// Avatar
Avatar::new()
    .src("user.jpg")
    .alt("John Doe")
    .size(AvatarSize::Large)
    .render()
```

---

### 💬 Chat & Messaging Components (5) **NEW!**

<table>
<tr>
<td><strong>ChatMessage</strong> - Message bubbles (user/assistant/system)</td>
<td><strong>MessageList</strong> - Scrollable chat history</td>
</tr>
<tr>
<td><strong>ChatInput</strong> - Multi-line input with send button</td>
<td><strong>TypingIndicator</strong> - Animated typing dots</td>
</tr>
<tr>
<td><strong>CodeBlock</strong> - Code display with copy button</td>
<td></td>
</tr>
</table>

```windjammer
// Build a ChatGPT-style interface
MessageList::new()
    .message(
        ChatMessage::new("Hello!")
            .role(MessageRole::User)
            .timestamp("2:30 PM")
            .render()
    )
    .message(
        ChatMessage::new("Hi! How can I help you?")
            .role(MessageRole::Assistant)
            .render()
    )
    .message(TypingIndicator::new().render())
    .render()

// Chat input with send button
ChatInput::new()
    .placeholder("Type your message...")
    .multiline(true)
    .rows(3)
    .render()

// Code block with copy
CodeBlock::new("fn main() { println!(\"Hello!\"); }")
    .language("rust")
    .show_copy_button(true)
    .render()
```

---

### 🧭 Navigation Components (11)

<table>
<tr>
<td><strong>Navbar</strong> - Top/bottom navigation bar **NEW!**</td>
<td><strong>Sidebar</strong> - Collapsible side navigation **NEW!**</td>
<td><strong>HamburgerMenu</strong> - Mobile drawer menu **NEW!**</td>
</tr>
<tr>
<td><strong>Tabs</strong> - Tab navigation</td>
<td><strong>TabPanel</strong> - Alternative tabs</td>
<td><strong>Toolbar</strong> - Action buttons bar</td>
</tr>
<tr>
<td><strong>Tooltip</strong> - Hover information</td>
<td><strong>Breadcrumb</strong> - Navigation trail</td>
<td><strong>Dropdown</strong> - Menu dropdown</td>
</tr>
<tr>
<td><strong>Menu</strong> - Navigation menu</td>
<td><strong>Pagination</strong> - Page navigation</td>
<td></td>
</tr>
</table>

```windjammer
// Navbar with brand and items
Navbar::new()
    .brand("MyApp")
    .item(NavbarItem::new("Home", "/"))
    .item(NavbarItem::new("About", "/about"))
    .sticky(true)
    .render()

// Collapsible sidebar
Sidebar::new()
    .item(SidebarItem::new("Dashboard").icon("📊").href("/"))
    .item(SidebarItem::new("Settings").icon("⚙️").href("/settings"))
    .width("250px")
    .collapsed(false)
    .render()

// Hamburger menu
HamburgerMenu::new()
    .item(HamburgerMenuItem::new("Profile", "/profile"))
    .item(HamburgerMenuItem::new("Logout", "/logout"))
    .render()

// Tabs
Tabs::new()
    .tab(Tab::new("overview", "Overview").active(true))
    .tab(Tab::new("settings", "Settings"))
    .render()

// Pagination
Pagination::new()
    .current(2)
    .total(10)
    .render()
```

---

### 🎯 Advanced Components (6)

<table>
<tr>
<td><strong>Dialog</strong> - Modal popups</td>
<td><strong>Toast</strong> - Notifications</td>
<td><strong>Accordion</strong> - Expandable sections</td>
</tr>
<tr>
<td><strong>CodeEditor</strong> - Code input</td>
<td><strong>AdvancedCodeEditor</strong> - Full editor</td>
<td><strong>ContextMenu</strong> - Right-click menu **NEW!**</td>
</tr>
</table>

```windjammer
// Toast notification
Toast::new("Success!")
    .variant(ToastVariant::Success)
    .position(ToastPosition::TopRight)
    .duration(3000)
    .render()

// Dialog
Dialog::new()
    .title("Confirm Action")
    .content("<p>Are you sure?</p>")
    .open(true)
    .render()

// Accordion
Accordion::new()
    .item(AccordionItem::new("Section 1", "<p>Content 1</p>"))
    .item(AccordionItem::new("Section 2", "<p>Content 2</p>"))
    .render()

// Context menu
ContextMenu::new("my-element")
    .item(ContextMenuItem::new("Copy").icon("📋"))
    .item(ContextMenuItem::new("Paste").icon("📄"))
    .item(ContextMenuItem::new("Delete").icon("🗑️"))
    .render()
```

---

### 🌳 Tree & Hierarchy (5)

<table>
<tr>
<td><strong>FileTree</strong> - File browser</td>
<td><strong>TreeView</strong> - Generic tree</td>
<td><strong>CollapsibleSection</strong> - Expandable panel</td>
</tr>
</table>

```windjammer
// File tree
FileTree::new()
    .node(FileNode::directory("src")
        .child(FileNode::file("main.rs"))
        .child(FileNode::file("lib.rs"))
    )
    .render()

// Tree view
TreeView::new()
    .item(TreeItem::new("Root")
        .child(TreeItem::new("Child 1"))
        .child(TreeItem::new("Child 2"))
    )
    .render()
```

---

## 🎮 Interactive Examples

### Counter App

```windjammer
use windjammer_ui::*

fn main() {
    let mut count = 0

    let ui = Container::new()
        .child(
            Text::new(format!("Count: {}", count))
                .size(TextSize::XLarge)
                .render()
        )
        .child(
            Button::new("Increment")
                .variant(ButtonVariant::Primary)
                .render()
        )
        .render()
    
    println!("{}", ui)
}
```

### Dashboard Layout

```windjammer
use windjammer_ui::*

fn main() {
    let dashboard = Container::new()
        .max_width("1200px")
        .child(
            Grid::new()
                .columns(3)
                .gap("24px")
                .child(
                    Card::new()
                        .title("Users")
                        .child(Text::new("1,234").size(TextSize::XLarge).render())
                        .render()
                )
                .child(
                    Card::new()
                        .title("Revenue")
                        .child(Text::new("$45,678").size(TextSize::XLarge).render())
                        .render()
                )
                .child(
                    Card::new()
                        .title("Orders")
                        .child(Text::new("567").size(TextSize::XLarge).render())
                        .render()
                )
                .render()
        )
        .render()
    
    println!("{}", dashboard)
}
```

### Form with Validation

```windjammer
use windjammer_ui::*

fn main() {
    let form = Card::new()
        .title("Contact Form")
        .child(
            Flex::new()
                .direction(FlexDirection::Column)
                .gap("16px")
                .child(
                    Input::new()
                        .placeholder("Your name")
                        .render()
                )
                .child(
                    Input::new()
                        .placeholder("Email address")
                        .render()
                )
                .child(
                    Button::new("Submit")
                        .variant(ButtonVariant::Primary)
                        .render()
                )
                .render()
        )
        .render()
    
    println!("{}", form)
}
```

---

## 📦 Installation & Setup

### 1. Add Windjammer UI to your project

```bash
wj add windjammer-ui
```

### 2. Include the CSS (one time)

```html
<link rel="stylesheet" href="windjammer-ui.css">
```

### 3. Write Windjammer code

```windjammer
use windjammer_ui::*

fn main() {
    let ui = Button::new("Hello").render()
    println!("{}", ui)
}
```

**That's it!** No build configuration, no webpack, no npm packages.

---

## 🏗️ Architecture

### What Developers Write:

```windjammer
Button::new("Click Me")
    .variant(ButtonVariant::Primary)
    .size(ButtonSize::Large)
    .render()
```

### What Gets Generated:

```html
<button class="wj-button wj-button-primary wj-button-lg">
    Click Me
</button>
```

### What Styles It:

```css
/* Included in windjammer-ui.css */
.wj-button { padding: 10px 20px; border-radius: 6px; ... }
.wj-button-primary { background: #667eea; color: white; ... }
```

**Developers never write the HTML or CSS!** They're auto-generated from pure Windjammer code.

---

## 🎨 Live Gallery

**[→ Open Interactive Gallery](examples/gallery.html)**

The gallery showcases all 40 components with:
- ✅ Live interactive demos
- ✅ Code examples for each component
- ✅ Dark mode toggle
- ✅ Responsive design
- ✅ Copy-paste ready code

Try it now to see:
- Click toast notification buttons to see animations
- Switch between tabs (pure CSS, no JS!)
- Toggle dark mode
- Interact with forms, sliders, switches
- Expand accordions and collapsible sections
- Navigate pagination

---

## 🌟 Why Windjammer UI?

| Traditional Approach | Windjammer UI |
|---------------------|---------------|
| Write React JSX | ✅ Write pure Windjammer |
| Import 10+ npm packages | ✅ One import: `std::ui` |
| Configure webpack/vite | ✅ Zero config |
| Write custom CSS | ✅ Beautiful defaults |
| Debug runtime errors | ✅ Compile-time safety |
| Ship large JS bundles | ✅ Compiled to Rust/WASM |

---

## 📊 Component Coverage

```
✅ 49 / 49 Components Implemented (100%)

Basic:        ████████████████████ 7/7
Layout:       ████████████████████ 8/8
Forms:        ████████████████████ 7/7
Data Display: ████████████████████ 5/5
Navigation:   ████████████████████ 11/11
Chat:         ████████████████████ 5/5 🆕
Advanced:     ████████████████████ 6/6
Tree:         ████████████████████ 3/3
```

**Status: Production Ready! 🎉**
**New:** Chat-ready with ChatGPT-style messaging components!

---

## 🚀 Performance

All components compile to native Rust:
- **Zero runtime overhead**
- **Type-safe at compile time**
- **No JavaScript engine needed**
- **Sub-millisecond rendering**

---

## 📚 Documentation

- **[API Reference]WINDJAMMER_UI_ARCHITECTURE.md** - Complete architecture guide
- **[Component Docs]DOGFOODING_GAPS_FOUND.md** - Implementation details
- **[Live Gallery]examples/gallery.html** - Interactive showcase

---

## 🤝 Contributing

All 40 components are written in pure Windjammer (`.wj` files) located in `src/components_wj/`.

To add a new component:

1. Create `src/components_wj/mycomponent.wj`
2. Run `./wj-build.sh` to transpile to Rust
3. Add to `src/components/mod.rs`
4. Update gallery showcase

---

## 🎯 Roadmap

### v0.1.0 ✅ (Current)
- ✅ 40 components implemented
- ✅ Builder pattern APIs
- ✅ Dark mode support
- ✅ Interactive gallery

### v0.2.0 🚧 (Next)
- 🚧 Event handlers (onClick, onChange)
- 🚧 Form validation
- 🚧 Animation system
- 🚧 Accessibility (ARIA)

### v1.0.0 🔮 (Future)
- 🔮 Direct WASM rendering
- 🔮 Built-in reactivity
- 🔮 Mobile components
- 🔮 Drag & drop

---

## 📜 License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE)
- MIT License ([LICENSE-MIT]LICENSE-MIT)

at your option.

---

## 🙏 Acknowledgments

- **shadcn/ui** - Design inspiration
- **Rust** - The language that makes this possible
- **Windjammer** - The platform

---

## 🐛 Known Limitations

While Windjammer UI is production-ready, there are some platform-specific considerations:

### Platform Support
- **Desktop on Linux CI**: Requires display server (X11/Wayland). CI tests web features only on Linux.
- **iOS Features on Windows**: macOS-specific dependencies (cocoa, core-foundation) are not available on Windows.
- **Cross-compilation**: Some features may require platform-specific system libraries.

### Technical Limitations
- **Event Handlers in HTML**: Event handlers are not serializable to HTML strings (by design). Use the DOM rendering methods for interactive components.
- **WASM Binary Size**: Desktop features significantly increase WASM binary size. Use `features = ["web"]` for web-only builds.

### Recommended Feature Configurations

```toml
# Web/WASM only (smallest bundle)
windjammer-ui = { version = "0.1.1", features = ["web"] }

# Desktop only (native windowing)
windjammer-ui = { version = "0.1.1", features = ["desktop"] }

# All platforms (largest bundle)
windjammer-ui = { version = "0.1.1", features = ["all-platforms"] }
```

---

<div align="center">

**Built with ❤️ in pure Windjammer**

[View Gallery](examples/gallery.html) • [Read Docs](WINDJAMMER_UI_ARCHITECTURE.md) • [Report Issue](https://github.com/jeffreyfriedman/windjammer/issues)

⭐ **Star us on GitHub if you like Windjammer UI!** ⭐

</div>