FeaturesPage.vala 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using Astralis;
  2. using Invercargill;
  3. using Invercargill.DataStructures;
  4. using Inversion;
  5. using Spry;
  6. /**
  7. * FeaturesPage - Detailed features overview
  8. *
  9. * Showcases all the capabilities of the Spry framework
  10. */
  11. public class FeaturesPage : PageComponent {
  12. public const string ROUTE = "/features";
  13. public override string markup { get {
  14. return """
  15. <div sid="features-page" class="section">
  16. <div class="container">
  17. <!-- Header -->
  18. <div class="section-header">
  19. <h1>Features</h1>
  20. <p>Everything you need to build modern, reactive web applications in Vala</p>
  21. </div>
  22. <!-- Component System -->
  23. <section class="demo-section">
  24. <h2>🧩 Component-Based Architecture</h2>
  25. <p>Build your UI with reusable, composable components that encapsulate state and behavior.</p>
  26. <div class="features-grid" style="margin-top: var(--space-6);">
  27. <div class="feature-card">
  28. <div class="feature-icon purple">📦</div>
  29. <h3>Encapsulated State</h3>
  30. <p>Each component manages its own state, making your code predictable and testable.</p>
  31. </div>
  32. <div class="feature-card">
  33. <div class="feature-icon blue">🔗</div>
  34. <h3>Outlets & Children</h3>
  35. <p>Use outlets to compose components together, creating complex UIs from simple parts.</p>
  36. </div>
  37. <div class="feature-card">
  38. <div class="feature-icon green">♻</div>
  39. <h3>Lifecycle Hooks</h3>
  40. <p>prepare() and handle_action() hooks give you control over component behavior.</p>
  41. </div>
  42. </div>
  43. </section>
  44. <!-- HTMX Integration -->
  45. <section class="demo-section">
  46. <h2>⚡ HTMX Integration</h2>
  47. <p>Add dynamic behavior without writing JavaScript. Spry makes HTMX even more powerful.</p>
  48. <div class="code-block">
  49. <div class="code-header">
  50. <div class="code-dots">
  51. <div class="code-dot red"></div>
  52. <div class="code-dot yellow"></div>
  53. <div class="code-dot green"></div>
  54. </div>
  55. <span class="code-lang">HTML with Spry Attributes</span>
  56. </div>
  57. <pre><code>&lt;!-- Declarative actions --&gt;
  58. &lt;button spry-action=":Toggle"
  59. spry-target="item"
  60. hx-swap="outerHTML"&gt;
  61. Toggle Item
  62. &lt;/button&gt;
  63. &lt;!-- Cross-component communication --&gt;
  64. &lt;form spry-action="ListComponent:Add"
  65. hx-target="#my-list"&gt;
  66. &lt;input name="title" /&gt;
  67. &lt;button type="submit"&gt;Add&lt;/button&gt;
  68. &lt;/form&gt;
  69. &lt;!-- Out-of-band updates --&gt;
  70. &lt;div spry-global="header"&gt;
  71. Updates automatically when data changes
  72. &lt;/div&gt;</code></pre>
  73. </div>
  74. <div class="features-grid" style="margin-top: var(--space-6);">
  75. <div class="feature-card">
  76. <div class="feature-icon purple">🎯</div>
  77. <h3>spry-action</h3>
  78. <p>Declare component actions directly in your markup. No event listeners needed.</p>
  79. </div>
  80. <div class="feature-card">
  81. <div class="feature-icon blue">🔍</div>
  82. <h3>spry-target</h3>
  83. <p>Target elements within your component using simple sid references.</p>
  84. </div>
  85. <div class="feature-card">
  86. <div class="feature-icon green">🌐</div>
  87. <h3>spry-global</h3>
  88. <p>Update multiple page regions with out-of-band HTMX swaps.</p>
  89. </div>
  90. </div>
  91. </section>
  92. <!-- Dependency Injection -->
  93. <section class="demo-section">
  94. <h2>💉 Dependency Injection</h2>
  95. <p>Powered by Inversion, get clean, testable code with automatic dependency resolution.</p>
  96. <div class="code-block">
  97. <div class="code-header">
  98. <div class="code-dots">
  99. <div class="code-dot red"></div>
  100. <div class="code-dot yellow"></div>
  101. <div class="code-dot green"></div>
  102. </div>
  103. <span class="code-lang">Vala</span>
  104. </div>
  105. <pre><code>class TodoComponent : Component {
  106. // Inject dependencies in field initializers
  107. private TodoStore store = inject&lt;TodoStore&gt;();
  108. private ComponentFactory factory = inject&lt;ComponentFactory&gt;();
  109. private HttpContext http = inject&lt;HttpContext&gt;();
  110. }
  111. // Register services with different lifecycles
  112. application.add_singleton&lt;AppState&gt;(); // One instance forever
  113. application.add_scoped&lt;ComponentFactory&gt;(); // One per request
  114. application.add_transient&lt;MyComponent&gt;(); // New each time</code></pre>
  115. </div>
  116. </section>
  117. <!-- Templates -->
  118. <section class="demo-section">
  119. <h2>📄 Page Templates</h2>
  120. <p>Create reusable layouts with nested templates that automatically wrap your pages.</p>
  121. <div class="features-grid" style="margin-top: var(--space-6);">
  122. <div class="feature-card">
  123. <div class="feature-icon purple">🏗</div>
  124. <h3>Nested Layouts</h3>
  125. <p>Stack templates to create complex layouts from simple, reusable pieces.</p>
  126. </div>
  127. <div class="feature-card">
  128. <div class="feature-icon blue">📍</div>
  129. <h3>Route-Based</h3>
  130. <p>Templates are applied based on route prefixes, automatically wrapping matching pages.</p>
  131. </div>
  132. <div class="feature-card">
  133. <div class="feature-icon green">🔌</div>
  134. <h3>Template Outlets</h3>
  135. <p>Use <spry-template-outlet /> to define where child content renders.</p>
  136. </div>
  137. </div>
  138. </section>
  139. <!-- Performance -->
  140. <section class="demo-section">
  141. <h2>🚀 High Performance</h2>
  142. <p>Built on Astralis for native code performance with web framework convenience.</p>
  143. <div class="stats-grid" style="margin-top: var(--space-6);">
  144. <div class="stat-card">
  145. <div class="stat-value">Native</div>
  146. <div class="stat-label">Code Execution</div>
  147. </div>
  148. <div class="stat-card">
  149. <div class="stat-value">Brotli</div>
  150. <div class="stat-label">Compression</div>
  151. </div>
  152. <div class="stat-card">
  153. <div class="stat-value">Zero</div>
  154. <div class="stat-label">JavaScript Required</div>
  155. </div>
  156. <div class="stat-card">
  157. <div class="stat-value">Fast</div>
  158. <div class="stat-label">Resource Loading</div>
  159. </div>
  160. </div>
  161. </section>
  162. <!-- CTA -->
  163. <div class="text-center" style="margin-top: var(--space-12);">
  164. <h2>Ready to Build?</h2>
  165. <p style="margin-bottom: var(--space-6);">Try the interactive demo and see Spry in action.</p>
  166. <a href="/demo" class="btn btn-primary">Try Live Demo</a>
  167. </div>
  168. </div>
  169. </div>
  170. """;
  171. }}
  172. }