@cobwds/mcp-server 1.19.3
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 +235 -0
- package/data/cem/custom-elements.json +15923 -0
- package/data/guides/.gitkeep +0 -0
- package/data/guides/fonts.md +56 -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 +115 -0
- package/data/guides/frameworks/vanilla.md +45 -0
- package/data/guides/installation.md +73 -0
- package/data/guides/page-structure.md +161 -0
- package/data/guides/styles.md +48 -0
- package/data/guides/themes.md +61 -0
- package/data/tokens/tokens.css +479 -0
- package/data/tokens/tokens.json +1553 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/lib/cem-parser.d.ts +102 -0
- package/dist/lib/cem-parser.d.ts.map +1 -0
- package/dist/lib/cem-parser.js +92 -0
- package/dist/lib/search.d.ts +20 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +87 -0
- package/dist/lib/token-parser.d.ts +128 -0
- package/dist/lib/token-parser.d.ts.map +1 -0
- package/dist/lib/token-parser.js +431 -0
- package/dist/prompts/cobwds-mode.d.ts +8 -0
- package/dist/prompts/cobwds-mode.d.ts.map +1 -0
- package/dist/prompts/cobwds-mode.js +60 -0
- package/dist/resources/components.d.ts +12 -0
- package/dist/resources/components.d.ts.map +1 -0
- package/dist/resources/components.js +62 -0
- package/dist/resources/guides.d.ts +11 -0
- package/dist/resources/guides.d.ts.map +1 -0
- package/dist/resources/guides.js +76 -0
- package/dist/resources/index.d.ts +8 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +13 -0
- package/dist/resources/tokens.d.ts +17 -0
- package/dist/resources/tokens.d.ts.map +1 -0
- package/dist/resources/tokens.js +312 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +30 -0
- package/dist/tools/component-tools.d.ts +12 -0
- package/dist/tools/component-tools.d.ts.map +1 -0
- package/dist/tools/component-tools.js +95 -0
- 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 +80 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/token-tools.d.ts +13 -0
- package/dist/tools/token-tools.d.ts.map +1 -0
- package/dist/tools/token-tools.js +207 -0
- 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 +293 -0
- package/dist/tools/validation-tools.d.ts +11 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +60 -0
- package/package.json +54 -0
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# COBWDS Font Setup Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
COBWDS uses two open-license Google Fonts:
|
|
6
|
+
|
|
7
|
+
- **Lora** — body text
|
|
8
|
+
- **Montserrat** — headings, display text, agency titles, and UI elements
|
|
9
|
+
|
|
10
|
+
## Installation (Google Fonts)
|
|
11
|
+
|
|
12
|
+
Add this to your HTML head:
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
16
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
17
|
+
<link href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,700&family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or include the Storybook helper stylesheet:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<link rel="stylesheet" href="/assets/fonts/cobwds-fonts.css">
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Font Tokens
|
|
27
|
+
|
|
28
|
+
| Token | Description | Font |
|
|
29
|
+
|-------|-------------|------|
|
|
30
|
+
| `--cob-font-family-body` | Body / paragraph text | Lora |
|
|
31
|
+
| `--cob-font-family-ui` | Buttons, labels, forms | Montserrat |
|
|
32
|
+
| `--cob-font-family-heading` | h1–h6 | Montserrat |
|
|
33
|
+
| `--cob-font-family-display` | Hero / display text | Montserrat |
|
|
34
|
+
| `--cob-font-family-agency` | Agency / program titles | Montserrat |
|
|
35
|
+
| `--cob-font-family-serif` | Primitive serif | Lora |
|
|
36
|
+
| `--cob-font-family-sans` | Primitive sans | Montserrat |
|
|
37
|
+
| `--cob-font-family-monospace` | Code | Roboto Mono / system mono |
|
|
38
|
+
|
|
39
|
+
### Usage Example
|
|
40
|
+
```css
|
|
41
|
+
.custom-heading {
|
|
42
|
+
font-family: var(--cob-font-family-heading);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.custom-body {
|
|
46
|
+
font-family: var(--cob-font-family-body);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Fallback Fonts
|
|
51
|
+
|
|
52
|
+
If custom fonts are unavailable, the web design system falls back to:
|
|
53
|
+
|
|
54
|
+
- **Serif (Lora):** Georgia, Cambria, Times New Roman, Times, serif
|
|
55
|
+
- **Sans (Montserrat):** -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif
|
|
56
|
+
- **Monospace:** Consolas, Courier, monospace
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# COBWDS Form Validation Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
COBWDS 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 COBWDS 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
|
+
<cob-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
|
+
</cob-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
|
+
<cob-textinput
|
|
42
|
+
id="email-field"
|
|
43
|
+
label="Email"
|
|
44
|
+
required
|
|
45
|
+
showError
|
|
46
|
+
errorMessage="Please enter a valid email address"
|
|
47
|
+
></cob-textinput>
|
|
48
|
+
|
|
49
|
+
<cob-select
|
|
50
|
+
id="state-field"
|
|
51
|
+
label="State"
|
|
52
|
+
required
|
|
53
|
+
showError
|
|
54
|
+
errorMessage="Please select a state"
|
|
55
|
+
></cob-select>
|
|
56
|
+
|
|
57
|
+
<cob-radiogroup
|
|
58
|
+
id="preference-field"
|
|
59
|
+
label="Contact Preference"
|
|
60
|
+
showError
|
|
61
|
+
errorMessage="Please select a contact preference"
|
|
62
|
+
>
|
|
63
|
+
<cob-radiobutton label="Email" value="email"></cob-radiobutton>
|
|
64
|
+
<cob-radiobutton label="Phone" value="phone"></cob-radiobutton>
|
|
65
|
+
</cob-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
|
+
<cob-alert id="error-summary" type="danger" heading="Please correct the following errors" hidden>
|
|
74
|
+
<ul id="error-list"></ul>
|
|
75
|
+
</cob-alert>
|
|
76
|
+
|
|
77
|
+
<cob-textinput
|
|
78
|
+
id="name-field"
|
|
79
|
+
label="Full Name"
|
|
80
|
+
required
|
|
81
|
+
class="cob-margin-b-300"
|
|
82
|
+
></cob-textinput>
|
|
83
|
+
|
|
84
|
+
<cob-textinput
|
|
85
|
+
id="email-field"
|
|
86
|
+
label="Email Address"
|
|
87
|
+
type="email"
|
|
88
|
+
required
|
|
89
|
+
class="cob-margin-b-300"
|
|
90
|
+
></cob-textinput>
|
|
91
|
+
|
|
92
|
+
<cob-textarea
|
|
93
|
+
id="message-field"
|
|
94
|
+
label="Message"
|
|
95
|
+
required
|
|
96
|
+
class="cob-margin-b-400"
|
|
97
|
+
></cob-textarea>
|
|
98
|
+
|
|
99
|
+
<cob-button type="submit" label="Submit"></cob-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 COBWDS components support `showError` and `errorMessage`:
|
|
155
|
+
|
|
156
|
+
- `cob-textinput` - Text input fields
|
|
157
|
+
- `cob-textarea` - Multi-line text areas
|
|
158
|
+
- `cob-select` - Dropdown selects
|
|
159
|
+
- `cob-radiogroup` - Radio button groups
|
|
160
|
+
- `cob-checkbox` - Checkboxes
|
|
161
|
+
- `cob-checkboxgroup` - Checkbox groups
|
|
162
|
+
- `cob-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**: COBWDS components automatically set `aria-invalid` and `aria-describedby`
|
|
169
|
+
4. **Clear error messages**: Use specific, actionable error text
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# COBWDS 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 @cobwds/components @cobwds/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Load styles
|
|
12
|
+
|
|
13
|
+
Add the COBWDS stylesheet to `angular.json`:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"projects": {
|
|
18
|
+
"your-app": {
|
|
19
|
+
"architect": {
|
|
20
|
+
"build": {
|
|
21
|
+
"options": {
|
|
22
|
+
"styles": [
|
|
23
|
+
"node_modules/@cobwds/styles/dist/cobwds-full.min.css",
|
|
24
|
+
"src/styles.css"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use `cobwds-full.min.css` for new projects (includes reset, typography, and utilities) or `cobwds.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: `<cob-button label="Click me"></cob-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 '@cobwds/cob-button';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<cob-button label="Click me"></cob-button>
|
|
71
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# COBWDS 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 COBWDS 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 @cobwds/components @cobwds/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/@cobwds/styles/dist/cobwds-full.min.css" />
|
|
21
|
+
|
|
22
|
+
<!-- Existing project: CSS variables only -->
|
|
23
|
+
<!-- <link rel="stylesheet" href="node_modules/@cobwds/styles/dist/cobwds.min.css" /> -->
|
|
24
|
+
|
|
25
|
+
<script type="module" src="node_modules/@cobwds/components/dist/cobwds.es.js"></script>
|
|
26
|
+
</head>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage in Razor
|
|
30
|
+
|
|
31
|
+
```razor
|
|
32
|
+
<cob-button label="Click me"></cob-button>
|
|
33
|
+
<cob-alert type="info">This is an informational message.</cob-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
|
+
<cob-button label="Submit" variant="filled"></cob-button>
|
|
42
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# COBWDS 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 @cobwds/components @cobwds/styles
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Add the COBWDS styles and scripts to your theme's `*.libraries.yml`:
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
cobwds:
|
|
17
|
+
css:
|
|
18
|
+
theme:
|
|
19
|
+
# New project: includes reset, typography, and utility classes
|
|
20
|
+
/node_modules/@cobwds/styles/dist/cobwds-full.min.css: { minified: true }
|
|
21
|
+
# Existing project: CSS variables only
|
|
22
|
+
# /node_modules/@cobwds/styles/dist/cobwds.min.css: { minified: true }
|
|
23
|
+
js:
|
|
24
|
+
/node_modules/@cobwds/components/dist/cobwds.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/cobwds
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage in Twig
|
|
35
|
+
|
|
36
|
+
```twig
|
|
37
|
+
<cob-button label="{{ 'Click me'|t }}"></cob-button>
|
|
38
|
+
<cob-alert type="info">{{ 'This is an alert.'|t }}</cob-alert>
|
|
39
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# COBWDS 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 @cobwds/components @cobwds/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Load styles
|
|
12
|
+
|
|
13
|
+
Import the COBWDS 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 '@cobwds/styles/dist/cobwds-full.min.css';
|
|
18
|
+
|
|
19
|
+
// Existing project: CSS variables only (styles components, nothing else)
|
|
20
|
+
// import '@cobwds/styles/dist/cobwds.min.css';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Import components and use them in JSX:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import '@cobwds/cob-button';
|
|
29
|
+
import '@cobwds/cob-alert';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
<cob-button label="Click me"></cob-button>
|
|
35
|
+
<cob-alert type="info">This is an alert.</cob-alert>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Notes on web components in React
|
|
42
|
+
|
|
43
|
+
- String attributes work normally: `<cob-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: `<cob-button disabled={true} />`
|
|
46
|
+
|
|
47
|
+
## Using the stepper in React (multi-page pattern)
|
|
48
|
+
|
|
49
|
+
`cob-stepper` requires careful state management in React. Two state variables are needed:
|
|
50
|
+
|
|
51
|
+
- `currentStep` — the furthest step the user has reached (progress boundary). Maps to the `current` prop on `CobStep`.
|
|
52
|
+
- `viewingStep` — which step's content is currently displayed. Maps to the `selected` prop on `CobStep`.
|
|
53
|
+
|
|
54
|
+
**Always pass both `current` and `selected` explicitly from React state.** Without explicit `selected`, the stepper's internal fallback will override the user's sidebar navigation on every React re-render.
|
|
55
|
+
|
|
56
|
+
**Event listening:** Use `onNysStepClick` on each `CobStep` (not on `CobStepper`). Always call `e.preventDefault()` to suppress `href`-based page navigation.
|
|
57
|
+
|
|
58
|
+
**Do not use `href` for SPA routing.** Omit `href` and handle step changes entirely in React state.
|
|
59
|
+
|
|
60
|
+
**Do not place `<CobStepper>` inside a `<form>` element.**
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { useState } from 'react';
|
|
64
|
+
import { CobStepper, CobStep, CobButton } from '@cobwds/components/react';
|
|
65
|
+
|
|
66
|
+
const STEPS = [
|
|
67
|
+
{ label: 'Personal Info', content: <PersonalInfoForm /> },
|
|
68
|
+
{ label: 'Contact Details', content: <ContactForm /> },
|
|
69
|
+
{ label: 'Review', content: <ReviewForm /> },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
export function MultiStepForm() {
|
|
73
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
74
|
+
const [viewingStep, setViewingStep] = useState(0);
|
|
75
|
+
|
|
76
|
+
function handleContinue() {
|
|
77
|
+
if (viewingStep < STEPS.length - 1) {
|
|
78
|
+
setCurrentStep(viewingStep + 1);
|
|
79
|
+
setViewingStep(viewingStep + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className="cob-grid-row">
|
|
85
|
+
<CobStepper label="Application" className="cob-grid-col-12 cob-desktop:cob-grid-col-3">
|
|
86
|
+
{STEPS.map((step, i) => (
|
|
87
|
+
<CobStep
|
|
88
|
+
key={i}
|
|
89
|
+
label={step.label}
|
|
90
|
+
current={i === currentStep}
|
|
91
|
+
selected={i === viewingStep}
|
|
92
|
+
onNysStepClick={(e) => { e.preventDefault(); setViewingStep(i); }}
|
|
93
|
+
/>
|
|
94
|
+
))}
|
|
95
|
+
<div slot="actions">
|
|
96
|
+
<CobButton label="Save & Exit" variant="outline" fullWidth />
|
|
97
|
+
</div>
|
|
98
|
+
</CobStepper>
|
|
99
|
+
|
|
100
|
+
<main className="cob-grid-col-12 cob-desktop:cob-grid-col-9">
|
|
101
|
+
{STEPS[viewingStep].content}
|
|
102
|
+
<div style={{ display: 'flex', gap: '8px', marginTop: '16px' }}>
|
|
103
|
+
{viewingStep > 0 && (
|
|
104
|
+
<CobButton label="Back" variant="outline"
|
|
105
|
+
onNysClick={() => setViewingStep((v) => v - 1)} />
|
|
106
|
+
)}
|
|
107
|
+
{viewingStep === currentStep && currentStep < STEPS.length - 1 && (
|
|
108
|
+
<CobButton label="Continue" onNysClick={handleContinue} />
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
</main>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# COBWDS with Vanilla JavaScript
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @cobwds/components @cobwds/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/@cobwds/styles/dist/cobwds-full.min.css" />
|
|
16
|
+
|
|
17
|
+
<!-- Existing project: CSS variables only (styles components, nothing else) -->
|
|
18
|
+
<link rel="stylesheet" href="node_modules/@cobwds/styles/dist/cobwds.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/@cobwds/styles/dist/cobwds-full.min.css" />
|
|
28
|
+
<script type="module">
|
|
29
|
+
import '@cobwds/components';
|
|
30
|
+
</script>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<cob-button label="Click me"></cob-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 '@cobwds/cob-button';
|
|
43
|
+
import '@cobwds/cob-alert';
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# COBWDS Installation Guide
|
|
2
|
+
|
|
3
|
+
## 1. Install the component package
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @cobwds/components
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 2. Load the styles
|
|
10
|
+
|
|
11
|
+
COBWDS components require CSS variables to render correctly. Choose the right stylesheet based on your project:
|
|
12
|
+
|
|
13
|
+
### New project (recommended)
|
|
14
|
+
|
|
15
|
+
Use `cobwds-full.min.css` — includes a CSS reset, typography styles, and utility/layout classes:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<link rel="stylesheet" href="/path/to/cobwds-full.min.css" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Existing project
|
|
22
|
+
|
|
23
|
+
If you already have a CSS reset and typography, use `cobwds.min.css` — loads only the CSS variables that style the components:
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<link rel="stylesheet" href="/path/to/cobwds.min.css" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Via npm
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @cobwds/styles
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
/* New project — full bundle with reset, typography, and utilities */
|
|
37
|
+
@import '@cobwds/styles/full';
|
|
38
|
+
|
|
39
|
+
/* Existing project — CSS variables only */
|
|
40
|
+
@import '@cobwds/styles';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 3. Import and use components
|
|
44
|
+
|
|
45
|
+
Import components individually:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import '@cobwds/cob-button';
|
|
49
|
+
import '@cobwds/cob-alert';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or import all components:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
import '@cobwds/components';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Then use them in HTML:
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<cob-button label="Click me" variant="filled"></cob-button>
|
|
62
|
+
<cob-alert type="info">This is an informational message.</cob-alert>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Style bundles reference
|
|
66
|
+
|
|
67
|
+
| File | Reset | Typography | Utilities | CSS Variables |
|
|
68
|
+
|------|-------|------------|-----------|---------------|
|
|
69
|
+
| `cobwds-full.min.css` | Yes | Yes | Yes | Yes |
|
|
70
|
+
| `cobwds-typography.min.css` | No | Yes | No | Yes |
|
|
71
|
+
| `cobwds.min.css` | No | No | No | Yes |
|
|
72
|
+
|
|
73
|
+
Use the `get_tokens` tool to explore available design tokens, or `get_utility_classes` for layout and spacing utilities.
|