@gsa-tts/graymatter-ui 0.2.7 → 0.3.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 +81 -0
- package/assets/images/favicon-dark.ico +0 -0
- package/assets/images/favicon-dark.svg +7 -0
- package/assets/images/favicon-light.svg +7 -0
- package/assets/images/favicon.ico +0 -0
- package/assets/images/favicon.svg +5 -6
- package/dist/graymatter-ui.js +1663 -1628
- package/dist/graymatter-ui.umd.cjs +80 -33
- package/package.json +4 -4
- package/src/components/Button.svelte +27 -31
- package/src/components/Button.webcomponent.svelte +13 -11
- package/src/components/DesktopHeader.svelte +70 -53
- package/src/components/DesktopHeader.webcomponent.svelte +13 -9
- package/src/components/DesktopSideNav.svelte +209 -166
- package/src/components/DesktopSideNav.webcomponent.svelte +7 -5
- package/src/components/Head.astro +24 -2
- package/src/components/Logo.svelte +48 -41
- package/src/components/Logo.webcomponent.svelte +16 -16
- package/src/components/MobileBottomNav.svelte +102 -69
- package/src/components/MobileBottomNav.webcomponent.svelte +13 -4
- package/src/components/MobileSideMenu.svelte +70 -42
- package/src/components/MobileSideMenu.webcomponent.svelte +6 -4
- package/src/components/MobileTopNav.svelte +24 -19
- package/src/components/MobileTopNav.webcomponent.svelte +6 -6
- package/src/components/NavigationInitializer.svelte +10 -2
- package/src/components/ProfileMenu.svelte +116 -27
- package/src/components/UsaSkipNav.svelte +23 -0
- package/src/components/icons/ApiIcon.svelte +182 -33
- package/src/components/icons/ChatIcon.svelte +10 -10
- package/src/components/icons/CloseIcon.svelte +10 -10
- package/src/components/icons/ConsoleIcon.svelte +68 -13
- package/src/components/icons/DiscoverIcon.svelte +14 -14
- package/src/components/icons/HelpIcon.svelte +2 -1
- package/src/components/icons/MenuIcon.svelte +47 -7
- package/src/components/index.ts +1 -1
- package/src/layouts/BaseLayout.astro +1 -1
- package/src/styles/base/global.css +7 -1
- package/src/components/UsaSkipNav.astro +0 -5
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# GrayMatter UI Package
|
|
2
|
+
|
|
3
|
+
## ProfileMenu Component - Event-Driven Architecture
|
|
4
|
+
|
|
5
|
+
The ProfileMenu component uses a custom event system to handle menu item actions, avoiding issues with function serialization in Astro apps.
|
|
6
|
+
|
|
7
|
+
### Usage
|
|
8
|
+
|
|
9
|
+
#### 1. Define Menu Items with Action Strings
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const profileMenuData = {
|
|
13
|
+
userMeta: {
|
|
14
|
+
initials: 'ZW',
|
|
15
|
+
},
|
|
16
|
+
menuItems: [
|
|
17
|
+
{
|
|
18
|
+
label: 'Settings',
|
|
19
|
+
icon: '/path/to/icon.svg',
|
|
20
|
+
action: 'settings', // String identifier
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: 'Log out',
|
|
24
|
+
icon: '/path/to/icon.svg',
|
|
25
|
+
action: 'logout', // String identifier
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### 2. Listen for Profile Menu Actions
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// In your app's main layout or component
|
|
35
|
+
window.addEventListener('profileMenuAction', (event) => {
|
|
36
|
+
const { action, userMeta, timestamp } = event.detail;
|
|
37
|
+
|
|
38
|
+
switch (action) {
|
|
39
|
+
case 'settings':
|
|
40
|
+
// Handle settings action
|
|
41
|
+
console.log('Settings clicked for user:', userMeta);
|
|
42
|
+
break;
|
|
43
|
+
case 'logout':
|
|
44
|
+
// Handle logout action
|
|
45
|
+
console.log('Logout clicked for user:', userMeta);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
console.warn('Unknown profile menu action:', action);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Event Details
|
|
54
|
+
|
|
55
|
+
The `profileMenuAction` event includes:
|
|
56
|
+
|
|
57
|
+
- **action**: String identifier for the menu item action
|
|
58
|
+
- **userMeta**: User metadata object
|
|
59
|
+
- **timestamp**: When the action was triggered
|
|
60
|
+
|
|
61
|
+
### Benefits
|
|
62
|
+
|
|
63
|
+
- ✅ **No serialization issues** - Works with both Astro and Svelte apps
|
|
64
|
+
- ✅ **Type safe** - No runtime function evaluation
|
|
65
|
+
- ✅ **Secure** - No `new Function()` usage
|
|
66
|
+
- ✅ **Debuggable** - Clear event flow
|
|
67
|
+
- ✅ **Flexible** - Each app can handle actions differently
|
|
68
|
+
- ✅ **Shadow DOM compatible** - Events bubble through web component boundaries
|
|
69
|
+
|
|
70
|
+
### Shadow DOM & Web Component Support
|
|
71
|
+
|
|
72
|
+
The ProfileMenu component is designed to work in both regular DOM and Shadow DOM contexts:
|
|
73
|
+
|
|
74
|
+
- **Regular DOM**: Events bubble up to `window` as expected
|
|
75
|
+
- **Shadow DOM**: Events are configured with `bubbles: true` and `composed: true` to cross Shadow DOM boundaries
|
|
76
|
+
- **Web Components**: Events are dispatched from the component element to ensure proper bubbling
|
|
77
|
+
|
|
78
|
+
This makes the component compatible with:
|
|
79
|
+
- Astro apps using the component directly
|
|
80
|
+
- Svelte apps using the web component version
|
|
81
|
+
- Any other framework using the web component
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18.0948 18.1253C18.0948 16.6694 16.8854 15.4856 15.3983 15.4856H12.6294C12.152 15.4856 11.7628 15.107 11.7628 14.6406C11.7628 14.1742 12.1511 13.7956 12.6294 13.7956H17.6731V12H12.217C10.7308 12 9.52148 13.1846 9.52148 14.6406C9.52148 16.0966 10.7308 17.2812 12.217 17.2812H14.9859C15.4634 17.2812 15.8525 17.6598 15.8525 18.1262C15.8525 18.5926 15.4643 18.9712 14.9859 18.9712H9.75091V20.7659H15.3983C16.8854 20.7659 18.0948 19.5813 18.0948 18.1262V18.1253Z" fill="white"/>
|
|
3
|
+
<path d="M25.8147 19.4146L25.8278 19.4305L26.295 20.7659H28.5001L25.4283 12H21.4798L18.4081 20.765H20.6132L21.086 19.4146H25.8147ZM21.7417 17.5445L23.0551 13.7956H23.8521L23.8577 13.8106L25.1766 17.5738H21.7315L21.7417 17.5445Z" fill="white"/>
|
|
4
|
+
<path d="M8.5473 12H6.46203V16.7447C6.46203 18.4303 5.33068 19.0306 4.27272 19.0306C2.84043 19.0306 2.08342 18.2397 2.08342 16.7447V12H0V17.1021C0 18.2096 0.459782 19.216 1.29389 19.936C2.08899 20.6223 3.14695 21 4.27365 21C6.39794 21 8.5473 19.6611 8.5473 17.1012V12Z" fill="white"/>
|
|
5
|
+
<path d="M31.9635 14.9368H29.4993V20.7659H31.9635V14.9368Z" fill="white"/>
|
|
6
|
+
<path d="M31.9997 12H29.4993V13.7947H31.9997V12Z" fill="white"/>
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18.0948 18.1253C18.0948 16.6694 16.8854 15.4856 15.3984 15.4856H12.6294C12.152 15.4856 11.7628 15.107 11.7628 14.6406C11.7628 14.1742 12.1511 13.7956 12.6294 13.7956H17.6731V12H12.217C10.7309 12 9.52151 13.1846 9.52151 14.6406C9.52151 16.0966 10.7309 17.2812 12.217 17.2812H14.9859C15.4634 17.2812 15.8526 17.6598 15.8526 18.1262C15.8526 18.5926 15.4643 18.9712 14.9859 18.9712H9.75093V20.7659H15.3984C16.8854 20.7659 18.0948 19.5804 18.0948 18.1253Z" fill="black"/>
|
|
3
|
+
<path d="M25.8148 19.4146L25.8278 19.4305L26.295 20.7659H28.5001L25.4284 12H21.4798L18.4081 20.765H20.6132L21.086 19.4146H25.8148ZM21.7417 17.5445L23.0551 13.7956H23.8521L23.8577 13.8106L25.1766 17.5738H21.7315L21.7417 17.5445Z" fill="black"/>
|
|
4
|
+
<path d="M8.5473 12H6.46203V16.7447C6.46203 18.4303 5.33068 19.0306 4.27272 19.0306C2.84043 19.0306 2.08342 18.2397 2.08342 16.7447V12H0V17.1021C0 18.2096 0.459782 19.216 1.29389 19.936C2.08899 20.6223 3.14695 21 4.27365 21C6.39794 21 8.5473 19.6611 8.5473 17.1012V12Z" fill="black"/>
|
|
5
|
+
<path d="M31.9635 14.9368H29.4992V20.7659H31.9635V14.9368Z" fill="black"/>
|
|
6
|
+
<path d="M31.9997 12H29.4992V13.7947H31.9997V12Z" fill="black"/>
|
|
7
|
+
</svg>
|
|
Binary file
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<
|
|
3
|
-
<path d="
|
|
4
|
-
<path d="
|
|
5
|
-
<path d="
|
|
6
|
-
<path d="
|
|
7
|
-
<path d="M30.2161 11.6181H27.9881V13.2933H30.2161V11.6181Z" fill="black"/>
|
|
2
|
+
<path d="M18.0948 18.1253C18.0948 16.6694 16.8854 15.4856 15.3984 15.4856H12.6294C12.152 15.4856 11.7628 15.107 11.7628 14.6406C11.7628 14.1742 12.1511 13.7956 12.6294 13.7956H17.6731V12H12.217C10.7309 12 9.52151 13.1846 9.52151 14.6406C9.52151 16.0966 10.7309 17.2812 12.217 17.2812H14.9859C15.4634 17.2812 15.8526 17.6598 15.8526 18.1262C15.8526 18.5926 15.4643 18.9712 14.9859 18.9712H9.75093V20.7659H15.3984C16.8854 20.7659 18.0948 19.5804 18.0948 18.1253Z" fill="black"/>
|
|
3
|
+
<path d="M25.8148 19.4146L25.8278 19.4305L26.295 20.7659H28.5001L25.4284 12H21.4798L18.4081 20.765H20.6132L21.086 19.4146H25.8148ZM21.7417 17.5445L23.0551 13.7956H23.8521L23.8577 13.8106L25.1766 17.5738H21.7315L21.7417 17.5445Z" fill="black"/>
|
|
4
|
+
<path d="M8.5473 12H6.46203V16.7447C6.46203 18.4303 5.33068 19.0306 4.27272 19.0306C2.84043 19.0306 2.08342 18.2397 2.08342 16.7447V12H0V17.1021C0 18.2096 0.459782 19.216 1.29389 19.936C2.08899 20.6223 3.14695 21 4.27365 21C6.39794 21 8.5473 19.6611 8.5473 17.1012V12Z" fill="black"/>
|
|
5
|
+
<path d="M31.9635 14.9368H29.4992V20.7659H31.9635V14.9368Z" fill="black"/>
|
|
6
|
+
<path d="M31.9997 12H29.4992V13.7947H31.9997V12Z" fill="black"/>
|
|
8
7
|
</svg>
|