@gsa-tts/graymatter-ui 0.4.9 → 0.4.10

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.4.9",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,6 +38,7 @@
38
38
  } = $props();
39
39
 
40
40
  const helpUrl = supplementalMenuData?.help?.url?.trim();
41
+ const isHelpSelected = $derived(() => get(selectedSubNavItemId) === 'help');
41
42
 
42
43
  let hydrated = false;
43
44
  let navContainer: HTMLDivElement;
@@ -177,8 +178,30 @@
177
178
  }
178
179
  };
179
180
  }
181
+
182
+ const location = (
183
+ globalThis as { location?: { pathname?: string; origin?: string } }
184
+ ).location;
185
+ if (helpUrl && location?.origin && location?.pathname) {
186
+ const helpPath = getPathname(helpUrl, location.origin);
187
+ if (helpPath && location.pathname === helpPath) {
188
+ selectedSubNavItemId.set('help');
189
+ }
190
+ }
180
191
  });
181
192
 
193
+ function getPathname(url: string, baseOrigin: string) {
194
+ try {
195
+ return new URL(url, baseOrigin).pathname;
196
+ } catch {
197
+ return null;
198
+ }
199
+ }
200
+
201
+ function handleHelpClick() {
202
+ selectedSubNavItemId.set('help');
203
+ }
204
+
182
205
  function toggleNav() {
183
206
  if ($isMenuButtonDisabled) return;
184
207
  navigationStore.toggleExpanded();
@@ -437,14 +460,19 @@
437
460
  >
438
461
  <a
439
462
  class="help-link"
440
- class:selected={get(selectedSubNavItemId) === 'help'}
441
- aria-current={get(selectedSubNavItemId) === 'help'}
463
+ class:selected={isHelpSelected()}
464
+ aria-current={isHelpSelected()}
442
465
  href={helpUrl}
443
466
  part="help-link"
444
467
  title="Help"
445
468
  aria-label="Help"
469
+ onclick={handleHelpClick}
446
470
  >
447
- <HelpIcon />
471
+ <div class="icon-container" part="help-icon-container">
472
+ <div class="icon-wrapper">
473
+ <HelpIcon isSelected={isHelpSelected()} />
474
+ </div>
475
+ </div>
448
476
  </a>
449
477
  </div>
450
478
  {/if}
@@ -624,7 +652,8 @@
624
652
  }
625
653
 
626
654
  .menu-button:focus .icon-container,
627
- .nav-item:focus .icon-container {
655
+ .nav-item:focus .icon-container,
656
+ .help-link:focus .icon-container {
628
657
  outline: var(--ai-size-2) solid var(--ai-color-blue-600);
629
658
  outline-offset: var(--ai-size-2);
630
659
  border-radius: var(--ai-size-4);
@@ -632,7 +661,8 @@
632
661
 
633
662
  /* Hide focus outline on click */
634
663
  .menu-button:focus:not(:focus-visible) .icon-container,
635
- .nav-item:focus:not(:focus-visible) .icon-container {
664
+ .nav-item:focus:not(:focus-visible) .icon-container,
665
+ .help-link:focus:not(:focus-visible) .icon-container {
636
666
  outline: none;
637
667
  }
638
668
 
@@ -726,7 +756,9 @@
726
756
  .nav-item.selected .icon-container,
727
757
  .nav-item.selected.hovered .icon-container,
728
758
  .menu-button:hover .icon-container,
729
- .menu-button:active .icon-container {
759
+ .menu-button:active .icon-container,
760
+ .help-link:hover .icon-container,
761
+ .help-link.selected .icon-container {
730
762
  background-color: var(--ai-color-steel-300);
731
763
  border-radius: var(--ai-size-4);
732
764
  }
@@ -767,20 +799,14 @@
767
799
  }
768
800
 
769
801
  .help-link {
770
- border-radius: var(--ai-size-4);
771
- padding: var(--ai-size-4);
772
- transition: background-color var(--ai-transition-ease-medium);
802
+ display: flex;
803
+ align-items: center;
804
+ justify-content: center;
805
+ text-decoration: none;
806
+ color: inherit;
773
807
  }
774
808
 
775
809
  .help-link :global(svg) {
776
810
  display: block;
777
811
  }
778
-
779
- .help-link:hover {
780
- background: var(--ai-color-steel-300);
781
- }
782
-
783
- .help-link:is(.selected) {
784
- background-color: var(--ai-color-steel-300);
785
- }
786
812
  </style>
@@ -3,15 +3,22 @@
3
3
  isMenuButtonDisabled,
4
4
  navigationStore,
5
5
  selectedSubNavItemTitle,
6
+ selectedSubNavItemId,
6
7
  } from '../stores/navigationStore.js';
7
8
  import Logo from './Logo.svelte';
8
9
  import MenuIcon from './icons/MenuIcon.svelte';
10
+ import HelpIcon from './icons/HelpIcon.svelte';
9
11
  import { onMount } from 'svelte';
12
+ import { get } from 'svelte/store';
10
13
 
11
- let { profileMenuData, logoLinkUrl, logoLinkLabel } = $props();
14
+ let { profileMenuData, logoLinkUrl, logoLinkLabel, supplementalMenuData } =
15
+ $props();
12
16
 
13
17
  import ProfileMenu from './ProfileMenu.svelte';
14
18
 
19
+ const helpUrl = supplementalMenuData?.help?.url?.trim();
20
+ const isHelpSelected = $derived(() => get(selectedSubNavItemId) === 'help');
21
+
15
22
  onMount(() => {
16
23
  // Listen for section visibility changes to update header
17
24
  const handleSectionVisible = (event: Event) => {
@@ -72,9 +79,35 @@
72
79
  };
73
80
  });
74
81
 
82
+ onMount(() => {
83
+ const location = (
84
+ globalThis as {
85
+ location?: { pathname?: string; origin?: string };
86
+ }
87
+ ).location;
88
+ if (helpUrl && location?.origin && location?.pathname) {
89
+ const helpPath = getPathname(helpUrl, location.origin);
90
+ if (helpPath && location.pathname === helpPath) {
91
+ selectedSubNavItemId.set('help');
92
+ }
93
+ }
94
+ });
95
+
96
+ function getPathname(url: string, baseOrigin: string) {
97
+ try {
98
+ return new URL(url, baseOrigin).pathname;
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+
75
104
  function toggleMobileNav() {
76
105
  navigationStore.toggleExpanded();
77
106
  }
107
+
108
+ function handleHelpClick() {
109
+ selectedSubNavItemId.set('help');
110
+ }
78
111
  </script>
79
112
 
80
113
  <nav class="mobile-top-nav" part="mobile-top-nav">
@@ -101,6 +134,22 @@
101
134
  <span class="brand-text">{$selectedSubNavItemTitle || ''}</span>
102
135
  </div>
103
136
 
137
+ {#if helpUrl}
138
+ <a
139
+ class="help-button"
140
+ class:selected={isHelpSelected()}
141
+ aria-current={isHelpSelected()}
142
+ href={helpUrl}
143
+ title="Help"
144
+ aria-label="Help"
145
+ onclick={handleHelpClick}
146
+ >
147
+ <span class="icon-container">
148
+ <HelpIcon isSelected={isHelpSelected()} />
149
+ </span>
150
+ </a>
151
+ {/if}
152
+
104
153
  {#if profileMenuData}
105
154
  <ProfileMenu
106
155
  userMeta={profileMenuData?.userMeta}
@@ -184,4 +233,28 @@
184
233
  .menu-button:focus {
185
234
  outline: none;
186
235
  }
236
+
237
+ .help-button {
238
+ display: flex;
239
+ align-items: center;
240
+ justify-content: center;
241
+ margin-right: var(--ai-size-4);
242
+ text-decoration: none;
243
+ color: inherit;
244
+ }
245
+
246
+ .help-button .icon-container {
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ width: var(--ai-size-40);
251
+ height: var(--ai-size-40);
252
+ border-radius: var(--ai-size-4);
253
+ transition: background-color var(--ai-transition-ease-fast);
254
+ }
255
+
256
+ .help-button:hover .icon-container,
257
+ .help-button.selected .icon-container {
258
+ background-color: var(--ai-color-steel-300);
259
+ }
187
260
  </style>
@@ -8,7 +8,13 @@
8
8
  import MobileTopNav from './MobileTopNav.svelte';
9
9
 
10
10
  // Props for the web component
11
- let { profileMenuData, logoLinkUrl, logoLinkLabel } = $props();
11
+ let { profileMenuData, logoLinkUrl, logoLinkLabel, supplementalMenuData } =
12
+ $props();
12
13
  </script>
13
14
 
14
- <MobileTopNav {profileMenuData} {logoLinkUrl} {logoLinkLabel} />
15
+ <MobileTopNav
16
+ {profileMenuData}
17
+ {logoLinkUrl}
18
+ {logoLinkLabel}
19
+ {supplementalMenuData}
20
+ />
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- export let isHovered: boolean = false;
2
+ export let isSelected = false;
3
3
  </script>
4
4
 
5
5
  <svg
@@ -11,7 +11,7 @@
11
11
  >
12
12
  <path
13
13
  d="M9.87891 7.51884C11.0505 6.49372 12.95 6.49372 14.1215 7.51884C15.2931 8.54397 15.2931 10.206 14.1215 11.2312C13.9176 11.4096 13.6917 11.5569 13.4513 11.6733C12.7056 12.0341 12.0002 12.6716 12.0002 13.5V14.25M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12ZM12 17.25H12.0075V17.2575H12V17.25Z"
14
- stroke={isHovered ? '#000' : '#585C63'}
14
+ stroke={isSelected ? '#000' : '#585C63'}
15
15
  stroke-width="1.5"
16
16
  stroke-linecap="round"
17
17
  stroke-linejoin="round"