@gsa-tts/graymatter-ui 0.3.1 → 0.3.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 +173 -74
- package/assets/images/chat-hero-image-mobile.webp +0 -0
- package/dist/graymatter-ui.js +2172 -2073
- package/dist/graymatter-ui.umd.cjs +21 -21
- package/package.json +5 -4
- package/src/astro-config/index.ts +10 -0
- package/src/components/Button.svelte +4 -0
- package/src/components/DesktopSideNav.svelte +41 -1
- package/src/components/Head.astro +2 -1
- package/src/components/MobileBottomNav.svelte +5 -1
- package/src/components/MobileSideMenu.svelte +2 -2
- package/src/components/MobileSideMenu.webcomponent.svelte +2 -4
- package/src/components/MobileTopNav.svelte +9 -2
- package/src/components/MobileTopNav.webcomponent.svelte +2 -2
- package/src/components/{UsaBanner.astro → UsaBanner.svelte} +33 -31
- package/src/components/index.ts +1 -1
- package/src/index.ts +3 -0
- package/src/layouts/GlobalAppLayout.astro +6 -127
- package/src/styles/base/typography.css +8 -1
- package/src/styles/components/heroCards.css +1 -7
- package/src/utils/navigationControl.ts +78 -0
- package/src/utils/setupMocks.ts +10 -2
- package/static/uswds/styles/styles.css +1 -1
- package/static/uswds/styles/styles.css.map +1 -1
- package/assets/images/api-hero-image.png +0 -0
- package/assets/images/chat-hero-image.png +0 -0
- package/assets/images/console-hero-image.png +0 -0
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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.
|
|
4
|
+
|
|
3
5
|
## Package Responsibilities
|
|
4
6
|
|
|
5
|
-
The GrayMatter UI package (`@gsa-tts/graymatter-ui`) is a UI component library
|
|
7
|
+
The GrayMatter UI package (`@gsa-tts/graymatter-ui`) is a UI component library that provides:
|
|
6
8
|
|
|
7
9
|
### Primary Responsibilities:
|
|
8
10
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- **Reusable UI Components** - A comprehensive set of accessible, customizable components
|
|
12
|
+
- **Design System Implementation** - Built using tokens from `@gsa-tts/graymatter-style-tokens`
|
|
13
|
+
- **Layout Components** - Consistent page structures and navigation patterns
|
|
14
|
+
- **Utility Functions** - Helper functions for UI-related operations
|
|
15
|
+
- **Cross-Framework Support** - Components available as both Svelte components and web components
|
|
14
16
|
|
|
15
17
|
### Package Boundaries:
|
|
16
18
|
|
|
@@ -21,91 +23,188 @@ The GrayMatter UI package (`@gsa-tts/graymatter-ui`) is a UI component library.
|
|
|
21
23
|
- **SHOULD NOT** contain data fetching or API integration code
|
|
22
24
|
- **SHOULD NOT** depend on application-specific packages
|
|
23
25
|
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @gsa-tts/graymatter-ui @gsa-tts/graymatter-style-tokens
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Note:** The `@gsa-tts/graymatter-style-tokens` package is required for proper styling and design tokens.
|
|
33
|
+
|
|
24
34
|
## Usage
|
|
25
35
|
|
|
26
36
|
The UI package can be used in two ways:
|
|
27
37
|
|
|
28
|
-
1.
|
|
29
|
-
2. As web components (for any framework or vanilla JS)
|
|
38
|
+
### 1. Svelte Components (for Svelte/Astro applications)
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
```svelte
|
|
41
|
+
<script>
|
|
42
|
+
import { DesktopSideNav, ProfileMenu } from '@gsa-tts/graymatter-ui';
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<DesktopSideNav showAppIcons={true} ssrSelectedItem="api">
|
|
46
|
+
<!-- Sub navigation content -->
|
|
47
|
+
</DesktopSideNav>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Web Components (for any framework or vanilla JS)
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<graymatter-desktop-side-nav show-app-icons="true" ssr-selected-item="api">
|
|
54
|
+
<!-- Sub navigation content -->
|
|
55
|
+
</graymatter-desktop-side-nav>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Navigation URL Configuration
|
|
59
|
+
|
|
60
|
+
Navigation components (`DesktopSideNav`, `MobileBottomNav`) support flexible URL configuration:
|
|
61
|
+
|
|
62
|
+
### Option 1: Environment Variables (Recommended)
|
|
63
|
+
```bash
|
|
64
|
+
# .env
|
|
65
|
+
PUBLIC_CHAT_URL=https://your-chat-app.com
|
|
66
|
+
PUBLIC_CONSOLE_URL=https://your-console-app.com
|
|
67
|
+
PUBLIC_API_URL=https://your-api-app.com
|
|
68
|
+
PUBLIC_DISCOVER_URL=https://your-discover-page.com
|
|
69
|
+
```
|
|
32
70
|
|
|
33
|
-
###
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
initials: 'ZW',
|
|
45
|
-
},
|
|
46
|
-
menuItems: [
|
|
47
|
-
{
|
|
48
|
-
label: 'Settings',
|
|
49
|
-
icon: '/path/to/icon.svg',
|
|
50
|
-
action: 'settings', // String identifier
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
label: 'Log out',
|
|
54
|
-
icon: '/path/to/icon.svg',
|
|
55
|
-
action: 'logout', // String identifier
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
71
|
+
### Option 2: Component Props (Override Environment)
|
|
72
|
+
```svelte
|
|
73
|
+
<DesktopSideNav
|
|
74
|
+
showAppIcons={true}
|
|
75
|
+
apiUrl="https://custom-api.com"
|
|
76
|
+
chatUrl="https://custom-chat.com"
|
|
77
|
+
consoleUrl="https://custom-console.com"
|
|
78
|
+
discoverUrl="https://custom-discover.com"
|
|
79
|
+
>
|
|
80
|
+
<!-- Sub navigation content -->
|
|
81
|
+
</DesktopSideNav>
|
|
59
82
|
```
|
|
60
83
|
|
|
61
|
-
|
|
84
|
+
### Option 3: Mixed Approach
|
|
85
|
+
```svelte
|
|
86
|
+
<DesktopSideNav
|
|
87
|
+
showAppIcons={true}
|
|
88
|
+
apiUrl="https://custom-api.com"
|
|
89
|
+
<!-- chatUrl, consoleUrl, discoverUrl will use environment variables -->
|
|
90
|
+
>
|
|
91
|
+
<!-- Sub navigation content -->
|
|
92
|
+
</DesktopSideNav>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Priority Order:** Component props → Environment variables → Fallback (`#`)
|
|
96
|
+
|
|
97
|
+
## Available Components
|
|
98
|
+
|
|
99
|
+
### Web Components (Universal - Any Framework)
|
|
100
|
+
|
|
101
|
+
All components with `.webcomponent.svelte` extension are available as web components:
|
|
62
102
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
- `graymatter-desktop-side-nav` - Desktop sidebar navigation
|
|
104
|
+
- `graymatter-mobile-top-nav` - Mobile header navigation
|
|
105
|
+
- `graymatter-mobile-bottom-nav` - Mobile bottom navigation bar
|
|
106
|
+
- `graymatter-mobile-side-menu` - Mobile slide-out navigation menu
|
|
107
|
+
- `graymatter-desktop-header` - Desktop header component
|
|
108
|
+
- `graymatter-button` - Accessible button component
|
|
109
|
+
- `graymatter-logo` - Brand logo component
|
|
110
|
+
|
|
111
|
+
### Svelte 5 Components
|
|
112
|
+
|
|
113
|
+
Available for Svelte, SvelteKit, and Astro applications:
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
import {
|
|
117
|
+
// Navigation Components
|
|
118
|
+
DesktopSideNav,
|
|
119
|
+
MobileTopNav,
|
|
120
|
+
MobileBottomNav,
|
|
121
|
+
MobileSideMenu,
|
|
122
|
+
DesktopHeader,
|
|
123
|
+
|
|
124
|
+
// UI Components
|
|
125
|
+
Button,
|
|
126
|
+
Logo,
|
|
127
|
+
ProfileMenu,
|
|
128
|
+
|
|
129
|
+
// Utility Components
|
|
130
|
+
UsaBanner,
|
|
131
|
+
UsaSkipNav,
|
|
132
|
+
NavigationInitializer,
|
|
67
133
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log('Settings clicked for user:', userMeta);
|
|
72
|
-
break;
|
|
73
|
-
case 'logout':
|
|
74
|
-
// Handle logout action
|
|
75
|
-
console.log('Logout clicked for user:', userMeta);
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
console.warn('Unknown profile menu action:', action);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
134
|
+
// Icon Components
|
|
135
|
+
// (all icons from ./icons/index.js)
|
|
136
|
+
} from '@gsa-tts/graymatter-ui/components';
|
|
81
137
|
```
|
|
82
138
|
|
|
83
|
-
###
|
|
139
|
+
### Astro Components
|
|
140
|
+
|
|
141
|
+
Available for Astro applications:
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
import {
|
|
145
|
+
Head,
|
|
146
|
+
BaseLayout,
|
|
147
|
+
GlobalAppLayout
|
|
148
|
+
} from '@gsa-tts/graymatter-ui/layouts';
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Component Categories
|
|
152
|
+
|
|
153
|
+
### Navigation Components
|
|
154
|
+
- **DesktopSideNav** - Desktop sidebar navigation with external control support
|
|
155
|
+
- **MobileTopNav** - Mobile header navigation
|
|
156
|
+
- **MobileBottomNav** - Mobile bottom navigation bar
|
|
157
|
+
- **MobileSideMenu** - Mobile slide-out navigation menu
|
|
84
158
|
|
|
85
|
-
|
|
159
|
+
### Layout Components
|
|
160
|
+
- **GlobalAppLayout** - Main application layout wrapper
|
|
161
|
+
- **BaseLayout** - Base page layout structure
|
|
86
162
|
|
|
87
|
-
|
|
88
|
-
- **
|
|
89
|
-
- **
|
|
163
|
+
### UI Components
|
|
164
|
+
- **ProfileMenu** - User profile dropdown menu with event-driven actions
|
|
165
|
+
- **Button** - Accessible button component with multiple variants
|
|
166
|
+
- **Logo** - Brand logo component
|
|
167
|
+
|
|
168
|
+
### Utility Components
|
|
169
|
+
- **UsaBanner** - Government banner component
|
|
170
|
+
- **UsaSkipNav** - Skip navigation link for accessibility
|
|
171
|
+
|
|
172
|
+
## Key Features
|
|
173
|
+
|
|
174
|
+
### Event-Driven Architecture
|
|
175
|
+
Many components use custom events for external control and communication:
|
|
176
|
+
|
|
177
|
+
- **DesktopSideNav** - External control via `graymatter-desktop-nav-control` events
|
|
178
|
+
- **ProfileMenu** - Action handling via `profileMenuAction` events
|
|
179
|
+
|
|
180
|
+
### Cross-App Communication
|
|
181
|
+
Components support communication between different applications:
|
|
182
|
+
|
|
183
|
+
- **Navigation Control** - Control desktop navigation from external apps
|
|
184
|
+
- **Event Bubbling** - Events work across Shadow DOM boundaries
|
|
185
|
+
|
|
186
|
+
### Accessibility
|
|
187
|
+
- **WCAG 2.1 AA Compliant** - Built with accessibility in mind
|
|
188
|
+
- **Keyboard Navigation** - Full keyboard support
|
|
189
|
+
- **Screen Reader Support** - Proper ARIA labels and roles
|
|
190
|
+
|
|
191
|
+
## Component Documentation
|
|
90
192
|
|
|
91
|
-
###
|
|
193
|
+
### Navigation Control
|
|
194
|
+
- **[DesktopSideNav External Control](./docs/NAVIGATION_CONTROL.md)** - Event-based control system for desktop navigation
|
|
92
195
|
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
- ✅ **Secure** - No `new Function()` usage
|
|
96
|
-
- ✅ **Debuggable** - Clear event flow
|
|
97
|
-
- ✅ **Flexible** - Each app can handle actions differently
|
|
98
|
-
- ✅ **Shadow DOM compatible** - Events bubble through web component boundaries
|
|
196
|
+
### Component-Specific Documentation
|
|
197
|
+
- **[ProfileMenu Component](./docs/PROFILE_MENU.md)** - Event-driven profile menu with action handling
|
|
99
198
|
|
|
100
|
-
|
|
199
|
+
## Framework Support
|
|
101
200
|
|
|
102
|
-
|
|
201
|
+
- **Svelte 5** - Native Svelte components
|
|
202
|
+
- **Astro** - Full support with client-side hydration
|
|
203
|
+
- **React/Vue/Angular** - Via web components
|
|
204
|
+
- **Vanilla JavaScript** - Via web components
|
|
103
205
|
|
|
104
|
-
|
|
105
|
-
- **Shadow DOM**: Events are configured with `bubbles: true` and `composed: true` to cross Shadow DOM boundaries
|
|
106
|
-
- **Web Components**: Events are dispatched from the component element to ensure proper bubbling
|
|
206
|
+
## Browser Support
|
|
107
207
|
|
|
108
|
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
- Any other framework using the web component
|
|
208
|
+
- **Modern Browsers** - Chrome, Firefox, Safari, Edge (latest 2 versions)
|
|
209
|
+
- **Web Components** - Native support or polyfill required
|
|
210
|
+
- **Custom Events** - Native support in all modern browsers
|
|
Binary file
|