pi-generative-ui 0.1.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 (23) hide show
  1. package/.pi/extensions/generative-ui/claude-guidelines/CORE.md +89 -0
  2. package/.pi/extensions/generative-ui/claude-guidelines/art.md +175 -0
  3. package/.pi/extensions/generative-ui/claude-guidelines/art_interactive.md +297 -0
  4. package/.pi/extensions/generative-ui/claude-guidelines/chart.md +255 -0
  5. package/.pi/extensions/generative-ui/claude-guidelines/chart_interactive.md +255 -0
  6. package/.pi/extensions/generative-ui/claude-guidelines/diagram.md +624 -0
  7. package/.pi/extensions/generative-ui/claude-guidelines/interactive.md +209 -0
  8. package/.pi/extensions/generative-ui/claude-guidelines/mockup.md +209 -0
  9. package/.pi/extensions/generative-ui/claude-guidelines/sections/art_and_illustration.md +11 -0
  10. package/.pi/extensions/generative-ui/claude-guidelines/sections/charts_chart_js.md +43 -0
  11. package/.pi/extensions/generative-ui/claude-guidelines/sections/color_palette.md +31 -0
  12. package/.pi/extensions/generative-ui/claude-guidelines/sections/core_design_system.md +60 -0
  13. package/.pi/extensions/generative-ui/claude-guidelines/sections/diagram_types.md +427 -0
  14. package/.pi/extensions/generative-ui/claude-guidelines/sections/mapping.json +44 -0
  15. package/.pi/extensions/generative-ui/claude-guidelines/sections/modules.md +17 -0
  16. package/.pi/extensions/generative-ui/claude-guidelines/sections/preamble.md +1 -0
  17. package/.pi/extensions/generative-ui/claude-guidelines/sections/svg_setup.md +73 -0
  18. package/.pi/extensions/generative-ui/claude-guidelines/sections/ui_components.md +87 -0
  19. package/.pi/extensions/generative-ui/claude-guidelines/sections/when_nothing_fits.md +6 -0
  20. package/.pi/extensions/generative-ui/guidelines.ts +795 -0
  21. package/.pi/extensions/generative-ui/index.ts +401 -0
  22. package/README.md +124 -0
  23. package/package.json +22 -0
@@ -0,0 +1,87 @@
1
+ ## UI components
2
+
3
+ ### Aesthetic
4
+ Flat, clean, white surfaces. Minimal 0.5px borders. Generous whitespace. No gradients, no shadows (except functional focus rings). Everything should feel native to claude.ai — like it belongs on the page, not embedded from somewhere else.
5
+
6
+ ### Tokens
7
+ - Borders: always `0.5px solid var(--color-border-tertiary)` (or `-secondary` for emphasis)
8
+ - Corner radius: `var(--border-radius-md)` for most elements, `var(--border-radius-lg)` for cards
9
+ - Cards: white bg (`var(--color-background-primary)`), 0.5px border, radius-lg, padding 1rem 1.25rem
10
+ - Form elements (input, select, textarea, button, range slider) are pre-styled — write bare tags. Text inputs are 36px with hover/focus built in; range sliders have 4px track + 18px thumb; buttons have outline style with hover/active. Only add inline styles to override (e.g., different width).
11
+ - Buttons: pre-styled with transparent bg, 0.5px border-secondary, hover bg-secondary, active scale(0.98). If it triggers sendPrompt, append a ↗ arrow.
12
+ - **Round every displayed number.** JS float math leaks artifacts — `0.1 + 0.2` gives `0.30000000000000004`, `7 * 1.1` gives `7.700000000000001`. Any number that reaches the screen (slider readouts, stat card values, axis labels, data-point labels, tooltips, computed totals) must go through `Math.round()`, `.toFixed(n)`, or `Intl.NumberFormat`. Pick the precision that makes sense for the context — integers for counts, 1–2 decimals for percentages, `toLocaleString()` for currency. For range sliders, also set `step="1"` (or step="0.1" etc.) so the input itself emits round values.
13
+ - Spacing: use rem for vertical rhythm (1rem, 1.5rem, 2rem), px for component-internal gaps (8px, 12px, 16px)
14
+ - Box-shadows: none, except `box-shadow: 0 0 0 Npx` focus rings on inputs
15
+
16
+ ### Metric cards
17
+ For summary numbers (revenue, count, percentage) — surface card with muted 13px label above, 24px/500 number below. `background: var(--color-background-secondary)`, no border, `border-radius: var(--border-radius-md)`, padding 1rem. Use in grids of 2-4 with `gap: 12px`. Distinct from raised cards (which have white bg + border).
18
+
19
+ ### Layout
20
+ - Editorial (explanatory content): no card wrapper, prose flows naturally
21
+ - Card (bounded objects like a contact record, receipt): single raised card wraps the whole thing
22
+ - Don't put tables here — output them as markdown in your response text
23
+
24
+ **Grid overflow:** `grid-template-columns: 1fr` has `min-width: auto` by default — children with large min-content push the column past the container. Use `minmax(0, 1fr)` to clamp.
25
+
26
+ **Table overflow:** Tables with many columns auto-expand past `width: 100%` if cell contents exceed it. In constrained layouts (≤700px), use `table-layout: fixed` and set explicit column widths, or reduce columns, or allow horizontal scroll on a wrapper.
27
+
28
+ ### Mockup presentation
29
+ Contained mockups — mobile screens, chat threads, single cards, modals, small UI components — should sit on a background surface (`var(--color-background-secondary)` container with `border-radius: var(--border-radius-lg)` and padding, or a device frame) so they don't float naked on the widget canvas. Full-width mockups like dashboards, settings pages, or data tables that naturally fill the viewport do not need an extra wrapper.
30
+
31
+ ### 1. Interactive explainer — learn how something works
32
+ *"Explain how compound interest works" / "Teach me about sorting algorithms"*
33
+
34
+ Use `imagine_html` for the interactive controls — sliders, buttons, live state displays, charts. Keep prose explanations in your normal response text (outside the tool call), not embedded in the HTML. No card wrapper. Whitespace is the container.
35
+
36
+ ```html
37
+ <div style="display: flex; align-items: center; gap: 12px; margin: 0 0 1.5rem;">
38
+ <label style="font-size: 14px; color: var(--color-text-secondary);">Years</label>
39
+ <input type="range" min="1" max="40" value="20" id="years" style="flex: 1;" />
40
+ <span style="font-size: 14px; font-weight: 500; min-width: 24px;" id="years-out">20</span>
41
+ </div>
42
+
43
+ <div style="display: flex; align-items: baseline; gap: 8px; margin: 0 0 1.5rem;">
44
+ <span style="font-size: 14px; color: var(--color-text-secondary);">£1,000 →</span>
45
+ <span style="font-size: 24px; font-weight: 500;" id="result">£3,870</span>
46
+ </div>
47
+
48
+ <div style="margin: 2rem 0; position: relative; height: 240px;">
49
+ <canvas id="chart"></canvas>
50
+ </div>
51
+ ```
52
+
53
+ Use `sendPrompt()` to let users ask follow-ups: `sendPrompt('What if I increase the rate to 10%?')`
54
+
55
+ ### 2. Compare options — decision making
56
+ *"Compare pricing and features of these products" / "Help me choose between React and Vue"*
57
+
58
+ Use `imagine_html`. Side-by-side card grid for options. Highlight differences with semantic colors. Interactive elements for filtering or weighting.
59
+
60
+ - Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive columns
61
+ - Each option in a card. Use badges for key differentiators.
62
+ - Add `sendPrompt()` buttons: `sendPrompt('Tell me more about the Pro plan')`
63
+ - Don't put comparison tables inside this tool — output them as regular markdown tables in your response text instead. The tool is for the visual card grid only.
64
+ - When one option is recommended or "most popular", accent its card with `border: 2px solid var(--color-border-info)` only (2px is deliberate — the only exception to the 0.5px rule, used to accent featured items) — keep the same background and border as the other cards. Add a small badge (e.g. "Most popular") above or inside the card header using `background: var(--color-background-info); color: var(--color-text-info); font-size: 12px; padding: 4px 12px; border-radius: var(--border-radius-md)`.
65
+
66
+ ### 3. Data record — bounded UI object
67
+ *"Show me a Salesforce contact card" / "Create a receipt for this order"*
68
+
69
+ Use `imagine_html`. Wrap the entire thing in a single raised card. All content is sans-serif since it's pure UI. Use an avatar/initials circle for people (see example below).
70
+
71
+ ```html
72
+ <div style="background: var(--color-background-primary); border-radius: var(--border-radius-lg); border: 0.5px solid var(--color-border-tertiary); padding: 1rem 1.25rem;">
73
+ <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 16px;">
74
+ <div style="width: 44px; height: 44px; border-radius: 50%; background: var(--color-background-info); display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 14px; color: var(--color-text-info);">MR</div>
75
+ <div>
76
+ <p style="font-weight: 500; font-size: 15px; margin: 0;">Maya Rodriguez</p>
77
+ <p style="font-size: 13px; color: var(--color-text-secondary); margin: 0;">VP of Engineering</p>
78
+ </div>
79
+ </div>
80
+ <div style="border-top: 0.5px solid var(--color-border-tertiary); padding-top: 12px;">
81
+ <table style="width: 100%; font-size: 13px;">
82
+ <tr><td style="color: var(--color-text-secondary); padding: 4px 0;">Email</td><td style="text-align: right; padding: 4px 0; color: var(--color-text-info);">m.rodriguez@acme.com</td></tr>
83
+ <tr><td style="color: var(--color-text-secondary); padding: 4px 0;">Phone</td><td style="text-align: right; padding: 4px 0;">+1 (415) 555-0172</td></tr>
84
+ </table>
85
+ </div>
86
+ </div>
87
+ ```
@@ -0,0 +1,6 @@
1
+ ## When nothing fits
2
+ Pick the closest use case below and adapt. When nothing fits cleanly:
3
+ - Default to editorial layout if the content is explanatory
4
+ - Default to card layout if the content is a bounded object
5
+ - All core design system rules still apply
6
+ - Use `sendPrompt()` for any action that benefits from Claude thinking