@gsa-tts/graymatter-ui 1.3.0 → 2.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.
package/README.md CHANGED
@@ -1,26 +1,28 @@
1
1
  # @gsa-tts/graymatter-ui
2
2
 
3
- A comprehensive UI component library built with Svelte 5, providing reusable components, layouts, and utilities for modern web applications.
3
+ A UI component library built with Svelte 5, providing reusable components,
4
+ styles, and utilities for the USAi applications.
4
5
 
5
6
  ## Package Responsibilities
6
7
 
7
- The GrayMatter UI package (`@gsa-tts/graymatter-ui`) is a UI component library that provides:
8
+ The GrayMatter UI package (`@gsa-tts/graymatter-ui`) provides:
8
9
 
9
10
  ### Primary Responsibilities:
10
11
 
11
- - **Reusable UI Components** - A comprehensive set of accessible, customizable components
12
+ - **Reusable UI Components** - A set of accessible, customizable Svelte 5 components
12
13
  - **Design System Implementation** - Built using tokens from `@gsa-tts/graymatter-style-tokens`
13
- - **Layout Components** - Consistent page structures and navigation patterns
14
+ - **Shared Styles** - Global and component CSS, plus compiled USWDS assets
14
15
  - **Utility Functions** - Helper functions for UI-related operations
15
- - **Cross-Framework Support** - Components available as both Svelte components and web components
16
16
 
17
17
  ### Package Boundaries:
18
18
 
19
- - **SHOULD** contain UI components, layouts, and styles
19
+ - **SHOULD** contain Svelte UI components, styles, and utilities
20
20
  - **SHOULD** consume design tokens from the style-tokens package
21
- - **SHOULD** be framework-agnostic where possible (via web components)
22
21
  - **SHOULD NOT** contain application-specific business logic
23
22
  - **SHOULD NOT** contain data fetching or API integration code
23
+ - **SHOULD NOT** contain application layouts or framework configuration
24
+ (e.g. Astro layouts / config live in the consuming app — see the `apps/site`
25
+ `src/layouts/`)
24
26
  - **SHOULD NOT** depend on application-specific packages
25
27
 
26
28
  ## Installation
@@ -29,13 +31,12 @@ The GrayMatter UI package (`@gsa-tts/graymatter-ui`) is a UI component library t
29
31
  npm install @gsa-tts/graymatter-ui @gsa-tts/graymatter-style-tokens
30
32
  ```
31
33
 
32
- **Note:** The `@gsa-tts/graymatter-style-tokens` package is required for proper styling and design tokens.
34
+ **Note:** The `@gsa-tts/graymatter-style-tokens` package is required for proper
35
+ styling and design tokens.
33
36
 
34
37
  ## Usage
35
38
 
36
- The UI package can be used in two ways:
37
-
38
- ### 1. Svelte Components (for Svelte/Astro applications)
39
+ ### Svelte Components
39
40
 
40
41
  ```svelte
41
42
  <script>
@@ -47,31 +48,30 @@ The UI package can be used in two ways:
47
48
  </DesktopSideNav>
48
49
  ```
49
50
 
50
- ### 2. Utility Functions
51
-
52
- For utility functions like navigation control, use the dedicated `/utils` import path:
53
-
54
- ```javascript
55
- // ✅ Recommended for Svelte-only projects
56
- import { toggleNavigation } from '@gsa-tts/graymatter-ui/utils';
51
+ Individual components can also be imported by path, which is useful for
52
+ server-rendered/island setups such as Astro:
57
53
 
58
- // ❌ Avoid this in Svelte-only projects (may cause build issues)
59
- import { toggleNavigation } from '@gsa-tts/graymatter-ui';
54
+ ```svelte
55
+ <script>
56
+ import Button from '@gsa-tts/graymatter-ui/components/Button.svelte';
57
+ </script>
60
58
  ```
61
59
 
62
- **Note:** The `/utils` path only exports TypeScript files and doesn't pull in Astro components, making it safe for Svelte-only projects that don't have Astro configured in their build system.
60
+ ### Utility Functions
63
61
 
64
- ### 3. Web Components (for any framework or vanilla JS)
62
+ Utility functions are available via the dedicated `/utils` import path:
65
63
 
66
- ```html
67
- <graymatter-desktop-side-nav show-app-icons="true" ssr-selected-item="api">
68
- <!-- Sub navigation content -->
69
- </graymatter-desktop-side-nav>
64
+ ```javascript
65
+ import { toggleNavigation } from '@gsa-tts/graymatter-ui/utils';
70
66
  ```
71
67
 
68
+ **Note:** The `/utils` path only exports plain TypeScript, so it never pulls in
69
+ Svelte components — safe to use from non-Svelte code.
70
+
72
71
  ## Navigation URL Configuration
73
72
 
74
- Navigation components (`DesktopSideNav`, `MobileBottomNav`) support flexible URL configuration via props:
73
+ Navigation components (`DesktopSideNav`, `MobileBottomNav`) support flexible URL
74
+ configuration via props:
75
75
 
76
76
  ### Option 1: Component Props (Recommended)
77
77
  ```svelte
@@ -105,11 +105,13 @@ Navigation components (`DesktopSideNav`, `MobileBottomNav`) support flexible URL
105
105
  </DesktopSideNav>
106
106
  ```
107
107
 
108
- **Fallback Behavior:** When no URL is provided for a navigation item, it will use `#` as the href, preventing navigation and keeping users on the current page.
108
+ **Fallback Behavior:** When no URL is provided for a navigation item, it will use
109
+ `#` as the href, preventing navigation and keeping users on the current page.
109
110
 
110
111
  ### Discover Icon Control
111
112
 
112
- The discover icon can be conditionally shown/hidden using the `hideDiscover` prop for both desktop and mobile navigation:
113
+ The discover icon can be conditionally shown/hidden using the `hideDiscover` prop
114
+ for both desktop and mobile navigation:
113
115
 
114
116
  ```svelte
115
117
  <!-- Hide discover icon (default) -->
@@ -121,25 +123,13 @@ The discover icon can be conditionally shown/hidden using the `hideDiscover` pro
121
123
  <MobileBottomNav showAppIcons={true} hideDiscover={false}>
122
124
  ```
123
125
 
124
- **Note:** The discover icon is hidden by default (`hideDiscover={true}`) since the discover page may not be available in all deployments. This gives you control over when to enable the discover functionality across all consuming applications.
126
+ **Note:** The discover icon is hidden by default (`hideDiscover={true}`) since the
127
+ discover page may not be available in all deployments. This gives you control over
128
+ when to enable the discover functionality across all consuming applications.
125
129
 
126
130
  ## Available Components
127
131
 
128
- ### Web Components (Universal - Any Framework)
129
-
130
- All components with `.webcomponent.svelte` extension are available as web components:
131
-
132
- - `graymatter-desktop-side-nav` - Desktop sidebar navigation
133
- - `graymatter-mobile-top-nav` - Mobile header navigation
134
- - `graymatter-mobile-bottom-nav` - Mobile bottom navigation bar
135
- - `graymatter-mobile-side-menu` - Mobile slide-out navigation menu
136
- - `graymatter-desktop-header` - Desktop header component
137
- - `graymatter-button` - Accessible button component
138
- - `graymatter-logo` - Brand logo component
139
-
140
- ### Svelte 5 Components
141
-
142
- Available for Svelte, SvelteKit, and Astro applications:
132
+ Import from `@gsa-tts/graymatter-ui/components` (or the package root):
143
133
 
144
134
  ```javascript
145
135
  import {
@@ -166,18 +156,6 @@ import {
166
156
  } from '@gsa-tts/graymatter-ui/components';
167
157
  ```
168
158
 
169
- ### Astro Components
170
-
171
- Available for Astro applications:
172
-
173
- ```javascript
174
- import {
175
- Head,
176
- BaseLayout,
177
- GlobalAppLayout
178
- } from '@gsa-tts/graymatter-ui/layouts';
179
- ```
180
-
181
159
  ## Component Categories
182
160
 
183
161
  ### Navigation Components
@@ -185,11 +163,7 @@ import {
185
163
  - **MobileTopNav** - Mobile header navigation
186
164
  - **MobileBottomNav** - Mobile bottom navigation bar
187
165
  - **MobileSideMenu** - Mobile slide-out navigation menu
188
-
189
- ### Layout Components
190
- - **GlobalAppLayout** - Main application layout wrapper
191
- - **BaseLayout** - Base page layout structure
192
- - **DocsLayout** - Documentation layout with dynamic navigation (Astro only)
166
+ - **DesktopHeader** - Desktop header component
193
167
 
194
168
  ### UI Components
195
169
  - **ProfileMenu** - User profile dropdown menu with event-driven actions
@@ -200,6 +174,7 @@ import {
200
174
  ### Utility Components
201
175
  - **UsaBanner** - Government banner component
202
176
  - **UsaSkipNav** - Skip navigation link for accessibility
177
+ - **NavigationInitializer** - Initializes navigation state on the client
203
178
 
204
179
  ### Utility Functions
205
180
  Available via the `/utils` import path:
@@ -219,11 +194,17 @@ Many components use custom events for external control and communication:
219
194
  - **DesktopSideNav** - External control via `graymatter-desktop-nav-control` events
220
195
  - **ProfileMenu** - Action handling via `profileMenuAction` events
221
196
 
197
+ Navigation-control events (`graymatter-desktop-nav-control`) are dispatched
198
+ directly on `window` with `bubbles: true`. `ProfileMenu` dispatches
199
+ `profileMenuAction` from its component element with `bubbles: true` and
200
+ `composed: true` (so it crosses Shadow DOM boundaries). Either event can be
201
+ observed on `window`.
202
+
222
203
  ### Cross-App Communication
223
204
  Components support communication between different applications:
224
205
 
225
206
  - **Navigation Control** - Control desktop navigation from external apps
226
- - **Event Bubbling** - Events work across Shadow DOM boundaries
207
+ - **Custom Events** - Decoupled action handling without prop drilling
227
208
 
228
209
  ### Accessibility
229
210
  - **WCAG 2.1 AA Compliant** - Built with accessibility in mind
@@ -237,40 +218,27 @@ Detailed documentation for specific components is available in the package:
237
218
  - **[NAVIGATION_CONTROL.md](https://github.com/GSA-TTS/usai-gov/blob/main/packages/ui/NAVIGATION_CONTROL.md)** - DesktopSideNav external control system with event-based API
238
219
  - **[PROFILE_MENU.md](https://github.com/GSA-TTS/usai-gov/blob/main/packages/ui/PROFILE_MENU.md)** - ProfileMenu component usage and event handling
239
220
  - **[MODAL_COMPONENTS.md](https://github.com/GSA-TTS/usai-gov/blob/main/packages/ui/MODAL_COMPONENTS.md)** - Modal component with examples, API reference, and visual screenshots
240
- - **[README_DocsLayout.md](https://github.com/GSA-TTS/usai-gov/blob/main/packages/ui/README_DocsLayout.md)** - DocsLayout component with dynamic navigation generation (Astro only)
241
-
242
- These files are also included with the package in your `node_modules/@gsa-tts/graymatter-ui/` directory. If you don't have access to the private repository, you can find the documentation files locally after installation.
243
-
244
- ## Framework Support
245
-
246
- - **Svelte 5** - Native Svelte components (individual components only)
247
- - **Astro** - Full support with client-side hydration (including DocsLayout)
248
- - **React/Vue/Angular** - Via web components (individual components only)
249
- - **Vanilla JavaScript** - Via web components (individual components only)
250
-
251
- **Note:** The `DocsLayout` component is Astro-specific and cannot be used in other frameworks. For non-Astro applications, use the individual Svelte components and shared utilities instead.
252
221
 
253
- ## Troubleshooting
222
+ > **Application layouts:** Page layouts (`BaseLayout`, `GlobalAppLayout`,
223
+ > `DocsLayout`, etc.) are owned by the consuming application, not this package.
224
+ > For the USAi site, see `apps/site/src/layouts/`.
254
225
 
255
- ### Build Issues with Astro Files
226
+ These files are also included with the package in your
227
+ `node_modules/@gsa-tts/graymatter-ui/` directory. If you don't have access to the
228
+ private repository, you can find the documentation files locally after
229
+ installation.
256
230
 
257
- If you're getting build errors related to Astro files in a Svelte-only project, use the dedicated import paths:
258
-
259
- ```javascript
260
- // ✅ For Svelte-only projects using web components
261
- import { toggleNavigation } from '@gsa-tts/graymatter-ui/utils';
262
- // Use web components in HTML: <graymatter-button>, <graymatter-logo>, etc.
263
-
264
- // ❌ Avoid in Svelte-only projects
265
- import { toggleNavigation } from '@gsa-tts/graymatter-ui';
266
- ```
231
+ ## Framework Support
267
232
 
268
- **Common Error:** `Unexpected token '{'. Expected '.' or '('` when importing from the main package in Svelte-only projects.
233
+ - **Svelte 5** - Native Svelte components
234
+ - **Astro** - Consume the Svelte components as islands with client-side hydration
235
+ - **SvelteKit** - Native Svelte components
269
236
 
270
- **Solution:** Use the `/utils` path for utility functions. For UI components, use web components instead of importing Svelte components directly.
237
+ Consuming applications provide their own page layouts and framework
238
+ configuration; this package ships the shared Svelte components, styles, and
239
+ utilities they build on.
271
240
 
272
241
  ## Browser Support
273
242
 
274
243
  - **Modern Browsers** - Chrome, Firefox, Safari, Edge (latest 2 versions)
275
- - **Web Components** - Native support or polyfill required
276
- - **Custom Events** - Native support in all modern browsers
244
+ - **Custom Events** - Native support in all modern browsers