@nysds/mcp-server 1.15.1 → 1.16.0-alpha5
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/README.md +40 -44
- package/data/guides/fonts.md +77 -0
- package/data/guides/form-validation.md +169 -0
- package/data/guides/frameworks/angular.md +71 -0
- package/data/guides/frameworks/dotnet.md +42 -0
- package/data/guides/frameworks/drupal.md +39 -0
- package/data/guides/frameworks/react.md +45 -0
- package/data/guides/frameworks/vanilla.md +45 -0
- package/data/guides/installation.md +73 -0
- package/data/guides/page-structure.md +160 -0
- package/data/guides/styles.md +48 -0
- package/dist/lib/cem-parser.d.ts +6 -0
- package/dist/lib/cem-parser.d.ts.map +1 -1
- package/dist/lib/cem-parser.js +18 -9
- package/dist/lib/format.d.ts +22 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +33 -0
- package/dist/prompts/nysds-mode.d.ts.map +1 -1
- package/dist/prompts/nysds-mode.js +17 -8
- package/dist/resources/guides.d.ts.map +1 -1
- package/dist/resources/guides.js +22 -26
- package/dist/tools/component-tools.d.ts +3 -5
- package/dist/tools/component-tools.d.ts.map +1 -1
- package/dist/tools/component-tools.js +51 -85
- package/dist/tools/guide-tools.d.ts +9 -0
- package/dist/tools/guide-tools.d.ts.map +1 -0
- package/dist/tools/guide-tools.js +78 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/token-tools.d.ts +2 -5
- package/dist/tools/token-tools.d.ts.map +1 -1
- package/dist/tools/token-tools.js +88 -108
- package/dist/tools/utility-tools.d.ts +8 -0
- package/dist/tools/utility-tools.d.ts.map +1 -0
- package/dist/tools/utility-tools.js +282 -0
- package/dist/tools/validation-tools.d.ts +1 -2
- package/dist/tools/validation-tools.d.ts.map +1 -1
- package/dist/tools/validation-tools.js +1 -163
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -3,40 +3,24 @@
|
|
|
3
3
|
MCP (Model Context Protocol) server for the New York State Design System. Exposes NYSDS components, design tokens, and documentation to AI assistants.
|
|
4
4
|
|
|
5
5
|
> [!WARNING]
|
|
6
|
-
> This MCP server is a work-in-progress and the current results are
|
|
6
|
+
> This MCP server is a work-in-progress and the current tool results are being refined. The server is functional, but the quality of the output depends on the robustness of the underlying documentation, and we're enhancing component JSDoc with patterns, accessibility guidance, and usage rules based on guidance from ["Effective Writing for AI" by Benny Powers](https://bennypowers.dev/cem/docs/mcp/writing-descriptions/).
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
-
> [!CAUTION]
|
|
11
|
-
> This package is not yet published to npm. You must clone the repository and build locally until it is.
|
|
12
|
-
|
|
13
|
-
Once it's cloned, run this command from the `/packages/mcp-server` directory:
|
|
14
|
-
|
|
15
10
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
cd nysds-mcp
|
|
19
|
-
|
|
20
|
-
# Switch to the MCP feature branch
|
|
21
|
-
git checkout feature/mcp-server
|
|
22
|
-
|
|
23
|
-
# Install dependencies (from repo root)
|
|
24
|
-
npm install
|
|
11
|
+
npx -y @nysds/mcp-server
|
|
12
|
+
```
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
npm run build --workspace=packages/mcp-server
|
|
14
|
+
Or install globally:
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @nysds/mcp-server
|
|
18
|
+
nysds-mcp
|
|
32
19
|
```
|
|
33
20
|
|
|
34
21
|
## Connecting to the MCP Server
|
|
35
22
|
|
|
36
|
-
Once the MCP server is
|
|
37
|
-
|
|
38
|
-
> [!NOTE]
|
|
39
|
-
> The "args" in these examples will change after the package is published to npm.
|
|
23
|
+
Once the MCP server is installed, your AI code assistant can automatically connect and communicate with it. You only need to set up the configuration. Each assistant has its own configuration format, but they all follow the same pattern: tell the assistant how to start the server (via `npx`), and it will automatically connect and use the available tools.
|
|
40
24
|
|
|
41
25
|
### GitHub Copilot
|
|
42
26
|
|
|
@@ -46,8 +30,8 @@ MCP support in GitHub Copilot is available in VS Code. Add to your VS Code setti
|
|
|
46
30
|
{
|
|
47
31
|
"servers": {
|
|
48
32
|
"nysds": {
|
|
49
|
-
"command": "
|
|
50
|
-
"args": ["
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@nysds/mcp-server"]
|
|
51
35
|
}
|
|
52
36
|
}
|
|
53
37
|
}
|
|
@@ -66,8 +50,8 @@ Add to your Claude Desktop configuration:
|
|
|
66
50
|
{
|
|
67
51
|
"mcpServers": {
|
|
68
52
|
"nysds": {
|
|
69
|
-
"command": "
|
|
70
|
-
"args": ["
|
|
53
|
+
"command": "npx",
|
|
54
|
+
"args": ["-y", "@nysds/mcp-server"]
|
|
71
55
|
}
|
|
72
56
|
}
|
|
73
57
|
}
|
|
@@ -81,8 +65,8 @@ Add to your project's `.mcp.json`:
|
|
|
81
65
|
{
|
|
82
66
|
"mcpServers": {
|
|
83
67
|
"nysds": {
|
|
84
|
-
"command": "
|
|
85
|
-
"args": ["
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["-y", "@nysds/mcp-server"]
|
|
86
70
|
}
|
|
87
71
|
}
|
|
88
72
|
}
|
|
@@ -98,8 +82,8 @@ Add to your Cursor MCP settings (`.cursor/mcp.json`):
|
|
|
98
82
|
{
|
|
99
83
|
"mcpServers": {
|
|
100
84
|
"nysds": {
|
|
101
|
-
"command": "
|
|
102
|
-
"args": ["
|
|
85
|
+
"command": "npx",
|
|
86
|
+
"args": ["-y", "@nysds/mcp-server"]
|
|
103
87
|
}
|
|
104
88
|
}
|
|
105
89
|
}
|
|
@@ -107,23 +91,29 @@ Add to your Cursor MCP settings (`.cursor/mcp.json`):
|
|
|
107
91
|
|
|
108
92
|
## Available Tools
|
|
109
93
|
|
|
110
|
-
###
|
|
94
|
+
### Components
|
|
95
|
+
|
|
96
|
+
| Tool | Description |
|
|
97
|
+
|------|-------------|
|
|
98
|
+
| `find_components` | Search for components by name/description, or list all (omit query) |
|
|
99
|
+
| `get_component` | Full documentation for a specific component. Use `includeExamples: true` for code examples. |
|
|
100
|
+
| `validate_component_api` | Validate that attributes/properties are valid for a component |
|
|
101
|
+
|
|
102
|
+
### Design Tokens
|
|
111
103
|
|
|
112
104
|
| Tool | Description |
|
|
113
105
|
|------|-------------|
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `get_usage_guide` | Installation and usage patterns |
|
|
106
|
+
| `get_tokens` | Get tokens, categories, or agency themes. Filter by category or layer. |
|
|
107
|
+
| `find_tokens` | Search tokens by CSS variable name, value, or description |
|
|
108
|
+
| `get_token_info` | Detailed info for a specific token with optional context validation |
|
|
109
|
+
| `get_token_graph` | Token dependency graph showing references and usage |
|
|
119
110
|
|
|
120
|
-
###
|
|
111
|
+
### Styles & Guides
|
|
121
112
|
|
|
122
113
|
| Tool | Description |
|
|
123
114
|
|------|-------------|
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `find_tokens` | Search tokens by name/value |
|
|
115
|
+
| `get_utility_classes` | Grid, flexbox, spacing, display, and typography utility classes |
|
|
116
|
+
| `get_guide` | Guides for installation, forms, styles, fonts, page structure, or framework setup (angular, react, dotnet, drupal, vanilla). Angular, React, .NET, and Drupal guides are currently untested. |
|
|
127
117
|
|
|
128
118
|
## Available Resources
|
|
129
119
|
|
|
@@ -131,7 +121,13 @@ Add to your Cursor MCP settings (`.cursor/mcp.json`):
|
|
|
131
121
|
|-----|-------------|
|
|
132
122
|
| `nysds://components` | Component overview list |
|
|
133
123
|
| `nysds://component/{tag}` | Individual component docs |
|
|
134
|
-
| `nysds://tokens` | All design tokens |
|
|
124
|
+
| `nysds://tokens` | All design tokens with CSS variables and descriptions |
|
|
125
|
+
| `nysds://tokens/css` | Raw tokens.css file content |
|
|
126
|
+
| `nysds://tokens/graph` | Token dependency graph with stats |
|
|
127
|
+
| `nysds://tokens/color` | Color tokens only |
|
|
128
|
+
| `nysds://tokens/font` | Typography tokens |
|
|
129
|
+
| `nysds://tokens/space` | Spacing tokens |
|
|
130
|
+
| `nysds://tokens/size` | Size tokens |
|
|
135
131
|
| `nysds://installation` | Installation guide |
|
|
136
132
|
|
|
137
133
|
## Prompts
|
|
@@ -162,7 +158,7 @@ Once configured, you can ask your AI assistant questions like:
|
|
|
162
158
|
**Framework integration:**
|
|
163
159
|
- "How do I set up NYSDS components in my Angular project?"
|
|
164
160
|
- "Show me how to use nys-button in React"
|
|
165
|
-
- "
|
|
161
|
+
- "How do I integrate NYSDS with Drupal?"
|
|
166
162
|
|
|
167
163
|
**Code review:**
|
|
168
164
|
- "Is this the correct way to use the nys-select component?"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# NYSDS Font Setup Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
NYSDS uses proprietary fonts that are licensed for New York State government use. These fonts are distributed through a private repository.
|
|
6
|
+
|
|
7
|
+
## Obtaining Fonts
|
|
8
|
+
|
|
9
|
+
The NYSDS font package is available through a private npm registry. Contact the NYSDS team for access:
|
|
10
|
+
|
|
11
|
+
1. Request access to the private font repository
|
|
12
|
+
2. Configure your npm to use the private registry
|
|
13
|
+
3. Install the font package
|
|
14
|
+
|
|
15
|
+
## Manual Installation
|
|
16
|
+
|
|
17
|
+
If you have the font files:
|
|
18
|
+
|
|
19
|
+
1. Place font files in your project (e.g., `/assets/fonts/`)
|
|
20
|
+
2. Include the font CSS in your stylesheet
|
|
21
|
+
3. The fonts will be loaded automatically when using NYSDS styles
|
|
22
|
+
|
|
23
|
+
### Directory Structure
|
|
24
|
+
```
|
|
25
|
+
/assets/fonts/
|
|
26
|
+
├── proxima-nova/
|
|
27
|
+
│ ├── proxima-nova-regular.woff2
|
|
28
|
+
│ ├── proxima-nova-medium.woff2
|
|
29
|
+
│ ├── proxima-nova-semibold.woff2
|
|
30
|
+
│ └── proxima-nova-bold.woff2
|
|
31
|
+
└── d-din/
|
|
32
|
+
├── d-din-regular.woff2
|
|
33
|
+
└── d-din-bold.woff2
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Font Tokens
|
|
37
|
+
|
|
38
|
+
NYSDS provides the following font family tokens:
|
|
39
|
+
|
|
40
|
+
| Token | Description | Usage |
|
|
41
|
+
|-------|-------------|-------|
|
|
42
|
+
| `--nys-font-body` | Body text font | Paragraphs, general content |
|
|
43
|
+
| `--nys-font-heading` | Heading font | h1-h6 elements |
|
|
44
|
+
| `--nys-font-ui` | UI font | Buttons, labels, form elements |
|
|
45
|
+
| `--nys-font-display` | Display font | Large headlines, hero text |
|
|
46
|
+
| `--nys-font-brand` | Brand font | Brand-specific usage |
|
|
47
|
+
| `--nys-font-alt` | Alternative font | Secondary content |
|
|
48
|
+
|
|
49
|
+
### Usage Example
|
|
50
|
+
```css
|
|
51
|
+
.custom-heading {
|
|
52
|
+
font-family: var(--nys-font-heading);
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Font Preloading
|
|
58
|
+
|
|
59
|
+
For optimal performance, preload critical fonts in your HTML head:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<link rel="preload" href="/assets/fonts/proxima-nova/proxima-nova-regular.woff2" as="font" type="font/woff2" crossorigin>
|
|
63
|
+
<link rel="preload" href="/assets/fonts/proxima-nova/proxima-nova-semibold.woff2" as="font" type="font/woff2" crossorigin>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Fallback Fonts
|
|
67
|
+
|
|
68
|
+
NYSDS includes system font fallbacks. If custom fonts are unavailable, the design system will gracefully degrade to:
|
|
69
|
+
|
|
70
|
+
- **Sans-serif:** -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial
|
|
71
|
+
- **Monospace:** "SF Mono", Consolas, "Liberation Mono", Menlo, monospace
|
|
72
|
+
|
|
73
|
+
## Getting Access
|
|
74
|
+
|
|
75
|
+
To request access to the NYSDS font package, contact the NYSDS team through:
|
|
76
|
+
- The NYS Digital Services team
|
|
77
|
+
- Your agency's designated NYSDS contact
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# NYSDS Form Validation Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
NYSDS form components include built-in validation support using the `showError` and `errorMessage` properties. All form components integrate with ElementInternals for native form validation.
|
|
6
|
+
|
|
7
|
+
## Error Display Properties
|
|
8
|
+
|
|
9
|
+
All NYSDS form components support these validation properties:
|
|
10
|
+
|
|
11
|
+
| Property | Type | Description |
|
|
12
|
+
|----------|------|-------------|
|
|
13
|
+
| `showError` | boolean | When true, displays the error state |
|
|
14
|
+
| `errorMessage` | string | The error message to display |
|
|
15
|
+
| `required` | boolean | Marks the field as required |
|
|
16
|
+
|
|
17
|
+
## Error Summary Pattern
|
|
18
|
+
|
|
19
|
+
Display an error summary at the top of forms with links to each field:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<nys-alert type="danger" heading="Please correct the following errors">
|
|
23
|
+
<ul>
|
|
24
|
+
<li><a href="#email-field">Email address is required</a></li>
|
|
25
|
+
<li><a href="#phone-field">Phone number format is invalid</a></li>
|
|
26
|
+
</ul>
|
|
27
|
+
</nys-alert>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This pattern:
|
|
31
|
+
- Appears at the top of the form after submission attempt
|
|
32
|
+
- Lists all errors with anchor links to the fields
|
|
33
|
+
- Helps users quickly navigate to problem areas
|
|
34
|
+
- Is essential for accessibility (screen reader users)
|
|
35
|
+
|
|
36
|
+
## Inline Error Pattern
|
|
37
|
+
|
|
38
|
+
Display errors directly on the form fields:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<nys-textinput
|
|
42
|
+
id="email-field"
|
|
43
|
+
label="Email"
|
|
44
|
+
required
|
|
45
|
+
showError
|
|
46
|
+
errorMessage="Please enter a valid email address"
|
|
47
|
+
></nys-textinput>
|
|
48
|
+
|
|
49
|
+
<nys-select
|
|
50
|
+
id="state-field"
|
|
51
|
+
label="State"
|
|
52
|
+
required
|
|
53
|
+
showError
|
|
54
|
+
errorMessage="Please select a state"
|
|
55
|
+
></nys-select>
|
|
56
|
+
|
|
57
|
+
<nys-radiogroup
|
|
58
|
+
id="preference-field"
|
|
59
|
+
label="Contact Preference"
|
|
60
|
+
showError
|
|
61
|
+
errorMessage="Please select a contact preference"
|
|
62
|
+
>
|
|
63
|
+
<nys-radiobutton label="Email" value="email"></nys-radiobutton>
|
|
64
|
+
<nys-radiobutton label="Phone" value="phone"></nys-radiobutton>
|
|
65
|
+
</nys-radiogroup>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Complete Form Example
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<form id="contact-form" novalidate>
|
|
72
|
+
<!-- Error summary (hidden initially, shown on validation failure) -->
|
|
73
|
+
<nys-alert id="error-summary" type="danger" heading="Please correct the following errors" hidden>
|
|
74
|
+
<ul id="error-list"></ul>
|
|
75
|
+
</nys-alert>
|
|
76
|
+
|
|
77
|
+
<nys-textinput
|
|
78
|
+
id="name-field"
|
|
79
|
+
label="Full Name"
|
|
80
|
+
required
|
|
81
|
+
class="nys-margin-b-300"
|
|
82
|
+
></nys-textinput>
|
|
83
|
+
|
|
84
|
+
<nys-textinput
|
|
85
|
+
id="email-field"
|
|
86
|
+
label="Email Address"
|
|
87
|
+
type="email"
|
|
88
|
+
required
|
|
89
|
+
class="nys-margin-b-300"
|
|
90
|
+
></nys-textinput>
|
|
91
|
+
|
|
92
|
+
<nys-textarea
|
|
93
|
+
id="message-field"
|
|
94
|
+
label="Message"
|
|
95
|
+
required
|
|
96
|
+
class="nys-margin-b-400"
|
|
97
|
+
></nys-textarea>
|
|
98
|
+
|
|
99
|
+
<nys-button type="submit" label="Submit"></nys-button>
|
|
100
|
+
</form>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## JavaScript Validation Example
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
const form = document.getElementById('contact-form');
|
|
107
|
+
const errorSummary = document.getElementById('error-summary');
|
|
108
|
+
const errorList = document.getElementById('error-list');
|
|
109
|
+
|
|
110
|
+
form.addEventListener('submit', (e) => {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
|
|
113
|
+
const errors = [];
|
|
114
|
+
|
|
115
|
+
// Validate each field
|
|
116
|
+
const nameField = document.getElementById('name-field');
|
|
117
|
+
if (!nameField.value) {
|
|
118
|
+
nameField.showError = true;
|
|
119
|
+
nameField.errorMessage = 'Full name is required';
|
|
120
|
+
errors.push({ id: 'name-field', message: 'Full name is required' });
|
|
121
|
+
} else {
|
|
122
|
+
nameField.showError = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const emailField = document.getElementById('email-field');
|
|
126
|
+
if (!emailField.value) {
|
|
127
|
+
emailField.showError = true;
|
|
128
|
+
emailField.errorMessage = 'Email address is required';
|
|
129
|
+
errors.push({ id: 'email-field', message: 'Email address is required' });
|
|
130
|
+
} else if (!isValidEmail(emailField.value)) {
|
|
131
|
+
emailField.showError = true;
|
|
132
|
+
emailField.errorMessage = 'Please enter a valid email address';
|
|
133
|
+
errors.push({ id: 'email-field', message: 'Please enter a valid email address' });
|
|
134
|
+
} else {
|
|
135
|
+
emailField.showError = false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Show/hide error summary
|
|
139
|
+
if (errors.length > 0) {
|
|
140
|
+
errorList.innerHTML = errors
|
|
141
|
+
.map(err => `<li><a href="#${err.id}">${err.message}</a></li>`)
|
|
142
|
+
.join('');
|
|
143
|
+
errorSummary.hidden = false;
|
|
144
|
+
errorSummary.scrollIntoView({ behavior: 'smooth' });
|
|
145
|
+
} else {
|
|
146
|
+
errorSummary.hidden = true;
|
|
147
|
+
form.submit();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Form Components with Validation Support
|
|
153
|
+
|
|
154
|
+
The following NYSDS components support `showError` and `errorMessage`:
|
|
155
|
+
|
|
156
|
+
- `nys-textinput` - Text input fields
|
|
157
|
+
- `nys-textarea` - Multi-line text areas
|
|
158
|
+
- `nys-select` - Dropdown selects
|
|
159
|
+
- `nys-radiogroup` - Radio button groups
|
|
160
|
+
- `nys-checkbox` - Checkboxes
|
|
161
|
+
- `nys-checkboxgroup` - Checkbox groups
|
|
162
|
+
- `nys-date` - Date pickers
|
|
163
|
+
|
|
164
|
+
## Accessibility Considerations
|
|
165
|
+
|
|
166
|
+
1. **Error summary links**: Include anchor links to fields for keyboard navigation
|
|
167
|
+
2. **Focus management**: Move focus to error summary or first error field on validation failure
|
|
168
|
+
3. **ARIA attributes**: NYSDS components automatically set `aria-invalid` and `aria-describedby`
|
|
169
|
+
4. **Clear error messages**: Use specific, actionable error text
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# NYSDS with Angular
|
|
2
|
+
|
|
3
|
+
> **Note:** Angular integration is currently untested. The guidance below is based on standard web component usage patterns and may require adjustments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nysds/components @nysds/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Load styles
|
|
12
|
+
|
|
13
|
+
Add the NYSDS stylesheet to `angular.json`:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"projects": {
|
|
18
|
+
"your-app": {
|
|
19
|
+
"architect": {
|
|
20
|
+
"build": {
|
|
21
|
+
"options": {
|
|
22
|
+
"styles": [
|
|
23
|
+
"node_modules/@nysds/styles/dist/nysds-full.min.css",
|
|
24
|
+
"src/styles.css"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use `nysds-full.min.css` for new projects (includes reset, typography, and utilities) or `nysds.min.css` for existing projects (CSS variables only).
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
Add `CUSTOM_ELEMENTS_SCHEMA` to your module so Angular allows custom element tags:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
|
42
|
+
|
|
43
|
+
@NgModule({
|
|
44
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
45
|
+
})
|
|
46
|
+
export class AppModule {}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For standalone components:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
53
|
+
|
|
54
|
+
@Component({
|
|
55
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
56
|
+
template: `<nys-button label="Click me"></nys-button>`
|
|
57
|
+
})
|
|
58
|
+
export class MyComponent {}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
Import components in the component or module where they're used:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import '@nysds/nys-button';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<nys-button label="Click me"></nys-button>
|
|
71
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# NYSDS with .NET / Blazor
|
|
2
|
+
|
|
3
|
+
> **Note:** .NET / Blazor integration is currently untested. The guidance below is based on standard web component usage patterns and may require adjustments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add the NYSDS scripts and styles to your layout file (e.g., `_Layout.cshtml` or `App.razor`).
|
|
8
|
+
|
|
9
|
+
Install via npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @nysds/components @nysds/styles
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then reference in your layout:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<head>
|
|
19
|
+
<!-- New project: includes reset, typography, and utility classes -->
|
|
20
|
+
<link rel="stylesheet" href="node_modules/@nysds/styles/dist/nysds-full.min.css" />
|
|
21
|
+
|
|
22
|
+
<!-- Existing project: CSS variables only -->
|
|
23
|
+
<!-- <link rel="stylesheet" href="node_modules/@nysds/styles/dist/nysds.min.css" /> -->
|
|
24
|
+
|
|
25
|
+
<script type="module" src="node_modules/@nysds/components/dist/nysds.es.js"></script>
|
|
26
|
+
</head>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage in Razor
|
|
30
|
+
|
|
31
|
+
```razor
|
|
32
|
+
<nys-button label="Click me"></nys-button>
|
|
33
|
+
<nys-alert type="info">This is an informational message.</nys-alert>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage in Blazor
|
|
37
|
+
|
|
38
|
+
Blazor treats unknown elements as custom elements by default. No additional configuration is needed:
|
|
39
|
+
|
|
40
|
+
```razor
|
|
41
|
+
<nys-button label="Submit" variant="filled"></nys-button>
|
|
42
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# NYSDS with Drupal
|
|
2
|
+
|
|
3
|
+
> **Note:** Drupal integration is currently untested. The guidance below is based on standard web component usage patterns and may require adjustments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the packages:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nysds/components @nysds/styles
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add the NYSDS styles and scripts to your theme's `*.libraries.yml`:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
nysds:
|
|
17
|
+
css:
|
|
18
|
+
theme:
|
|
19
|
+
# New project: includes reset, typography, and utility classes
|
|
20
|
+
/node_modules/@nysds/styles/dist/nysds-full.min.css: { minified: true }
|
|
21
|
+
# Existing project: CSS variables only
|
|
22
|
+
# /node_modules/@nysds/styles/dist/nysds.min.css: { minified: true }
|
|
23
|
+
js:
|
|
24
|
+
/node_modules/@nysds/components/dist/nysds.es.js: { attributes: { type: module } }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then attach the library in your theme's `.info.yml`:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
libraries:
|
|
31
|
+
- mytheme/nysds
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage in Twig
|
|
35
|
+
|
|
36
|
+
```twig
|
|
37
|
+
<nys-button label="{{ 'Click me'|t }}"></nys-button>
|
|
38
|
+
<nys-alert type="info">{{ 'This is an alert.'|t }}</nys-alert>
|
|
39
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# NYSDS with React
|
|
2
|
+
|
|
3
|
+
> **Note:** React integration is currently untested. The guidance below is based on standard web component usage patterns and may require adjustments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nysds/components @nysds/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Load styles
|
|
12
|
+
|
|
13
|
+
Import the NYSDS stylesheet in your app entry point (e.g., `index.tsx` or `App.tsx`):
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
// New project: includes reset, typography, and utility classes
|
|
17
|
+
import '@nysds/styles/dist/nysds-full.min.css';
|
|
18
|
+
|
|
19
|
+
// Existing project: CSS variables only (styles components, nothing else)
|
|
20
|
+
// import '@nysds/styles/dist/nysds.min.css';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Import components and use them in JSX:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import '@nysds/nys-button';
|
|
29
|
+
import '@nysds/nys-alert';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
<nys-button label="Click me"></nys-button>
|
|
35
|
+
<nys-alert type="info">This is an alert.</nys-alert>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Notes on web components in React
|
|
42
|
+
|
|
43
|
+
- String attributes work normally: `<nys-button label="Click me" />`
|
|
44
|
+
- For event listeners, use `ref` and `addEventListener` — React's synthetic event system doesn't forward to custom elements
|
|
45
|
+
- Boolean attributes should be set explicitly: `<nys-button disabled={true} />`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# NYSDS with Vanilla JavaScript
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @nysds/components @nysds/styles
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Load styles
|
|
10
|
+
|
|
11
|
+
Choose the right stylesheet for your project:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<!-- New project: includes reset, typography, and utility classes -->
|
|
15
|
+
<link rel="stylesheet" href="node_modules/@nysds/styles/dist/nysds-full.min.css" />
|
|
16
|
+
|
|
17
|
+
<!-- Existing project: CSS variables only (styles components, nothing else) -->
|
|
18
|
+
<link rel="stylesheet" href="node_modules/@nysds/styles/dist/nysds.min.css" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!DOCTYPE html>
|
|
25
|
+
<html lang="en">
|
|
26
|
+
<head>
|
|
27
|
+
<link rel="stylesheet" href="node_modules/@nysds/styles/dist/nysds-full.min.css" />
|
|
28
|
+
<script type="module">
|
|
29
|
+
import '@nysds/components';
|
|
30
|
+
</script>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<nys-button label="Click me"></nys-button>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can also import individual components to reduce bundle size:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script type="module">
|
|
42
|
+
import '@nysds/nys-button';
|
|
43
|
+
import '@nysds/nys-alert';
|
|
44
|
+
</script>
|
|
45
|
+
```
|