@gsa-tts/graymatter-ui 0.3.11 → 0.3.13

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
@@ -47,7 +47,21 @@ The UI package can be used in two ways:
47
47
  </DesktopSideNav>
48
48
  ```
49
49
 
50
- ### 2. Web Components (for any framework or vanilla JS)
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';
57
+
58
+ // ❌ Avoid this in Svelte-only projects (may cause build issues)
59
+ import { toggleNavigation } from '@gsa-tts/graymatter-ui';
60
+ ```
61
+
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.
63
+
64
+ ### 3. Web Components (for any framework or vanilla JS)
51
65
 
52
66
  ```html
53
67
  <graymatter-desktop-side-nav show-app-icons="true" ssr-selected-item="api">
@@ -186,6 +200,16 @@ import {
186
200
  - **UsaBanner** - Government banner component
187
201
  - **UsaSkipNav** - Skip navigation link for accessibility
188
202
 
203
+ ### Utility Functions
204
+ Available via the `/utils` import path:
205
+
206
+ ```javascript
207
+ import { toggleNavigation } from '@gsa-tts/graymatter-ui/utils';
208
+ ```
209
+
210
+ - **toggleNavigation()** - Toggle desktop navigation visibility
211
+ - **controlDesktopNavigation()** - Advanced navigation control
212
+
189
213
  ## Key Features
190
214
 
191
215
  ### Event-Driven Architecture
@@ -221,6 +245,25 @@ These files are also included with the package in your `node_modules/@gsa-tts/gr
221
245
  - **React/Vue/Angular** - Via web components
222
246
  - **Vanilla JavaScript** - Via web components
223
247
 
248
+ ## Troubleshooting
249
+
250
+ ### Build Issues with Astro Files
251
+
252
+ If you're getting build errors related to Astro files in a Svelte-only project, use the dedicated import paths:
253
+
254
+ ```javascript
255
+ // ✅ For Svelte-only projects using web components
256
+ import { toggleNavigation } from '@gsa-tts/graymatter-ui/utils';
257
+ // Use web components in HTML: <graymatter-button>, <graymatter-logo>, etc.
258
+
259
+ // ❌ Avoid in Svelte-only projects
260
+ import { toggleNavigation } from '@gsa-tts/graymatter-ui';
261
+ ```
262
+
263
+ **Common Error:** `Unexpected token '{'. Expected '.' or '('` when importing from the main package in Svelte-only projects.
264
+
265
+ **Solution:** Use the `/utils` path for utility functions. For UI components, use web components instead of importing Svelte components directly.
266
+
224
267
  ## Browser Support
225
268
 
226
269
  - **Modern Browsers** - Chrome, Firefox, Safari, Edge (latest 2 versions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gsa-tts/graymatter-ui",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -55,8 +55,8 @@
55
55
  "typescript": "5.7.3",
56
56
  "vite": "^6.3.5",
57
57
  "vitest": "^3.0.7",
58
- "@gsa-tts/graymatter-eslint": "0.0.2",
59
58
  "@gsa-tts/graymatter-typescript-config": "0.0.2",
59
+ "@gsa-tts/graymatter-eslint": "0.0.2",
60
60
  "@gsa-tts/graymatter-vitest-config": "0.0.1"
61
61
  },
62
62
  "dependencies": {
@@ -10,6 +10,9 @@ const defaultDescription =
10
10
  'Accelerating trusted AI adoption across government. Three powerful AI tools. Industry-leading models. One integrated platform.';
11
11
  const defaultOgImage = getUrlFromBase('/common/assets/images/og-preview.webp');
12
12
 
13
+ // Use computed variables instead of direct props to avoid Vite 7 import analysis issues
14
+ const pageTitle = title ? `${title} | USAi` : 'USAi';
15
+ const gtmIDValue = gtmID;
13
16
  const ogTitle = title || siteName;
14
17
  const ogDescription = description || defaultDescription;
15
18
  const ogImage = openGraphImage || defaultOgImage;
@@ -18,13 +21,13 @@ const canonicalUrl = new URL(Astro.url.pathname, siteUrl).href;
18
21
  ---
19
22
 
20
23
  <meta name="viewport" content="width=device-width" />
21
- <title>{title}</title>
24
+ <title>{pageTitle}</title>
22
25
  <script is:inline>
23
26
  if ('performance' in window) {
24
27
  performance.mark('usai:documenthead:start');
25
28
  }
26
29
  </script>
27
- {gtmID && <GoogleTagManager {gtmID} />}
30
+ {gtmIDValue && <GoogleTagManager gtmID={gtmIDValue} />}
28
31
  <script is:inline src=`${getUrlFromBase('uswds/js/uswds-init.min.js')}`
29
32
  ></script>
30
33
  <Font cssVariable="--ai-font-family-sans" preload />
@@ -1,3 +1,2 @@
1
- export * from './meta.js';
2
1
  export * from './url.js';
3
2
  export * from './string-formatters.js';
@@ -2,11 +2,7 @@
2
2
  import '../styles/base/global.css';
3
3
  import Head from '../components/Head.astro';
4
4
  import UsaSkipNav from '../components/UsaSkipNav.svelte';
5
- import { getPageTitle } from '../helpers/meta';
6
- import GoogleTagManager from '../components/GoogleTagManager.astro';
7
- const { description, openGraphImage, gtmID } = Astro.props;
8
-
9
- const title = getPageTitle(Astro);
5
+ const { title, description, openGraphImage, gtmID } = Astro.props;
10
6
  ---
11
7
 
12
8
  <!doctype html>
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  import BaseLayout from '@gsa-tts/graymatter-ui/layouts/BaseLayout.astro';
3
3
  import '../styles/base/global.css';
4
- import { getPageTitle } from '@gsa-tts/graymatter-ui/helpers';
5
4
  import DesktopSideNav from '../components/DesktopSideNav.svelte';
6
5
  import DesktopHeader from '../components/DesktopHeader.svelte';
7
6
  import MobileTopNav from '../components/MobileTopNav.svelte';
@@ -1,5 +0,0 @@
1
- import type { AstroGlobal } from 'astro';
2
-
3
- export const getPageTitle = (astro: Pick<AstroGlobal, 'props'>): string => {
4
- return astro.props?.title ? `${astro.props?.title} | USAi` : 'USAi';
5
- };