@gsa-tts/graymatter-ui 0.2.3 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gsa-tts/graymatter-ui",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -247,7 +247,7 @@
247
247
  aria-label={sideNavExpanded() ? 'Close navigation menu' : 'Open navigation menu'}
248
248
  aria-expanded={sideNavExpanded() ? 'true' : 'false'}
249
249
  >
250
- <div class="icon-container">
250
+ <div class="icon-container" part="icon-container">
251
251
  <div class="icon-wrapper">
252
252
  <MenuIcon
253
253
  isHovered={menuBtnHovered()}
@@ -541,6 +541,12 @@
541
541
  border-radius: var(--ai-size-4);
542
542
  }
543
543
 
544
+ /* Hide focus outline on click */
545
+ .menu-button:focus:not(:focus-visible) .icon-container,
546
+ .nav-item:focus:not(:focus-visible) .icon-container {
547
+ outline: none;
548
+ }
549
+
544
550
  .nav-items {
545
551
  display: flex;
546
552
  width: var(--ai-size-72);
@@ -2,9 +2,9 @@
2
2
  import { onMount } from 'svelte';
3
3
  /**
4
4
  * Array of menu items to render in the profile menu.
5
- * Each item: { label: string, icon: string, onClick: () => void }
5
+ * Each item: { label: string, icon: string, onClick: string | (() => void) }
6
6
  */
7
- export let menuItems: Array<{ label: string; icon: string; onClick: () => void }> = [];
7
+ export let menuItems: Array<{ label: string; icon: string; onClick: string | (() => void) }> = [];
8
8
  export let userMeta: { initials: string};
9
9
  export let ariaLabel: string = 'Open profile menu';
10
10
  export let menuAlign: 'desktop' | 'mobile' = 'desktop';
@@ -14,6 +14,24 @@
14
14
  function toggleMenu() { menuOpen = !menuOpen; }
15
15
  function closeMenu() { menuOpen = false; }
16
16
 
17
+ // Execute the onClick function - handles both string and function types
18
+ function executeOnClick(onClick: string | (() => void)) {
19
+ try {
20
+ if (typeof onClick === 'string') {
21
+ // Handle string-based function (for Astro apps)
22
+ const onClickFunction = new Function('return ' + onClick)();
23
+ onClickFunction();
24
+ } else if (typeof onClick === 'function') {
25
+ // Handle actual function (for Svelte apps)
26
+ onClick();
27
+ } else {
28
+ console.error('Invalid onClick type:', typeof onClick);
29
+ }
30
+ } catch (error) {
31
+ console.error('Error executing onClick function:', error);
32
+ }
33
+ }
34
+
17
35
  // Optional: close menu on outside click
18
36
  function handleBlur(event: FocusEvent) {
19
37
  const related = event.relatedTarget as HTMLElement | null;
@@ -91,14 +109,16 @@
91
109
  <button
92
110
  type="button"
93
111
  class="menu-item"
94
- on:click={() => { item.onClick(); closeMenu(); }}
112
+ on:click={() => { executeOnClick(item.onClick); closeMenu(); }}
95
113
  bind:this={btns[idx]}
96
114
  on:keydown={(e) => handleMenuKeydown(e, idx)}
97
115
  role="menuitem"
98
116
  >
117
+ {#if item.icon}
99
118
  <span class="icon">
100
119
  <img src={item.icon} alt="" aria-hidden="true" width="20" height="20" />
101
120
  </span>
121
+ {/if}
102
122
  <div class="menu-text">{item.label}</div>
103
123
  </button>
104
124
  {/each}
@@ -122,15 +142,24 @@
122
142
  }
123
143
 
124
144
  .user-profile-icon {
125
- border-radius: var(--ai-size-4);
126
145
  background: var(--ai-color-blue-800);
146
+ border-radius: var(--ai-size-4);
147
+ box-sizing: border-box;
148
+ height: var(--ai-size-40);
149
+ padding: var(--ai-size-4);
150
+ white-space: nowrap;
151
+ width: var(--ai-size-40);
127
152
  }
128
153
 
129
154
  .user-initials {
130
155
  color: var(--ai-color-white);
131
- text-align: center;
156
+ font-size: var(--ai-size-16);
157
+ font-style: normal;
132
158
  font-weight: 400;
133
- line-height: 1.3;
159
+ line-height: 1;
160
+ overflow: hidden;
161
+ text-align: center;
162
+ text-overflow: ellipsis;
134
163
  }
135
164
 
136
165
  .user-profile-button {
@@ -150,7 +179,7 @@
150
179
  }
151
180
 
152
181
  .user-profile-button:focus:not(:focus-visible) {
153
- outline: none;
182
+ outline: none;
154
183
  }
155
184
 
156
185
  .user-profile-container {
@@ -159,14 +188,6 @@
159
188
  aspect-ratio: 1/1;
160
189
  }
161
190
 
162
- .user-profile-icon {
163
- padding: 0.5556rem 0.4931rem 0.5694rem 0.3819rem;
164
- }
165
-
166
- .user-initials {
167
- font-size: var(--ai-size-16);
168
- font-style: normal;
169
- }
170
191
  .profile-context-menu {
171
192
  display: flex;
172
193
  width: 13.75rem;
@@ -238,4 +259,4 @@
238
259
  font-weight: 400;
239
260
  line-height: 130%;
240
261
  }
241
- </style>
262
+ </style>
@@ -1,2 +1,2 @@
1
- export const siteName = 'USAI.GOV';
1
+ export const siteName = 'USAi.gov';
2
2
  export const salesEmail = 'partnerships@usai.gov';
@@ -18,12 +18,11 @@ const {
18
18
  profileMenuData = undefined,
19
19
  logoLinkUrl,
20
20
  logoLinkLabel,
21
+ title: pageTitle,
21
22
  } = Astro.props;
22
-
23
- const title = getPageTitle(Astro);
24
23
  ---
25
24
 
26
- <BaseLayout title={title} gtmID={gtmID}>
25
+ <BaseLayout title={pageTitle} gtmID={gtmID}>
27
26
  <div class="app">
28
27
  <!-- Desktop Navigation -->
29
28
  <div class="layout-container">
@@ -1 +1 @@
1
- export * from './getAppUrls';
1
+ export * from './getAppUrls.js';