gd-design-library 0.7.3 → 0.7.5
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.
- package/package.json +1 -1
- package/ai/README.md +0 -137
package/package.json
CHANGED
package/ai/README.md
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# AI prompt and codegen usage for gd-design-library (GridKit)
|
|
2
|
-
|
|
3
|
-
This README explains how to use the AI helpers in `/ai` to reliably generate React/TSX that only uses `gd-design-library`. It consolidates the hard rules, guardrails, and helper APIs exposed by this folder.
|
|
4
|
-
|
|
5
|
-
Why these rules exist:
|
|
6
|
-
|
|
7
|
-
- Consistency: a single design system source makes UI consistent and themable.
|
|
8
|
-
- Accessibility: components provide sensible defaults and ARIA support.
|
|
9
|
-
- Maintainability: no ad‑hoc CSS/HTML or third‑party UI imports.
|
|
10
|
-
|
|
11
|
-
Core rule (must follow):
|
|
12
|
-
|
|
13
|
-
- Use ONLY components exported by `gd-design-library` for layout, forms, feedback, display, and navigation. Do not invent components. Do not import from other UI libraries.
|
|
14
|
-
|
|
15
|
-
Single-source import (enforced):
|
|
16
|
-
|
|
17
|
-
- Correct: `import { Form, Input, Button, Typography, FlexContainer, Column, Card, Link } from 'gd-design-library';`
|
|
18
|
-
- Incorrect: `import Button from 'some-ui-lib';`, `import { Box } from '@mui/material';`, or using `./styles.css` for layout spacing.
|
|
19
|
-
|
|
20
|
-
How to use the AI helpers
|
|
21
|
-
|
|
22
|
-
1. Programmatic prompt builder (recommended)
|
|
23
|
-
|
|
24
|
-
- Import from the AI helpers barrel:
|
|
25
|
-
- `import { buildClaudeSystemPrompt } from 'gd-design-library/ai';`
|
|
26
|
-
- Build your system+task prompt:
|
|
27
|
-
- `const prompt = buildClaudeSystemPrompt('Create a sign-in form with email and password');`
|
|
28
|
-
What this does:
|
|
29
|
-
- Includes a live list of available components and composition tips from `./ai/schemas/components.ts` and `./ai/schemas/components/*`.
|
|
30
|
-
- Enforces single-source imports from `gd-design-library` and accessibility/theming guardrails.
|
|
31
|
-
|
|
32
|
-
2. Legacy/basic builder
|
|
33
|
-
|
|
34
|
-
- `buildGDLibraryPrompt(request: string)` is kept for compatibility. It defers to `buildClaudeSystemPrompt`.
|
|
35
|
-
|
|
36
|
-
3. Direct constant (advanced)
|
|
37
|
-
|
|
38
|
-
- `CLAUDE_GRIDKIT_SYSTEM_PROMPT` contains the full system instructions. You can append your task to it manually if needed.
|
|
39
|
-
|
|
40
|
-
Practical generation tips (what the model should output)
|
|
41
|
-
|
|
42
|
-
- Output ONLY valid React TSX. No markdown fences or commentary.
|
|
43
|
-
- Prefer composition using the provided layout primitives (FlexContainer, Column, Row, Card.\* subcomponents, etc.).
|
|
44
|
-
- Keep custom styles minimal; use component props for spacing, alignment, sizing.
|
|
45
|
-
- Always ensure accessibility: label all form controls (Label or Input label prop), use appropriate aria-\* attributes, and keep keyboard navigation sensible.
|
|
46
|
-
- Do not inline the ThemeProvider inside leaf components; provide it at the app root. See Theme provider/hook entries in the schema.
|
|
47
|
-
- Keep imports consolidated to one source: `gd-design-library`.
|
|
48
|
-
|
|
49
|
-
API guardrails from the schema/prompt (must-follow)
|
|
50
|
-
|
|
51
|
-
- Row/Column/Card.Row/Card.Column: use `isWrap` (boolean), NOT `wrap`.
|
|
52
|
-
- Image and Card.Image: `width` and `height` props are numbers only (e.g., `width={96}`), not strings like `"96px"`.
|
|
53
|
-
- Card.Title and other Card subcomponents: `sizeVariant` only accepts `CardSizeVariant.Default` or `CardSizeVariant.Sm`.
|
|
54
|
-
- Counter and Card.Counter: use `initial` (not `value`) for the starting quantity; use `onCounterChange` as the change handler.
|
|
55
|
-
- Button `variant` must be one of `ButtonVariant.Contained | ButtonVariant.Outlined | ButtonVariant.Text | ButtonVariant.Inherit`.
|
|
56
|
-
- Button `color` must be one of `ButtonColorVariant.Primary | ButtonColorVariant.Secondary`.
|
|
57
|
-
|
|
58
|
-
Component catalog
|
|
59
|
-
|
|
60
|
-
- The authoritative, up-to-date list of supported components, their props, examples, and composition tips is generated from:
|
|
61
|
-
- `./schemas/components.ts` (registry)
|
|
62
|
-
- `./schemas/components/*` (per-component schemas)
|
|
63
|
-
- The list includes layout, forms, feedback, display, navigation, and theme provider/hook entries. Always consult these when unsure.
|
|
64
|
-
- Quick categories (from schema v1.0.0):
|
|
65
|
-
- Theme: useTheme.provider (ThemeProvider), useTheme.hook (useTheme)
|
|
66
|
-
- Layout: FlexContainer, Column, Row, Wrapper, Scroll, Separator
|
|
67
|
-
- Forms: Form, Input, Select, Search, Label, Textarea, Switch, Toggle, RadioGroup, Slider, InputFile, DragAndDropFiles
|
|
68
|
-
- Feedback & overlays: InlineNotification, Loader, Skeleton, Snackbar, SnackbarManager, Tooltip, Modal, Portal
|
|
69
|
-
- Navigation & structure: Breadcrumbs, Tabs, Stepper, List, Accordion, Link
|
|
70
|
-
- Display & content: Typography, Button, Icon, Image, Card, Avatar, Carousel, ContentCarousel, Counter, Price, ProgressBar, Rating, ChatContainer, ChatBubble
|
|
71
|
-
- Not part of gd-design-library (do not request/use): Grid, Stack, Alert, Toast, Table, Badge, ButtonGroup, Dropdown, Drawer, Popover, Pagination, Heading, Spinner.
|
|
72
|
-
|
|
73
|
-
Patterns from stories (grounded tips)
|
|
74
|
-
|
|
75
|
-
- Textarea:
|
|
76
|
-
- Control resizing with the `resize` prop using the `TextareaResize` enum (e.g., None, Horizontal, Vertical, Both). Prefer `dynamicHeightAdjustment` for auto-growing content.
|
|
77
|
-
- Use `rows` for fixed height or `minHeight`/`maxHeight` for constraints.
|
|
78
|
-
- Controlled vs uncontrolled: use `value` with `onChange` for controlled; use `defaultValue` for uncontrolled.
|
|
79
|
-
- Accessibility: use `ariaDescribedBy` to connect helper/error text; set `readOnly`/`disabled` as needed; `autoFocus` is available.
|
|
80
|
-
- Limits and events: `maxLength` to constrain length; `onCustomResize` receives `{ height, width }` when user resizes.
|
|
81
|
-
- Buttons:
|
|
82
|
-
- Variants: `ButtonVariant.Contained | Outlined | Text | Inherit`; Colors: `ButtonColorVariant.Primary | Secondary`. For icon-only buttons, set `isIcon`.
|
|
83
|
-
- Forms and labels:
|
|
84
|
-
- Always provide a visible label via the `label` prop or a separate `<Label htmlFor>` paired with the input `name/id`. Wrap controls with `<Form>` and handle submit via `onSubmit`.
|
|
85
|
-
- Layout composition:
|
|
86
|
-
- Use `FlexContainer` with `Column`/`Row` and `gap` to manage spacing. Avoid raw CSS margins except where necessary.
|
|
87
|
-
- Cards and images:
|
|
88
|
-
- `Card.Title` uses `sizeVariant={CardSizeVariant.Default | CardSizeVariant.Sm}` only. `Card.Image` and `Image` require numeric `width`/`height` props.
|
|
89
|
-
|
|
90
|
-
Example: Correct usage
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
import { Form, Input, Button, Typography, FlexContainer, Column, Card, Link } from 'gd-design-library';
|
|
94
|
-
|
|
95
|
-
export function LoginCard() {
|
|
96
|
-
return (
|
|
97
|
-
<FlexContainer alignItems="center" justifyContent="center" minHeight="100vh" padding="24px">
|
|
98
|
-
<Card width={360} padding="24px">
|
|
99
|
-
<Column gap="12px">
|
|
100
|
-
<Typography as="h1" variant="h2">Sign in</Typography>
|
|
101
|
-
<Form onSubmit={(e) => { e.preventDefault(); /* TODO: submit */ }}>
|
|
102
|
-
<Column gap="12px">
|
|
103
|
-
<Input variant="email" label="Email" name="email" />
|
|
104
|
-
<Input variant="password" label="Password" name="password" />
|
|
105
|
-
<Button type="submit" fullWidth>Sign in</Button>
|
|
106
|
-
</Column>
|
|
107
|
-
</Form>
|
|
108
|
-
<Typography variant="small">
|
|
109
|
-
Don’t have an account? <Link href="#">Sign up</Link>
|
|
110
|
-
</Typography>
|
|
111
|
-
</Column>
|
|
112
|
-
</Card>
|
|
113
|
-
</FlexContainer>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Incorrect usage (anti-patterns)
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
import Button from 'some-ui-lib';
|
|
122
|
-
import { Box } from '@mui/material';
|
|
123
|
-
|
|
124
|
-
export function Login() {
|
|
125
|
-
return (
|
|
126
|
-
<div className="container"> {/* Do not build layout with raw divs/CSS */}
|
|
127
|
-
<button>Sign in</button> {/* Do not use native elements for styled UI */}
|
|
128
|
-
</div>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Troubleshooting and notes
|
|
134
|
-
|
|
135
|
-
- If a component/prop isn’t recognized, verify it exists in `gd-design-library` exports and the AI schemas under `./ai/schemas/components/*`.
|
|
136
|
-
- When new components are added to the design system, update their schema and the central registry in `./ai/schemas/components.ts` so prompts stay accurate.
|
|
137
|
-
- The default intro string in code (`defaultAIPromptIntro`) is aligned with the schema. Prefer the schema-driven builders (e.g., `buildClaudeSystemPrompt`) for the most accurate, current catalog.
|