@kupola/kupola 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -286
  3. package/adapters/axios.d.ts +34 -0
  4. package/adapters/axios.js +122 -0
  5. package/adapters/navios-http.d.ts +110 -0
  6. package/adapters/navios-http.js +151 -0
  7. package/css/components-ext.css +157 -0
  8. package/css/components.css +69 -0
  9. package/css/theme-dark.css +5 -5
  10. package/css/utilities.css +119 -1
  11. package/dist/css/accessibility.css +119 -0
  12. package/dist/css/animations.css +224 -0
  13. package/dist/css/brand-themes.css +300 -0
  14. package/dist/css/colors_and_type.css +441 -0
  15. package/dist/css/components-ext.css +4165 -0
  16. package/dist/css/components.css +1483 -0
  17. package/dist/css/kupola.css +1 -12
  18. package/dist/css/kupola.min.css +1 -0
  19. package/dist/css/responsive.css +697 -0
  20. package/dist/css/scaffold.css +145 -0
  21. package/dist/css/states.css +316 -0
  22. package/dist/css/theme-dark.css +296 -0
  23. package/dist/css/theme-light.css +296 -0
  24. package/dist/css/utilities.css +171 -0
  25. package/dist/icons.svg +284 -0
  26. package/dist/kupola.cjs.js +17409 -257
  27. package/dist/kupola.cjs.js.map +1 -1
  28. package/dist/kupola.css +9000 -0
  29. package/dist/kupola.esm.js +17183 -7597
  30. package/dist/kupola.esm.js.map +1 -1
  31. package/dist/kupola.min.css +1 -0
  32. package/dist/kupola.min.js +2 -0
  33. package/dist/kupola.min.js.map +1 -0
  34. package/dist/kupola.umd.js +17415 -257
  35. package/dist/kupola.umd.js.map +1 -1
  36. package/dist/plugins/vite-plugin-kupola.js +120 -0
  37. package/dist/types/kupola.d.ts +421 -323
  38. package/js/calendar.js +334 -25
  39. package/js/carousel.js +182 -48
  40. package/js/collapse.js +148 -34
  41. package/js/color-picker.js +416 -108
  42. package/js/component.js +8 -19
  43. package/js/countdown.js +9 -8
  44. package/js/data-bind.js +73 -16
  45. package/js/datepicker.js +488 -110
  46. package/js/depends.js +710 -0
  47. package/js/dialog.js +4 -2
  48. package/js/drawer.js +172 -8
  49. package/js/dropdown.js +272 -17
  50. package/js/dynamic-tags.js +156 -40
  51. package/js/fileupload.js +9 -8
  52. package/js/form.js +280 -254
  53. package/js/global-events.js +281 -188
  54. package/js/heatmap.js +10 -7
  55. package/js/i18n.js +18 -10
  56. package/js/icons.js +141 -161
  57. package/js/image-preview.js +146 -2
  58. package/js/initializer.js +151 -71
  59. package/js/kupola-core.js +123 -45
  60. package/js/kupola-lifecycle.js +13 -11
  61. package/js/message.js +8 -1
  62. package/js/modal.js +207 -59
  63. package/js/notification.js +8 -1
  64. package/js/numberinput.js +9 -8
  65. package/js/pagination.js +263 -0
  66. package/js/registry.js +29 -12
  67. package/js/select.js +482 -27
  68. package/js/slide-captcha.js +11 -2
  69. package/js/slider.js +442 -25
  70. package/js/statcard.js +9 -7
  71. package/js/table.js +1210 -0
  72. package/js/tag.js +268 -14
  73. package/js/theme-standalone.js +88 -0
  74. package/js/theme.js +14 -43
  75. package/js/timepicker.js +335 -66
  76. package/js/tooltip.js +317 -86
  77. package/js/utils.js +6 -2
  78. package/js/validation.js +6 -2
  79. package/js/virtual-list.js +11 -7
  80. package/js/web-components.js +288 -0
  81. package/package.json +81 -67
  82. package/plugins/vite-plugin-kupola.js +120 -0
  83. package/scripts/build-css.cjs +113 -0
  84. package/scripts/build-svg-sprite.cjs +107 -0
  85. package/types/kupola.d.ts +421 -323
  86. package/CHANGELOG.md +0 -130
  87. package/INTEGRATION.md +0 -440
  88. package/PROJECT_SUMMARY.md +0 -312
  89. package/SKILL.md +0 -572
  90. package/dist/utils/utils/Kupola.cs +0 -77
  91. package/dist/utils/utils/Kupola.java +0 -104
  92. package/dist/utils/utils/kupola.go +0 -120
  93. package/dist/utils/utils/kupola.js +0 -63
  94. package/dist/utils/utils/kupola.py +0 -1392
  95. package/dist/utils/utils/kupola.rb +0 -69
  96. package/js/composition-api.js +0 -458
  97. package/js/error-handler.js +0 -181
  98. package/js/http.js +0 -419
  99. package/js/kupola-devtools.js +0 -598
  100. package/js/performance.js +0 -250
  101. package/js/router.js +0 -396
  102. package/js/security.js +0 -189
  103. package/js/test-utils.js +0 -251
  104. package/templates/base.html +0 -30
  105. package/templates/base_dashboard.html +0 -99
  106. package/utils/Kupola.cs +0 -77
  107. package/utils/Kupola.java +0 -104
  108. package/utils/kupola.go +0 -120
  109. package/utils/kupola.js +0 -63
  110. package/utils/kupola.py +0 -1392
  111. package/utils/kupola.rb +0 -69
package/SKILL.md DELETED
@@ -1,572 +0,0 @@
1
- # Kupola
2
-
3
- > Lightweight UI toolkit for any web project. No heavy frontend frameworks required. Works seamlessly with Flask, Django, Gin, Spring Boot, ASP.NET Core, Express, and any backend framework that outputs HTML.
4
-
5
- ## Library Layout
6
-
7
- > The library root directory is `kupola/`. All paths are relative to this root.
8
-
9
- ```
10
- kupola/
11
- ├── css/ # CSS stylesheets
12
- │ ├── kupola.css # Main CSS bundle
13
- │ ├── colors_and_type.css # Token definitions
14
- │ ├── components.css # Component styles
15
- │ ├── components-ext.css # Extended component styles
16
- │ ├── scaffold.css # Reset and utilities
17
- │ ├── brand-themes.css # 11 brand color themes
18
- │ ├── theme-dark.css # Dark theme tokens (default)
19
- │ ├── theme-light.css # Light theme tokens
20
- │ ├── states.css # Component states
21
- │ ├── utilities.css # Utility classes
22
- │ ├── responsive.css # Responsive design (PC/Pad/Phone)
23
- │ ├── accessibility.css # a11y support
24
- │ └── animations.css # Transitions and animations
25
- ├── js/ # JavaScript utilities
26
- │ ├── kupola-core.js # Core framework (KupolaHttp, KupolaComponent)
27
- │ ├── component.js # Base component class
28
- │ ├── kupola-lifecycle.js # Lifecycle management
29
- │ ├── composition-api.js # Composition API (reactive, computed, watch)
30
- │ ├── initializer.js # Auto initialization manager
31
- │ ├── registry.js # Component registry
32
- │ ├── global-events.js # Global event manager
33
- │ ├── router.js # Client-side router
34
- │ ├── http.js # HTTP client (fetch-based)
35
- │ ├── data-bind.js # Data binding and event bus
36
- │ ├── validation.js # Form validation
37
- │ ├── theme.js # Theme/brand switching
38
- │ ├── icons.js # Icon renderer
39
- │ ├── tooltip.js # Tooltip system
40
- │ ├── datepicker.js # Datepicker component
41
- │ ├── timepicker.js # Timepicker component
42
- │ ├── numberinput.js # Number input component
43
- │ ├── fileupload.js # File upload component
44
- │ ├── select.js # Select component
45
- │ ├── slider.js # Slider component
46
- │ ├── modal.js # Modal component
47
- │ ├── dialog.js # Dialog component
48
- │ ├── drawer.js # Drawer component
49
- │ ├── dropdown.js # Dropdown component
50
- │ ├── slide-captcha.js # Slide captcha component
51
- │ ├── heatmap.js # Heatmap component
52
- │ ├── virtual-list.js # Virtual list component
53
- │ ├── statcard.js # Statistic card component
54
- │ ├── image-preview.js # Image preview component
55
- │ ├── carousel.js # Carousel component
56
- │ ├── countdown.js # Countdown component
57
- │ ├── calendar.js # Calendar component
58
- │ ├── collapse.js # Collapse component
59
- │ ├── tag.js # Tag component
60
- │ ├── dynamic-tags.js # Dynamic tags component
61
- │ ├── color-picker.js # Color picker component
62
- │ ├── notification.js # Notification component
63
- │ ├── message.js # Message component
64
- │ ├── form.js # Form utilities
65
- │ ├── security.js # Security utilities (XSS/CSRF)
66
- │ ├── utils.js # General utilities
67
- │ ├── error-handler.js # Global error handler
68
- │ ├── performance.js # Performance monitoring
69
- │ ├── i18n.js # Internationalization
70
- │ ├── kupola-devtools.js # DevTools panel
71
- │ └── test-utils.js # Testing utilities
72
- ├── icons/ # 121 SVG icons (+ sprite)
73
- │ ├── *.svg # Individual icons
74
- │ └── icons.svg # SVG sprite
75
- ├── dist/ # Build output
76
- │ ├── kupola.esm.js # ES Module format
77
- │ ├── kupola.cjs.js # CommonJS format
78
- │ ├── kupola.umd.js # UMD format
79
- │ └── types/kupola.d.ts # TypeScript types
80
- ├── src/ # Build entry points
81
- ├── dashboard/ # Dashboard layout framework
82
- │ ├── dashboard.css # Layout styles
83
- │ ├── dashboard.html # Complete demo
84
- │ └── dashboard.js # Interactivity
85
- ├── templates/ # Flask/Gin templates
86
- │ ├── base.html # Base template
87
- │ └── base_dashboard.html # Dashboard base template
88
- ├── utils/ # Multi-language utility functions
89
- │ ├── kupola.py # Python component generation functions
90
- │ ├── kupola.go # Go component generation functions
91
- │ ├── Kupola.java # Java component generation functions
92
- │ ├── Kupola.cs # C# component generation functions
93
- │ ├── kupola.js # Node.js component generation functions
94
- │ └── kupola.rb # Ruby component generation functions
95
- ├── docs/ # Documentation
96
- │ ├── api.md # API documentation
97
- │ └── kupola-vs-vue-react.md # Framework comparison
98
- ├── examples/ # Example projects
99
- │ ├── basic_example.html # HTML demo
100
- │ └── flask_example/ # Flask complete example
101
- ├── snippets/ # IDE code snippets
102
- │ └── kupola.code-snippets # VS Code snippets
103
- ├── version.json # Version information
104
- ├── CHANGELOG.md # Changelog
105
- ├── INTEGRATION.md # Integration guide
106
- ├── PROJECT_SUMMARY.md # Project summary
107
- └── README.md # Usage guide
108
- ```
109
-
110
- ## Brand Essentials
111
-
112
- - **Surface**: dark canvas `--bg-base-default #1A1B1D`
113
- - **Primary text**: `--text-default #D1D3DB`
114
- - **Brand accent**: `--bg-brand #535164` (曾青, default) with 10 alternative colors
115
- - **Status palette**: primary / success / alert / warning / error
116
- - **Typography**: SF Pro / SF Pro Text / JetBrains Mono
117
- - **Radii**: `2 / 4 / 6 / 8 / 10 / full`
118
- - **Spacers**: `0 / 4 / 6 / 8 / 12 / 16 / 24 / 32 / 40`
119
-
120
- ## Brand Colors
121
-
122
- | ID | Name | Color | Text Color |
123
- |----|------|-------|------------|
124
- | zengqing | 曾青 | #535164 | white (default) |
125
- | green | 翠绿 | #32F08C | dark |
126
- | xionghuang | 雄黄 | #FF9900 | dark |
127
- | jianghuang | 姜黄 | #E2C027 | dark |
128
- | lanlv | 蓝绿 | #12A182 | white |
129
- | kongquelan | 孔雀蓝 | #0EB0C9 | dark |
130
- | meiguizi | 玫瑰紫 | #BA2F7B | white |
131
- | shihong | 柿红 | #F2481B | white |
132
- | shanchahong | 山茶红 | #F05A46 | white |
133
- | quhong | 紫云 | #B1A6CC | dark |
134
- | roulan | 柔蓝 | #106898 | white |
135
-
136
- ## Components (40+)
137
-
138
- | Slug | Type | Notes |
139
- |------|------|-------|
140
- | activity-rail | IDE rail | vertical activity bar with active state + divider |
141
- | alert | Notification | 4 tones × simple/complex |
142
- | avatar | User chip | sm/md/lg, square/accent |
143
- | badge | Status tag | default / success / warning / danger / brand |
144
- | button | Button | 8 variants × 3 sizes × 4 states |
145
- | card | Surface card | header / actions |
146
- | chat-composer | AI input | tool row + model chip + mic + send |
147
- | checkbox | Form control | checked / unchecked / disabled |
148
- | collapse | Accordion | collapsible sections |
149
- | color-picker | Color selector | preset colors + custom input |
150
- | date-picker | Date input | calendar popup, month navigation |
151
- | dialog | Modal | overlay + footer |
152
- | divider | Separator | horizontal rule |
153
- | drawer | Side panel | slide-in panel from left/right |
154
- | dynamic-tags | Tag input | add/remove tags dynamically |
155
- | editor-tabs | IDE tabs | layered tab strip + close affordance + actions |
156
- | empty | Empty state | placeholder for empty content |
157
- | file-tree | File explorer | multi-depth, chevron |
158
- | file-upload | File input | drag & drop, preview, delete |
159
- | form | Form controls | input / textarea / select / checkbox / radio / switch |
160
- | Heatmap | Data visualization | calendar-based heatmap with color levels |
161
- | image | Media | image with placeholder, fallback, and error states |
162
- | image-list | Media | image grid with selection support |
163
- | image-preview | Image viewer | full-size image preview |
164
- | stat-card | Data visualization | KPI card with number animation and trend indicators |
165
- | kbd | Shortcut hint | keyboard key caps |
166
- | menu | Dropdown | section labels, shortcut |
167
- | message | Toast | floating message notifications |
168
- | nav-list | Sidebar nav | grouped items with active state |
169
- | notification | Notification | popup notifications |
170
- | number-input | Numeric input | +/- buttons, min/max constraints |
171
- | page-header | Page head | title + actions region |
172
- | pagination | Page navigator | numeric with ellipsis |
173
- | progress | Progress bar | determinate / indeterminate |
174
- | progress-circle | Circular progress | SVG-based circular indicator |
175
- | radio | Form control | single selection among options |
176
- | select | Dropdown select | options dropdown |
177
- | setting-row | Preference row | title + description + control |
178
- | slide-captcha | Security | circle / slider mode, error refresh |
179
- | slider | Range input | horizontal slider with value display |
180
- | spin | Loading | spinner indicator |
181
- | stat-card | KPI card | tabular numerals + delta |
182
- | status-bar | IDE status bar | status items + dot indicators |
183
- | switch | Toggle | on/off switch with thumb |
184
- | table | Data table | avatar + tag cells |
185
- | table-panel | Table container | bordered table with toolbar + footer pagination |
186
- | tabs | Tabs | underline / filled / closable |
187
- | tag | Status tag | default / success / warning / danger / brand |
188
- | time-picker | Time input | time selection popup |
189
- | timeline | Timeline | chronological event list |
190
- | tooltip | Hint | custom tooltip with data-title |
191
- | virtual-list | List | virtualized scrolling for large datasets |
192
- | workbench-titlebar | IDE top bar | traffic lights + project selector + icon actions |
193
-
194
- ## Dashboard Framework
195
-
196
- Complete 4-section layout:
197
- - **Header** (48px): Logo + center menu + right icons (theme/brand/user)
198
- - **Sidebar** (48px): Icon-only navigation with tooltips
199
- - **Content**: Scrollable main area
200
- - **Footer** (24px): Status indicators
201
-
202
- ## Templates
203
-
204
- | Template | Description |
205
- |----------|-------------|
206
- | base.html | Minimal base template with CSS/JS includes |
207
- | base_dashboard.html | Full dashboard layout with all features |
208
-
209
- ## Language-Specific Utilities
210
-
211
- Kupola provides helper functions for popular backend languages:
212
-
213
- ### Python Utilities
214
-
215
- `utils/kupola.py` provides component generation functions for Flask/Django:
216
-
217
- | Function | Description |
218
- |----------|-------------|
219
- | kupola_button() | Generate button HTML |
220
- | kupola_input() | Generate input field |
221
- | kupola_card() | Generate card |
222
- | kupola_table() | Generate table |
223
- | kupola_dashboard_layout() | Generate dashboard layout |
224
- | kupola_stat_card() | Generate stat card |
225
- | kupola_html_tag() | Generate HTML tag with theme/brand |
226
- | kupola_theme_script() | Generate theme script tag |
227
- | kupola_brand_toggle() | Generate brand toggle button |
228
-
229
- ## Go Utilities
230
-
231
- `utils/kupola.go` provides component generation functions for Gin/Echo/Beego:
232
-
233
- | Function | Description |
234
- |----------|-------------|
235
- | Button(label, variant, size) | Generate button HTML |
236
- | Input(label, name, placeholder, validate) | Generate input field |
237
- | Card(title, body, footer) | Generate card |
238
- | StatCard(title, value, trend, trendType) | Generate stat card |
239
- | Badge(text, variant) | Generate badge |
240
- | Avatar(initials, size, variant) | Generate avatar |
241
- | ThemeScript(theme, brand) | Generate theme initialization script |
242
- | DataBind(key, bindType) | Generate data-bind attribute |
243
- | DataComponent(name) | Generate data-component attribute |
244
- | DataValidate(rules) | Generate data-validate attribute |
245
-
246
- ### Java Utilities
247
-
248
- `utils/Kupola.java` provides component generation functions for Spring Boot/Quarkus:
249
-
250
- | Function | Description |
251
- |----------|-------------|
252
- | button(label, variant, size) | Generate button HTML |
253
- | input(label, name, placeholder, validate) | Generate input field |
254
- | card(title, body, footer) | Generate card |
255
- | statCard(title, value, trend, trendType) | Generate stat card |
256
- | badge(text, variant) | Generate badge |
257
- | avatar(initials, size, variant) | Generate avatar |
258
- | themeScript(theme, brand) | Generate theme initialization script |
259
- | dataBind(key, bindType) | Generate data-bind attribute |
260
- | dataComponent(name) | Generate data-component attribute |
261
- | dataValidate(rules) | Generate data-validate attribute |
262
-
263
- ### C# Utilities
264
-
265
- `utils/Kupola.cs` provides component generation functions for ASP.NET Core:
266
-
267
- | Function | Description |
268
- |----------|-------------|
269
- | Button(label, variant, size) | Generate button HTML |
270
- | Input(label, name, placeholder, validate) | Generate input field |
271
- | Card(title, body, footer) | Generate card |
272
- | StatCard(title, value, trend, trendType) | Generate stat card |
273
- | Badge(text, variant) | Generate badge |
274
- | Avatar(initials, size, variant) | Generate avatar |
275
- | ThemeScript(theme, brand) | Generate theme initialization script |
276
- | DataBind(key, bindType) | Generate data-bind attribute |
277
- | DataComponent(name) | Generate data-component attribute |
278
- | DataValidate(rules) | Generate data-validate attribute |
279
-
280
- ### Node.js Utilities
281
-
282
- `utils/kupola.js` provides component generation functions for Express/Koa:
283
-
284
- | Function | Description |
285
- |----------|-------------|
286
- | button(label, variant, size) | Generate button HTML |
287
- | input(label, name, placeholder, validate) | Generate input field |
288
- | card(title, body, footer) | Generate card |
289
- | statCard(title, value, trend, trendType) | Generate stat card |
290
- | badge(text, variant) | Generate badge |
291
- | avatar(initials, size, variant) | Generate avatar |
292
- | themeScript(theme, brand) | Generate theme initialization script |
293
- | dataBind(key, bindType) | Generate data-bind attribute |
294
- | dataComponent(name) | Generate data-component attribute |
295
- | dataValidate(rules) | Generate data-validate attribute |
296
-
297
- ### Ruby Utilities
298
-
299
- `utils/kupola.rb` provides component generation functions for Ruby on Rails:
300
-
301
- | Function | Description |
302
- |----------|-------------|
303
- | button(label, variant, size) | Generate button HTML |
304
- | input(label, name, placeholder, validate) | Generate input field |
305
- | card(title, body, footer) | Generate card |
306
- | stat_card(title, value, trend, trend_type) | Generate stat card |
307
- | badge(text, variant) | Generate badge |
308
- | avatar(initials, size, variant) | Generate avatar |
309
- | theme_script(theme, brand) | Generate theme initialization script |
310
- | data_bind(key, bind_type) | Generate data-bind attribute |
311
- | data_component(name) | Generate data-component attribute |
312
- | data_validate(rules) | Generate data-validate attribute |
313
-
314
- ## Usage
315
-
316
- ### HTML Only
317
-
318
- ```html
319
- <link rel="stylesheet" href="/kupola/css/kupola.css">
320
- <script src="/kupola/js/kupola-core.js"></script>
321
-
322
- <button class="ds-btn ds-btn--brand">Submit</button>
323
- ```
324
-
325
- ### Flask Integration
326
-
327
- ```python
328
- from kupola.utils.kupola import kupola_button
329
- ```
330
-
331
- ```html
332
- {% extends "base_dashboard.html" %}
333
-
334
- {% block content %}
335
- <h1>Dashboard</h1>
336
- {% endblock %}
337
- ```
338
-
339
- ### Gin Integration
340
-
341
- ```go
342
- package main
343
-
344
- import (
345
- "github.com/gin-gonic/gin"
346
- "your-project/kupola"
347
- )
348
-
349
- func main() {
350
- r := gin.Default()
351
- r.Static("/kupola", "./assets/kupola")
352
- r.LoadHTMLGlob("templates/*")
353
-
354
- r.GET("/", func(c *gin.Context) {
355
- c.HTML(200, "dashboard.html", gin.H{
356
- "Button": kupola.Button,
357
- "Card": kupola.Card,
358
- "StatCard": kupola.StatCard,
359
- })
360
- })
361
-
362
- r.Run(":8080")
363
- }
364
- ```
365
-
366
- ```html
367
- <!-- templates/dashboard.html -->
368
- <!DOCTYPE html>
369
- <html>
370
- <head>
371
- <link rel="stylesheet" href="/kupola/css/kupola.css">
372
- </head>
373
- <body>
374
- {{.Card "Welcome" "Hello Kupola!" ""}}
375
- {{.Button "Click Me" "brand" "md"}}
376
- <script src="/kupola/js/kupola-core.js"></script>
377
- </body>
378
- </html>
379
- ```
380
-
381
- ### Spring Boot Integration
382
-
383
- ```java
384
- @Configuration
385
- public class WebConfig implements WebMvcConfigurer {
386
- @Override
387
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
388
- registry.addResourceHandler("/kupola/**")
389
- .addResourceLocations("classpath:/static/kupola/");
390
- }
391
- }
392
- ```
393
-
394
- ```html
395
- <!-- templates/dashboard.html -->
396
- <!DOCTYPE html>
397
- <html xmlns:th="http://www.thymeleaf.org">
398
- <head>
399
- <link rel="stylesheet" th:href="@{/kupola/css/kupola.css}">
400
- </head>
401
- <body>
402
- <div class="ds-card">
403
- <div class="ds-card__body">
404
- <button class="ds-btn ds-btn--brand">Submit</button>
405
- </div>
406
- </div>
407
- <script th:src="@{/kupola/js/kupola-core.js}"></script>
408
- </body>
409
- </html>
410
- ```
411
-
412
- ### ASP.NET Core Integration
413
-
414
- ```csharp
415
- public void Configure(IApplicationBuilder app)
416
- {
417
- app.UseStaticFiles();
418
- app.UseStaticFiles(new StaticFileOptions
419
- {
420
- FileProvider = new PhysicalFileProvider(
421
- Path.Combine(Directory.GetCurrentDirectory(), "assets", "kupola")),
422
- RequestPath = "/kupola"
423
- });
424
- }
425
- ```
426
-
427
- ```html
428
- <!-- Views/Home/Index.cshtml -->
429
- <!DOCTYPE html>
430
- <html>
431
- <head>
432
- <link rel="stylesheet" href="/kupola/css/kupola.css">
433
- </head>
434
- <body>
435
- <div class="ds-card">
436
- <div class="ds-card__body">
437
- <button class="ds-btn ds-btn--brand">Submit</button>
438
- </div>
439
- </div>
440
- <script src="/kupola/js/kupola-core.js"></script>
441
- </body>
442
- </html>
443
- ```
444
-
445
- ### Express.js Integration
446
-
447
- ```javascript
448
- // app.js
449
- const express = require('express');
450
- const { button, card } = require('./utils/kupola.js');
451
-
452
- const app = express();
453
- app.use('/kupola', express.static('public/kupola'));
454
-
455
- app.get('/', (req, res) => {
456
- const html = `<!DOCTYPE html>
457
- <html>
458
- <head>
459
- <link rel="stylesheet" href="/kupola/css/kupola.css">
460
- </head>
461
- <body>
462
- ${card('Welcome', 'Hello Kupola!', '')}
463
- ${button('Click Me', 'brand', 'md')}
464
- <script src="/kupola/js/kupola-core.js"></script>
465
- </body>
466
- </html>`;
467
- res.send(html);
468
- });
469
- ```
470
-
471
- ### Ruby on Rails Integration
472
-
473
- ```ruby
474
- # app/helpers/kupola_helper.rb
475
- module KupolaHelper
476
- def button(label, variant = 'brand', size = 'md')
477
- "<button class=\"ds-btn ds-btn--#{variant} ds-btn--#{size}\">#{label}</button>".html_safe
478
- end
479
-
480
- def card(title, body, footer = '')
481
- footer_html = footer.empty? ? '' : "<div class=\"ds-card__footer\">#{footer}</div>"
482
- "<div class=\"ds-card\"><div class=\"ds-card__header\"><h3 class=\"ds-card__title\">#{title}</h3></div><div class=\"ds-card__body\">#{body}</div>#{footer_html}</div>".html_safe
483
- end
484
- end
485
- ```
486
-
487
- ```erb
488
- <!-- app/views/home/index.html.erb -->
489
- <!DOCTYPE html>
490
- <html>
491
- <head>
492
- <%= stylesheet_link_tag '/kupola/css/kupola.css' %>
493
- </head>
494
- <body>
495
- <%= card 'Welcome', 'Hello Kupola!', '' %>
496
- <%= button 'Click Me', 'brand', 'md' %>
497
- <%= javascript_include_tag '/kupola/js/kupola-core.js' %>
498
- </body>
499
- </html>
500
- ```
501
-
502
- ## Responsive Design
503
-
504
- Three breakpoints supported:
505
- - **Phone**: < 768px - Sidebar moves to bottom, single column layout
506
- - **Pad**: 768px - 1024px - 2-column grid, adjusted spacing
507
- - **PC**: > 1024px - Full 4-column grid, standard layout
508
-
509
- ## Accessibility (a11y)
510
-
511
- - ARIA labels for all interactive components
512
- - Keyboard navigation support
513
- - Focus-visible styles
514
- - Skip link for screen readers
515
- - High contrast mode support
516
- - Reduced motion preference support
517
-
518
- ## Form Validation
519
-
520
- Built-in validation via `data-validate` attribute:
521
- - `required` - Field is required
522
- - `email` - Valid email format
523
- - `url` - Valid URL format
524
- - `minLength:N` - Minimum length
525
- - `maxLength:N` - Maximum length
526
- - `pattern:regex` - Custom pattern
527
- - `min:N` - Minimum value
528
- - `max:N` - Maximum value
529
- - `equalTo:id` - Match another field
530
-
531
- ## Data Binding
532
-
533
- Two-way data binding via `data-bind` attribute:
534
- - `data-bind="key:text"` - Bind text content
535
- - `data-bind="key:value"` - Bind input value
536
- - `data-bind="key:checked"` - Bind checkbox state
537
- - `data-bind="key:disabled"` - Bind disabled state
538
- - `data-bind="key:class:className"` - Conditional class
539
-
540
- ## Event Bus
541
-
542
- Publish/subscribe event system:
543
- ```javascript
544
- kupolaEvents.on('eventName', callback);
545
- kupolaEvents.emit('eventName', data);
546
- kupolaEvents.off('eventName', callback);
547
- kupolaEvents.once('eventName', callback);
548
- ```
549
-
550
- ## Authoring Rules
551
-
552
- 1. **Never hardcode hex values.** Always reference `var(--token)`.
553
- 2. **Use utility classes.** Prefer `.flex`, `.grid`, `.gap-*` over custom CSS.
554
- 3. **Components are fluid.** All `.ds-*` components are fluid (`min-width: 0` + `1fr`).
555
- 4. **Icons use currentColor.** SVG icons inherit text color via `stroke="currentColor"`.
556
- 5. **Add ARIA labels.** All interactive components should have proper ARIA attributes.
557
-
558
- ## Workflow Commands
559
-
560
- - **Add component**: `add-component` - Add a new component template
561
- - **Add brand color**: `add-brand-color` - Add a new brand color theme
562
- - **Generate template**: `generate-template` - Generate a new Flask template
563
- - **Update documentation**: `update-docs` - Update API documentation
564
- - **Update examples**: `update-examples` - Update example projects
565
-
566
- ## Version
567
-
568
- Current version: `1.2.0` (see `version.json`)
569
-
570
- ## License
571
-
572
- MIT
@@ -1,77 +0,0 @@
1
- using System;
2
-
3
- namespace Kupola
4
- {
5
- public static class Components
6
- {
7
- public static string Button(string label, string variant = "brand", string size = "md")
8
- {
9
- return $"<button class=\"ds-btn ds-btn--{variant} ds-btn--{size}\">{label}</button>";
10
- }
11
-
12
- public static string Input(string label, string name, string placeholder, string validate = "")
13
- {
14
- string validateAttr = string.IsNullOrEmpty(validate) ? "" : $" data-validate=\"{validate}\"";
15
- return $@"<div class=""ds-form-item"">
16
- <label class=""ds-form-item__label"">{label}</label>
17
- <input type=""text"" class=""ds-input"" name=""{name}"" placeholder=""{placeholder}""{validateAttr}>
18
- </div>";
19
- }
20
-
21
- public static string Card(string title, string body, string footer = "")
22
- {
23
- string footerHtml = string.IsNullOrEmpty(footer) ? "" : $"<div class=\"ds-card__footer\">{footer}</div>";
24
- return $@"<div class=""ds-card"">
25
- <div class=""ds-card__header"">
26
- <h3 class=""ds-card__title"">{title}</h3>
27
- </div>
28
- <div class=""ds-card__body"">{body}</div>
29
- {footerHtml}
30
- </div>";
31
- }
32
-
33
- public static string StatCard(string title, string value, string trend = "", string trendType = "up")
34
- {
35
- string trendHtml = string.IsNullOrEmpty(trend) ? "" :
36
- $"<span class=\"ds-stat-card__trend {(trendType == "down" ? "ds-stat-card__trend--down" : "ds-stat-card__trend--up")}\">{trend}</span>";
37
- return $@"<div class=""ds-stat-card"">
38
- <div class=""ds-stat-card__title"">{title}</div>
39
- <div class=""ds-stat-card__value"">{value}</div>
40
- {trendHtml}
41
- </div>";
42
- }
43
-
44
- public static string Badge(string text, string variant = "default")
45
- {
46
- return $"<span class=\"ds-badge ds-badge--{variant}\">{text}</span>";
47
- }
48
-
49
- public static string Avatar(string initials, string size = "md", string variant = "default")
50
- {
51
- return $"<div class=\"ds-avatar ds-avatar--{size} ds-avatar--{variant}\">{initials}</div>";
52
- }
53
-
54
- public static string ThemeScript(string theme = "dark", string brand = "zengqing")
55
- {
56
- return $@"<script>
57
- if (typeof setTheme === 'function') setTheme('{theme}');
58
- if (typeof setBrand === 'function') setBrand('{brand}');
59
- </script>";
60
- }
61
-
62
- public static string DataBind(string key, string bindType)
63
- {
64
- return $"data-bind=\"{key}:{bindType}\"";
65
- }
66
-
67
- public static string DataComponent(string name)
68
- {
69
- return $"data-component=\"{name}\"";
70
- }
71
-
72
- public static string DataValidate(string rules)
73
- {
74
- return $"data-validate=\"{rules}\"";
75
- }
76
- }
77
- }