@trimble-oss/moduswebcomponents-mcp 1.0.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 (108) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +337 -0
  3. package/package.json +39 -0
  4. package/versions/1.0.0/component-docs/_all_components.json +56 -0
  5. package/versions/1.0.0/component-docs/modus-wc-autocomplete.json +415 -0
  6. package/versions/1.0.0/component-docs/modus-wc-date.json +227 -0
  7. package/versions/1.0.0/component-docs/modus-wc-dropdown-menu.json +164 -0
  8. package/versions/1.0.0/component-docs/modus-wc-logo.json +61 -0
  9. package/versions/1.0.0/component-docs/modus-wc-menu-item.json +165 -0
  10. package/versions/1.0.0/component-docs/modus-wc-menu.json +106 -0
  11. package/versions/1.0.0/component-docs/modus-wc-navbar.json +290 -0
  12. package/versions/1.0.0/component-docs/modus-wc-profile-menu.json +64 -0
  13. package/versions/1.0.0/component-docs/modus-wc-side-navigation.json +102 -0
  14. package/versions/1.0.0/component-docs/modus-wc-table.json +202 -0
  15. package/versions/1.0.0/component-docs/modus-wc-tooltip.json +94 -0
  16. package/versions/1.0.0/component-docs/modus-wc-typography.json +78 -0
  17. package/versions/1.0.0/docs/_all_docs.json +15 -0
  18. package/versions/1.0.0/docs/angular.mdx +374 -0
  19. package/versions/1.0.0/docs/getting-started.mdx +131 -0
  20. package/versions/1.0.7/component-docs/_all_components.json +55 -0
  21. package/versions/1.0.7/component-docs/modus-wc-autocomplete.json +405 -0
  22. package/versions/1.0.7/component-docs/modus-wc-table.json +202 -0
  23. package/versions/1.0.7/component-docs/modus-wc-tooltip.json +94 -0
  24. package/versions/1.0.7/docs/_all_docs.json +15 -0
  25. package/versions/1.0.7/docs/angular.mdx +374 -0
  26. package/versions/1.1.0/component-docs/_all_components.json +56 -0
  27. package/versions/1.1.0/component-docs/modus-wc-autocomplete.json +405 -0
  28. package/versions/1.1.0/component-docs/modus-wc-navbar.json +290 -0
  29. package/versions/1.1.0/component-docs/modus-wc-profile-menu.json +64 -0
  30. package/versions/1.1.0/component-docs/modus-wc-side-navigation.json +102 -0
  31. package/versions/1.1.0/component-docs/modus-wc-table.json +202 -0
  32. package/versions/1.1.0/component-docs/modus-wc-tooltip.json +94 -0
  33. package/versions/1.1.0/component-docs/modus-wc-typography.json +78 -0
  34. package/versions/1.1.0/docs/_all_docs.json +15 -0
  35. package/versions/1.1.0/docs/angular.mdx +374 -0
  36. package/versions/1.1.0/docs/getting-started.mdx +131 -0
  37. package/versions/1.1.1/component-docs/_all_components.json +56 -0
  38. package/versions/1.1.1/component-docs/modus-wc-autocomplete.json +405 -0
  39. package/versions/1.1.1/component-docs/modus-wc-navbar.json +290 -0
  40. package/versions/1.1.1/component-docs/modus-wc-profile-menu.json +64 -0
  41. package/versions/1.1.1/component-docs/modus-wc-side-navigation.json +102 -0
  42. package/versions/1.1.1/component-docs/modus-wc-table.json +202 -0
  43. package/versions/1.1.1/component-docs/modus-wc-tooltip.json +94 -0
  44. package/versions/1.1.1/component-docs/modus-wc-typography.json +78 -0
  45. package/versions/1.1.1/docs/_all_docs.json +15 -0
  46. package/versions/1.1.1/docs/angular.mdx +374 -0
  47. package/versions/1.1.1/docs/getting-started.mdx +131 -0
  48. package/versions/base/component-docs/_all_components.json +55 -0
  49. package/versions/base/component-docs/modus-wc-accordion.json +48 -0
  50. package/versions/base/component-docs/modus-wc-alert.json +112 -0
  51. package/versions/base/component-docs/modus-wc-autocomplete.json +397 -0
  52. package/versions/base/component-docs/modus-wc-avatar.json +83 -0
  53. package/versions/base/component-docs/modus-wc-badge.json +68 -0
  54. package/versions/base/component-docs/modus-wc-breadcrumbs.json +63 -0
  55. package/versions/base/component-docs/modus-wc-button-group.json +100 -0
  56. package/versions/base/component-docs/modus-wc-button.json +130 -0
  57. package/versions/base/component-docs/modus-wc-card.json +98 -0
  58. package/versions/base/component-docs/modus-wc-checkbox.json +149 -0
  59. package/versions/base/component-docs/modus-wc-chip.json +132 -0
  60. package/versions/base/component-docs/modus-wc-collapse.json +90 -0
  61. package/versions/base/component-docs/modus-wc-date.json +227 -0
  62. package/versions/base/component-docs/modus-wc-divider.json +85 -0
  63. package/versions/base/component-docs/modus-wc-dropdown-menu.json +154 -0
  64. package/versions/base/component-docs/modus-wc-file-dropzone.json +155 -0
  65. package/versions/base/component-docs/modus-wc-handle.json +135 -0
  66. package/versions/base/component-docs/modus-wc-icon.json +722 -0
  67. package/versions/base/component-docs/modus-wc-input-feedback.json +71 -0
  68. package/versions/base/component-docs/modus-wc-input-label.json +84 -0
  69. package/versions/base/component-docs/modus-wc-loader.json +65 -0
  70. package/versions/base/component-docs/modus-wc-logo.json +61 -0
  71. package/versions/base/component-docs/modus-wc-menu-item.json +173 -0
  72. package/versions/base/component-docs/modus-wc-menu.json +86 -0
  73. package/versions/base/component-docs/modus-wc-modal.json +108 -0
  74. package/versions/base/component-docs/modus-wc-navbar.json +280 -0
  75. package/versions/base/component-docs/modus-wc-number-input.json +219 -0
  76. package/versions/base/component-docs/modus-wc-pagination.json +103 -0
  77. package/versions/base/component-docs/modus-wc-panel.json +76 -0
  78. package/versions/base/component-docs/modus-wc-progress.json +86 -0
  79. package/versions/base/component-docs/modus-wc-radio.json +139 -0
  80. package/versions/base/component-docs/modus-wc-rating.json +117 -0
  81. package/versions/base/component-docs/modus-wc-select.json +159 -0
  82. package/versions/base/component-docs/modus-wc-side-navigation.json +102 -0
  83. package/versions/base/component-docs/modus-wc-skeleton.json +65 -0
  84. package/versions/base/component-docs/modus-wc-slider.json +163 -0
  85. package/versions/base/component-docs/modus-wc-stepper.json +47 -0
  86. package/versions/base/component-docs/modus-wc-switch.json +149 -0
  87. package/versions/base/component-docs/modus-wc-table.json +202 -0
  88. package/versions/base/component-docs/modus-wc-tabs.json +86 -0
  89. package/versions/base/component-docs/modus-wc-text-input.json +278 -0
  90. package/versions/base/component-docs/modus-wc-textarea.json +215 -0
  91. package/versions/base/component-docs/modus-wc-theme-switcher.json +49 -0
  92. package/versions/base/component-docs/modus-wc-time-input.json +211 -0
  93. package/versions/base/component-docs/modus-wc-toast.json +56 -0
  94. package/versions/base/component-docs/modus-wc-toolbar.json +44 -0
  95. package/versions/base/component-docs/modus-wc-tooltip.json +94 -0
  96. package/versions/base/component-docs/modus-wc-typography.json +73 -0
  97. package/versions/base/component-docs/modus-wc-utility-panel.json +86 -0
  98. package/versions/base/docs/_all_docs.json +15 -0
  99. package/versions/base/docs/accessibility.mdx +32 -0
  100. package/versions/base/docs/angular.mdx +346 -0
  101. package/versions/base/docs/form-inputs.mdx +86 -0
  102. package/versions/base/docs/getting-started.mdx +91 -0
  103. package/versions/base/docs/modus-figma-mcp-integration-guide.mdx +254 -0
  104. package/versions/base/docs/modus-icon-usage.mdx +210 -0
  105. package/versions/base/docs/react.mdx +129 -0
  106. package/versions/base/docs/styling.mdx +107 -0
  107. package/versions/base/docs/testing.mdx +18 -0
  108. package/versions/base/docs/vue.mdx +159 -0
@@ -0,0 +1,254 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="Documentation/Modus Figma MCP Integration Guide" />
4
+
5
+ # Modus Figma MCP Integration Guide
6
+
7
+ ### Important Note
8
+
9
+ **Designer Collaboration is Critical**: The accuracy and effectiveness of this tool heavily depends on proper design setup in Figma. For optimal results, use the **Modus 2.0 component library** available in Figma rather than creating custom elements. While custom themes can still be applied, using the Modus 2.0 design system significantly improves component detection and mapping accuracy.
10
+
11
+ ## Overview
12
+
13
+ This guide explains how to use the Modus Figma tools to convert Figma designs into Modus Web Components.
14
+
15
+ 1. [Workflow Setup](#workflow-setup)
16
+ - [MCP Server Configuration](#mcp-server-configuration)
17
+ - [JSON Configuration for MCP Setup](#json-configuration-for-mcp-setup)
18
+ - [Authentication Setup](#authentication-setup)
19
+ 2. [Available MCP Tools](#available-mcp-tools)
20
+ - [1. analyze_figma](#1-analyze_figma)
21
+ - [2. get_modus_component_data](#2-get_modus_component_data)
22
+ 3. [Implementation Workflows](#implementation-workflows)
23
+ - [Workflow 1: Complete Page Analysis](#workflow-1-complete-page-analysis)
24
+ - [Workflow 2: Component-Specific Analysis](#workflow-2-component-specific-analysis)
25
+ 4. [Using the Specification File](#using-the-specification-file)
26
+
27
+ ## Workflow Setup
28
+
29
+ ### MCP Server Configuration
30
+
31
+ The MCP server is accessible at:
32
+
33
+ ```
34
+ https://flows-webhook.stage.trimble-ai.com/mcp/agentic/n8n-server/v1/modus
35
+ ```
36
+
37
+ ### JSON Configuration for MCP Setup
38
+
39
+ Add the following JSON code to your AI environment's MCP configuration file (e.g., mcp.json in Cursor/VS Code) for access:
40
+
41
+ ```json
42
+ "modus_n8n_webhook": {
43
+ "command": "npx",
44
+ "args": [
45
+ "mcp-remote",
46
+ "https://flows-webhook.stage.trimble-ai.com/mcp/agentic/n8n-server/v1/modus",
47
+ "--header",
48
+ "Authorization: Bearer ${AUTH_TOKEN}"
49
+ ],
50
+ "env": {
51
+ "AUTH_TOKEN": ""
52
+ }
53
+ }
54
+ ```
55
+
56
+ ### Authentication Setup
57
+
58
+ To access the MCP webhook, you need to create a Trimble Cloud application and generate an access token:
59
+
60
+ 1. **Subscribe to or Create an Application**: Follow the steps in the [Webhook Access Documentation](https://docs.trimblecloud.com/agentic-ai-platform/prototyping/how-tos/webhook-access/) to subscribe to an existing application or create a new one.
61
+
62
+ 2. **Generate Access Token**: Use the client ID and client secret from your application to generate an access token by following the [Access Token Generation Guide](https://docs.trimblecloud.com/profiles/docs/content/how-to-guides/prof-qstart-get-access-token/).
63
+
64
+ 3. **Configure Environment**: Use the generated access token as your AUTH_TOKEN in the MCP configuration:
65
+ ```
66
+ AUTH_TOKEN=your_generated_access_token_here
67
+ ```
68
+
69
+ ## Available MCP Tools
70
+
71
+ ### 1. analyze_figma
72
+
73
+ **Purpose**: Enhanced Figma page analysis with advanced layout reconstruction and component mapping.
74
+
75
+ **Parameters**:
76
+
77
+ - `figma_url` (required): The Figma file URL
78
+ - `node_id` (optional): Specific node ID to analyze, defaults to entire page
79
+
80
+ **Returns** (example response structure):
81
+
82
+ ```json
83
+ {
84
+ "success": true,
85
+ "file_key": "figma-file-key",
86
+ "node_id": "2100:41706",
87
+ "page_summary": {
88
+ "name": "Dashboard",
89
+ "layout_type": "dashboard",
90
+ "component_count": 156,
91
+ "has_navigation": true,
92
+ "has_sidebar": true,
93
+ "has_table": true,
94
+ "has_form": true,
95
+ "complexity": "high"
96
+ },
97
+ "key_components": [
98
+ {
99
+ "figma_name": "Navbar",
100
+ "figma_id": "I2100:41706;1:27669",
101
+ "modus_component": "modus-wc-navbar",
102
+ "component_type": "navbar",
103
+ "confidence": 0.95,
104
+ "detection_method": "pattern_match",
105
+ "properties": {},
106
+ "pattern": "navigation"
107
+ }
108
+ ],
109
+ "component_summary": {
110
+ "modus-wc-navbar": 2,
111
+ "modus-wc-button": 15,
112
+ "modus-wc-table": 1
113
+ },
114
+ "undetected_components": {
115
+ "count": 12,
116
+ "examples": [
117
+ {
118
+ "figma_name": "Custom Header",
119
+ "figma_id": "2100:123",
120
+ "reason": "Layout container"
121
+ }
122
+ ]
123
+ },
124
+ "implementation": {
125
+ "required_imports": ["ModusNavbar", "ModusButton", "ModusTable"],
126
+ "layout_approach": "dashboard",
127
+ "implementation_notes": [
128
+ "This is a dashboard layout with navigation",
129
+ "Include form validation for input elements",
130
+ "Consider lazy loading for complex components"
131
+ ]
132
+ },
133
+ "analysis_metadata": {
134
+ "detection_rate": "89.2%",
135
+ "total_mappings_available": 98,
136
+ "pipeline_nodes": 5
137
+ }
138
+ }
139
+ ```
140
+
141
+ ### 2. get_modus_component_data
142
+
143
+ **Purpose**: Retrieves comprehensive documentation for Modus Web Components.
144
+
145
+ **Parameters**:
146
+
147
+ - `component_name` (required): The Modus component name (e.g., 'modus-wc-table')
148
+
149
+ **Returns** (example response structure):
150
+
151
+ ```json
152
+ {
153
+ "success": true,
154
+ "component_documentation": {
155
+ "name": "modus-wc-table",
156
+ "properties": [
157
+ {
158
+ "name": "columns",
159
+ "type": "ModusTableColumn[]",
160
+ "required": true,
161
+ "description": "Array of column definitions"
162
+ }
163
+ ],
164
+ "events": [
165
+ {
166
+ "name": "cellClick",
167
+ "type": "CustomEvent<ModusTableCellClickEventDetails>",
168
+ "description": "Fires when a cell is clicked"
169
+ }
170
+ ],
171
+ "methods": [
172
+ {
173
+ "name": "sort",
174
+ "signature": "sort(columnId: string, direction: 'asc' | 'desc') => Promise<void>",
175
+ "description": "Sorts the table by specified column"
176
+ }
177
+ ],
178
+ "slots": [
179
+ {
180
+ "name": "default",
181
+ "description": "The table content"
182
+ }
183
+ ]
184
+ }
185
+ }
186
+ ```
187
+
188
+ ## Implementation Workflows
189
+
190
+ ### Workflow 1: Complete Page Analysis
191
+
192
+ **Purpose**: Analyze an entire Figma page and get comprehensive component mapping.
193
+
194
+ **Input**:
195
+
196
+ ```json
197
+ {
198
+ "figma_url": "https://www.figma.com/design/abc123/MyDesign?node-id=1-2",
199
+ "analyze_children": true
200
+ }
201
+ ```
202
+
203
+ **Steps**:
204
+
205
+ 1. **Initial Analysis**: Call analyze_figma with full page URL
206
+ 2. **Component Documentation**: For each unique component type found, call get_modus_component_data
207
+ 3. **Deep Dive Analysis**: For complex components, call analyze_figma with specific node IDs
208
+ 4. **Result Compilation**: Combine all analysis data into implementation guide
209
+
210
+ ### Workflow 2: Component-Specific Analysis
211
+
212
+ **Purpose**: Deep dive into a specific component or section.
213
+
214
+ **Input**:
215
+
216
+ ```json
217
+ {
218
+ "figma_url": "https://www.figma.com/design/abc123/MyDesign",
219
+ "node_id": "2100:41706"
220
+ }
221
+ ```
222
+
223
+ **Steps**:
224
+
225
+ 1. **Targeted Analysis**: Call analyze_figma with specific node ID
226
+ 2. **Component Mapping**: Extract component types from analysis
227
+ 3. **Documentation Fetch**: Call get_modus_component_data for each component
228
+ 4. **Implementation Guide**: Generate specific implementation instructions
229
+
230
+ ## Using the Specification File
231
+
232
+ To implement automated Figma-to-code conversion using these tools, attach the specification file to your AI conversation. This spec file contains detailed instructions for the AI on how to analyze Figma designs and generate Modus Web Components code.
233
+
234
+ **How to use the spec file:**
235
+
236
+ 1. **Download the specification**: Get the [FIGMA_CODE_SPEC](https://docs.google.com/document/d/1OII7Yc0k2TIAtrUxYsYwPXtXNaO62wb2tU4-jYDnSnI/edit?tab=t.6m9dyidc3or1) file
237
+ 2. **Attach to your AI conversation**: Include the spec file when starting a new Figma analysis task
238
+ 3. **Provide your Figma URL**: Give the AI your Figma design URL
239
+ 4. **Follow the automated workflow**: The AI will use the spec file instructions to systematically analyze your design and generate implementation code
240
+
241
+ **Example prompt:**
242
+
243
+ ```
244
+ I want to convert my Figma design into Modus Web Components code.
245
+
246
+ Figma URL: https://www.figma.com/design/your-figma-url-here
247
+ Figma API Token: your-figma-api-token-here
248
+
249
+ Please follow the attached specification file to analyze this design and generate the corresponding code with proper Modus components.
250
+ ```
251
+
252
+ **Note**: You'll need to provide your Figma API token for the tools to access your Figma designs. You can generate a Figma API token from your Figma account settings.
253
+
254
+ The AI will then use the Modus Figma tools through the specification's step-by-step process to deliver accurate, implementation-ready code.
@@ -0,0 +1,210 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="Documentation/Modus Icon Usage" />
4
+
5
+ # Modus Icon Usage
6
+
7
+ Modus Web Components require Modus Icons.
8
+
9
+ Starting from v0.0.0-beta.5, the Web Components package supports both outlined and solid icon variants through a single CSS file.
10
+
11
+ ## 1. Installation
12
+
13
+ ### Option A: Online Usage (CDN)
14
+
15
+ Create a file at:
16
+
17
+ ```
18
+ /public/modus-web-components/modus-icons.css
19
+ ```
20
+
21
+ with the following contents:
22
+
23
+ ```css
24
+ @font-face {
25
+ font-family: 'modus-icons';
26
+ src: url('https://cdn.jsdelivr.net/npm/@trimble-oss/modus-icons@1/dist/modus-outlined/fonts/modus-icons.woff2')
27
+ format('woff2');
28
+ font-style: normal;
29
+ font-weight: normal;
30
+ font-display: swap;
31
+ }
32
+
33
+ @font-face {
34
+ font-family: 'modus-icons-outlined';
35
+ src: url('https://cdn.jsdelivr.net/npm/@trimble-oss/modus-icons@1/dist/modus-outlined/fonts/modus-icons.woff2')
36
+ format('woff2');
37
+ font-style: normal;
38
+ font-weight: normal;
39
+ font-display: swap;
40
+ }
41
+
42
+ @font-face {
43
+ font-family: 'modus-icons-solid';
44
+ src: url('https://cdn.jsdelivr.net/npm/@trimble-oss/modus-icons@1/dist/modus-solid/fonts/modus-icons.woff2')
45
+ format('woff2');
46
+ font-style: normal;
47
+ font-weight: normal;
48
+ font-display: swap;
49
+ }
50
+
51
+ .modus-icons-outlined {
52
+ font-family: 'modus-icons-outlined';
53
+ font-style: normal;
54
+ font-weight: normal;
55
+ }
56
+
57
+ .modus-icons-solid {
58
+ font-family: 'modus-icons-solid';
59
+ font-style: normal;
60
+ font-weight: normal;
61
+ }
62
+
63
+ .modus-icons {
64
+ font-family: 'modus-icons';
65
+ font-style: normal;
66
+ font-weight: normal;
67
+ }
68
+ ```
69
+
70
+ Then include it in your app:
71
+
72
+ ```html
73
+ <head>
74
+ <link rel="stylesheet" href="/modus-web-components/modus-icons.css" />
75
+ </head>
76
+ ```
77
+
78
+ ### Option B: Offline Usage
79
+
80
+ For applications requiring offline capability, follow these steps:
81
+
82
+ 1. Install the Modus Icons package:
83
+
84
+ ```bash
85
+ npm install @trimble-oss/modus-icons
86
+ ```
87
+
88
+ 2. Download the font files:
89
+
90
+ ```
91
+ node_modules/@trimble-oss/modus-icons/dist/modus-outlined/fonts/modus-icons.woff2
92
+ node_modules/@trimble-oss/modus-icons/dist/modus-solid/fonts/modus-icons.woff2
93
+ ```
94
+
95
+ 3. Create this directory structure in your project:
96
+
97
+ ```
98
+ public/
99
+ └── modus-web-components/
100
+ ├── fonts/
101
+ │ ├── modus-icons-outlined.woff2 (renamed from modus-outlined/fonts/modus-icons.woff2)
102
+ │ └── modus-icons-solid.woff2 (renamed from modus-solid/fonts/modus-icons.woff2)
103
+ └── modus-icons.css
104
+ ```
105
+
106
+ 4. Create a modified `modus-icons.css` file that references the local font files:
107
+
108
+ ```css
109
+ @font-face {
110
+ font-family: 'modus-icons';
111
+ src: url('./fonts/modus-icons-outlined.woff2') format('woff2');
112
+ font-style: normal;
113
+ font-weight: normal;
114
+ font-display: swap;
115
+ }
116
+
117
+ @font-face {
118
+ font-family: 'modus-icons-outlined';
119
+ src: url('./fonts/modus-icons-outlined.woff2') format('woff2');
120
+ font-style: normal;
121
+ font-weight: normal;
122
+ font-display: swap;
123
+ }
124
+
125
+ @font-face {
126
+ font-family: 'modus-icons-solid';
127
+ src: url('./fonts/modus-icons-solid.woff2') format('woff2');
128
+ font-style: normal;
129
+ font-weight: normal;
130
+ font-display: swap;
131
+ }
132
+
133
+ .modus-icons-outlined {
134
+ font-family: 'modus-icons-outlined';
135
+ font-style: normal;
136
+ font-weight: normal;
137
+ }
138
+
139
+ .modus-icons-solid {
140
+ font-family: 'modus-icons-solid';
141
+ font-style: normal;
142
+ font-weight: normal;
143
+ }
144
+
145
+ .modus-icons {
146
+ font-family: 'modus-icons';
147
+ font-style: normal;
148
+ font-weight: normal;
149
+ }
150
+ ```
151
+
152
+ 5. Include the CSS file in your HTML just as in the online version:
153
+
154
+ ```html
155
+ <head>
156
+ <link rel="stylesheet" href="/modus-web-components/modus-icons.css" />
157
+ </head>
158
+ ```
159
+
160
+ ## 2. Usage in Components
161
+
162
+ Once the stylesheet is loaded, you can use icons in any framework:
163
+
164
+ ### Web Components
165
+
166
+ ```html
167
+ <!-- Outlined icon (default) -->
168
+ <modus-wc-icon name="alert" variant="outlined"></modus-wc-icon>
169
+
170
+ <!-- Solid icon -->
171
+ <modus-wc-icon name="alert" variant="solid"></modus-wc-icon>
172
+ ```
173
+
174
+ ### React
175
+
176
+ ```tsx
177
+ import { ModusWcIcon } from '@trimble-oss/moduswebcomponents-react';
178
+
179
+ export function IconExamples() {
180
+ return (
181
+ <div>
182
+ {/* Outlined */}
183
+ <ModusWcIcon name="alert" variant="outlined" />
184
+
185
+ {/* Solid */}
186
+ <ModusWcIcon name="alert" variant="solid" />
187
+
188
+ {/* Accessible icon */}
189
+ <ModusWcIcon
190
+ name="accessibility_circle"
191
+ variant="solid"
192
+ decorative={false}
193
+ aria-label="Accessibility features"
194
+ />
195
+
196
+ {/* Custom styling */}
197
+ <ModusWcIcon
198
+ name="add_bold"
199
+ variant="outlined"
200
+ decorative
201
+ style={{ color: 'var(--modus-wc-color-trimble-blue)' }}
202
+ />
203
+ </div>
204
+ );
205
+ }
206
+ ```
207
+
208
+ ### Angular, Vue, etc.
209
+
210
+ Follow the same approach — just make sure to include the global CSS file once in your application.
@@ -0,0 +1,129 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="Documentation/Frameworks/React" />
4
+
5
+ # React Framework Integration
6
+
7
+ This guide will help you get started with consuming the Modus React Web Component library in your React project.
8
+
9
+ We highly recommend using the Modus React Components library for React based projects.
10
+ These components are automatically generated using the Stencil React Framework Integration.
11
+
12
+ Follow the steps outlined below to integrate and use Modus React Web Components effectively.
13
+
14
+ Please refer to the [official stencil documentation](https://stenciljs.com/docs/react#consumer-usage) for more information on how to integrate with your React project.
15
+
16
+ ## Usage
17
+
18
+ Modus React Components have a peer dependency with Modus Web Components and require the
19
+ installation of both packages.
20
+
21
+ ### 1. Install `modus-wc-react`:
22
+
23
+ Ensure that you specify the target version of React for the `modus-wc-react` package (e.g., `react18` for React 18).
24
+
25
+ <b>
26
+ Lock the installed package versions to avoid unintended breakages on future
27
+ npm installs.
28
+ </b>
29
+
30
+ ```bash
31
+ npm install @trimble-oss/moduswebcomponents-react@<latest-version>-react<target-version>
32
+ # e.g.,
33
+ npm install @trimble-oss/moduswebcomponents-react@1.0.0-react18
34
+ ```
35
+
36
+ ### 2. Set up the styling:
37
+
38
+ You will need to import our styling in your main JavaScript or CSS file:
39
+
40
+ ```js
41
+ import '@trimble-oss/moduswebcomponents/modus-wc-styles.css';
42
+ ```
43
+
44
+ ### 3. Use the component library as normal.
45
+
46
+ ```tsx
47
+ import { ModusWcBadge } from '@trimble-oss/moduswebcomponents-react';
48
+
49
+ <ModusWcBadge aria-label="Badge" content="Words" />;
50
+ ```
51
+
52
+ ### Using the Controlled Input Pattern
53
+
54
+ The controlled input pattern involves maintaining the state of the input's value within the React application or
55
+ component. The [React Docs](https://react.dev/reference/react-dom/components/input#controlling-an-input-with-a-state-variable)
56
+ describe this in more detail.
57
+
58
+ ```tsx
59
+ import React, { useState } from 'react';
60
+ import { ModusWcTextInput } from '@trimble-oss/moduswebcomponents-react';
61
+
62
+ interface Props extends React.ComponentProps<typeof ModusWcTextInput> {}
63
+
64
+ const MyComponent: React.FC<Props> = (props) => {
65
+ const [value, setValue] = useState('');
66
+
67
+ const handleInputChange = (
68
+ e: CustomEvent<HTMLModusWcTextInputElementEventMap['inputChange']>
69
+ ) => {
70
+ const value = e.detail.target.value;
71
+ setValue(value);
72
+ };
73
+
74
+ return (
75
+ <ModusWcTextInput
76
+ {...props}
77
+ onInputChange={handleInputChange}
78
+ value={value}
79
+ />
80
+ );
81
+ };
82
+
83
+ export default MyComponent;
84
+ ```
85
+
86
+ ### Wrapping Components
87
+
88
+ When using Modus React Components directly, it is recommended to wrap it in corresponding React components within your application.
89
+ This will abstract away from the library dependency, allowing more flexibility for you and your application in the future.
90
+
91
+ Wrapped Modus component example:
92
+
93
+ ```tsx
94
+ import React from 'react';
95
+ import { ModusWcAvatar } from '@trimble-oss/moduswebcomponents-react';
96
+
97
+ interface Props extends React.ComponentProps<typeof ModusWcAvatar> {}
98
+
99
+ const Avatar: React.FC<Props> = (props) => {
100
+ return <ModusWcAvatar {...props} />;
101
+ };
102
+
103
+ export default Avatar;
104
+ ```
105
+
106
+ or, a more complex wrapper:
107
+
108
+ ```tsx
109
+ import React from 'react';
110
+ import { ModusWcTextInput } from '@trimble-oss/moduswebcomponents-react';
111
+
112
+ interface Props
113
+ extends Omit<React.ComponentProps<typeof ModusWcTextInput>, 'inputChange'> {
114
+ onValueChange: (value: string) => void;
115
+ }
116
+
117
+ const TextInput: React.FC<Props> = (props) => {
118
+ const handleInputChange = (
119
+ e: CustomEvent<HTMLModusWcTextInputElementEventMap['inputChange']>
120
+ ) => {
121
+ const value = e.detail.target.value;
122
+ props.onValueChange(value);
123
+ };
124
+
125
+ return <ModusWcTextInput {...props} onInputChange={handleInputChange} />;
126
+ };
127
+
128
+ export default TextInput;
129
+ ```
@@ -0,0 +1,107 @@
1
+ import { Meta } from '@storybook/blocks';
2
+
3
+ <Meta title="Documentation/Styling" />
4
+
5
+ # Styling
6
+
7
+ ## Custom Styling
8
+
9
+ The Modus Web Components library provides several ways to customize the appearance of components.
10
+
11
+ ### 1. Use a Theme
12
+
13
+ Our components ship preloaded with several themes. A list of themes can be found
14
+ [here](https://github.com/trimble-oss/modus-wc-2.0/blob/main/tailwind.config.ts)
15
+ within the `daisyui.themes` array. Themes can be applied in multiple ways.
16
+
17
+ #### a. Using the `ThemeSwitcher` component:
18
+
19
+ The Theme Switcher will automatically handle theme switching through our theme store. Theme
20
+ values are stored in local storage using the key `modus-theme-config`.
21
+
22
+ ```html
23
+ <modus-wc-theme-provider initial-theme='{ "theme": "modus-modern-light" }'>
24
+ <modus-wc-theme-switcher aria-label="Toggle theme" />
25
+ </modus-wc-theme-provider>
26
+ ```
27
+
28
+ #### b. Manually applying the following HTML:
29
+
30
+ ```html
31
+ <!-- Light theme -->
32
+ <html class="light" data-theme="modus-modern-light" data-mode="light">
33
+ ...
34
+ </html>
35
+
36
+ <!-- Dark theme -->
37
+ <html class="dark" data-theme="modus-modern-dark" data-mode="dark">
38
+ ...
39
+ </html>
40
+ ```
41
+
42
+ ### 2. Override CSS Custom Properties
43
+
44
+ Our components use CSS custom properties for styling. You can override these globally or at the component level.
45
+
46
+ A full list of overridable CSS custom properties can be found
47
+ [here](https://github.com/trimble-oss/modus-wc-2.0/blob/main/src/styles/variables.scss).
48
+
49
+ ```css
50
+ :root {
51
+ --modus-wc-primary-color: purple;
52
+ --modus-wc-color-info: green;
53
+ --modus-wc-font-weight-normal: 500;
54
+ }
55
+ ```
56
+
57
+ ```css
58
+ .modus-wc-btn {
59
+ --modus-wc-border-radius-md: 20px;
60
+ }
61
+ ```
62
+
63
+ ### 3. Use Custom CSS Classes
64
+
65
+ Many components accept a `custom-class` attribute for additional styling:
66
+
67
+ ```html
68
+ <modus-wc-button
69
+ label="Custom Button"
70
+ custom-class="my-custom-button"
71
+ ></modus-wc-button>
72
+ ```
73
+
74
+ ```css
75
+ .my-custom-button {
76
+ background-color: purple;
77
+ border-color: purple;
78
+ }
79
+ ```
80
+
81
+ ### 4. Apply Direct CSS Overrides
82
+
83
+ Since Shadow DOM is disabled, you can directly target component classes.
84
+
85
+ Our component classes are all prefixed with `modus-wc-` to avoid collisions.
86
+
87
+ ```css
88
+ .modus-wc-btn {
89
+ background-color: yellow;
90
+ color: black;
91
+ }
92
+ ```
93
+
94
+ ## CSS Reset (Tailwind Preflight)
95
+
96
+ Tailwind performs a CSS reset (preflight) that normalizes browser styles to ensure all component styles are applied
97
+ consistently across browsers. This reset is automatically loaded into applications consuming the library. We've
98
+ provided Modus-specific overrides in `styles/tailwind.css` to maintain compatibility with our design system, though
99
+ these overrides aren't exhaustive. If you need additional style adjustments, you can either:
100
+
101
+ 1. Add custom CSS overrides in your application
102
+ 2. Create a GitHub issue describing the needed override (contributions welcome)
103
+
104
+ ---
105
+
106
+ Need help? Check out our [GitHub repository](https://github.com/trimble-oss/modus-wc-2.0)
107
+ or [raise an issue](https://github.com/trimble-oss/modus-wc-2.0/issues).