@flxgde/gigamenu 0.6.0 → 0.8.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 CHANGED
@@ -18,21 +18,41 @@ A keyboard-driven command palette menu for Angular applications. Inspired by VS
18
18
  - **Dark mode**: Configurable class name support
19
19
  - **Icon libraries**: Support for emoji and CSS icon classes (FontAwesome, PrimeIcons, etc.)
20
20
  - **Type-safe**: Full TypeScript support with helper functions
21
- - **Tailwind CSS**: Beautiful default styling with dark mode variants
21
+ - **Tailwind CSS**: Beautiful default styling, themeable via CSS variables
22
22
 
23
23
  ## Installation
24
24
 
25
25
  ```bash
26
- npm install gigamenu
26
+ npm install @flxgde/gigamenu
27
27
  ```
28
28
 
29
+ Peer dependencies: `@angular/common`, `@angular/core` and `@angular/router` (19 - 22).
30
+
31
+ ### Styles
32
+
33
+ The component is styled with Tailwind CSS 4 utility classes. Pick one of the following:
34
+
35
+ - **Prebuilt CSS** (no Tailwind needed in your app): add the stylesheet to your global styles, e.g. in `angular.json`
36
+ (`"styles": ["node_modules/@flxgde/gigamenu/styles.css", ...]`) or in a CSS file:
37
+ ```css
38
+ @import "@flxgde/gigamenu/styles.css";
39
+ ```
40
+ - **Tailwind 4 in your app**: let Tailwind scan the package so the utilities are generated by your build:
41
+ ```css
42
+ @import "tailwindcss";
43
+ @source "../node_modules/@flxgde/gigamenu/fesm2022";
44
+ ```
45
+ (adjust the relative path to the location of your CSS file).
46
+
47
+ Colors, radius and dark mode are driven by CSS variables, see [Theming](#theming).
48
+
29
49
  ## Usage
30
50
 
31
51
  ### 1. Import the component
32
52
 
33
53
  ```typescript
34
54
  import { Component, inject, OnInit } from '@angular/core';
35
- import { GigamenuComponent, GigamenuService } from 'gigamenu';
55
+ import { GigamenuComponent, GigamenuService } from '@flxgde/gigamenu';
36
56
 
37
57
  @Component({
38
58
  selector: 'app-root',
@@ -46,6 +66,7 @@ export class App implements OnInit {
46
66
  private readonly gigamenu = inject(GigamenuService);
47
67
 
48
68
  ngOnInit(): void {
69
+ // The router is injected lazily, no setup needed (setRouter() is optional)
49
70
  // Auto-discover routes from Angular Router
50
71
  this.gigamenu.discoverRoutes();
51
72
  }
@@ -76,6 +97,21 @@ this.gigamenu.registerPage({
76
97
  });
77
98
  ```
78
99
 
100
+ Paths may contain a `#fragment` and a `?query` string and can be combined with `:param` placeholders:
101
+
102
+ ```typescript
103
+ this.gigamenu.registerPage({
104
+ id: 'page:select-virtual-scroll',
105
+ label: 'Select: Virtual Scroll',
106
+ path: '/select?tab=api#virtual-scroll',
107
+ });
108
+ ```
109
+
110
+ The path is parsed with `Router.parseUrl()` and navigated with `navigateByUrl()`. Parameter values are URL-encoded.
111
+ To scroll to the fragment, enable anchor scrolling in your router
112
+ (`provideRouter(routes, withInMemoryScrolling({ anchorScrolling: 'enabled' }))`).
113
+ Auto-discovered routes keep working as before.
114
+
79
115
  ### 4. Commands with Parameters
80
116
 
81
117
  Commands can define parameters that are filled in step-by-step:
@@ -192,7 +228,7 @@ Customize the appearance of menu items, empty states, header, footer, or the ent
192
228
 
193
229
  | Method | Description |
194
230
  |--------|-------------|
195
- | `setRouter(router)` | Set the router instance (required for navigation) |
231
+ | `setRouter(router)` | Optional: use a specific router instance (by default the router is injected lazily) |
196
232
  | `open()` | Open the menu |
197
233
  | `close()` | Close the menu |
198
234
  | `toggle()` | Toggle menu visibility |
@@ -206,13 +242,34 @@ Customize the appearance of menu items, empty states, header, footer, or the ent
206
242
 
207
243
  ### Configuration
208
244
 
245
+ ```typescript
246
+ this.gigamenu.configure({ frecency: false, showFooter: false, labels: { footerBrand: '' } });
247
+ ```
248
+
209
249
  ```typescript
210
250
  interface GigamenuConfig {
211
251
  placeholder?: string; // Search input placeholder
212
252
  maxResults?: number; // Maximum items to show (default: 10)
213
253
  autoDiscoverRoutes?: boolean; // Auto-discover on init
214
254
  argSeparator?: string; // Separator between args when passed to action
215
- darkModeClass?: string; // CSS class for dark mode (default: 'dark')
255
+ darkModeClass?: string; // CSS class on <html> that enables dark mode (default: 'dark')
256
+ autocompleteTabBehavior?: 'cycle' | 'accept-first'; // default: 'cycle'
257
+ autocompleteDismiss?: 'on-type' | 'manual'; // default: 'on-type'
258
+ frecency?: boolean; // Usage-based ranking + localStorage persistence (default: true)
259
+ showFooter?: boolean; // Footer with key hints and branding (default: true)
260
+ showCategoryTags?: boolean; // "page" / "command" tag on each item (default: true)
261
+ labels?: GigamenuLabels; // Override built-in texts
262
+ }
263
+
264
+ interface GigamenuLabels { // all optional, defaults in parentheses
265
+ pageBadge?: string; // icon fallback for pages ('P')
266
+ commandBadge?: string; // icon fallback for commands ('C')
267
+ pageTag?: string; // category tag ('page')
268
+ commandTag?: string; // category tag ('command')
269
+ paramHint?: string; // hint next to items with param autocomplete ('Tab')
270
+ footerBrand?: string; // branding in the footer, '' hides it ('gigamenu')
271
+ noResults?: string; // empty state ('No results found')
272
+ navigate?: string; params?: string; next?: string; select?: string; execute?: string; // footer key hints
216
273
  }
217
274
  ```
218
275
 
@@ -324,7 +381,7 @@ Gigamenu uses intelligent ranking based on **frequency** and **recency** of sele
324
381
  - Persists to localStorage for cross-session learning
325
382
  - Auto-prunes low-scoring entries (max 100 terms, 10 items per term)
326
383
 
327
- No configuration needed - it works automatically!
384
+ It works automatically. Set `frecency: false` in the config to disable ranking and persistence entirely (nothing is read from or written to localStorage).
328
385
 
329
386
  ### Parameter Color Coding
330
387
 
@@ -368,12 +425,55 @@ Filled parameter values in the breadcrumb are color-coded:
368
425
 
369
426
  ## Styling
370
427
 
371
- Gigamenu uses Tailwind CSS and supports dark mode. By default, it uses the `dark` class on `<html>`, but this is customizable via the `darkModeClass` configuration option:
428
+ See [Installation > Styles](#styles) for including the CSS.
429
+
430
+ ### Dark mode
431
+
432
+ The panel is dark when `<html>` has the dark mode class (default `dark`, configurable via `darkModeClass`).
433
+ The class is observed, so toggling it at runtime updates the panel. The OS color scheme is not used.
372
434
 
373
435
  ```typescript
374
- this.gigamenu.configure({
375
- darkModeClass: 'dark-theme', // Use your custom class name
376
- });
436
+ this.gigamenu.configure({ darkModeClass: 'dark-theme' });
437
+ ```
438
+
439
+ ### Theming
440
+
441
+ All colors and the radius are CSS custom properties. Set them on `gm-gigamenu` or `:root`; a variable you set applies
442
+ to light **and** dark mode (let your own tokens switch per theme). Unset variables keep the built-in light/dark defaults.
443
+
444
+ | Variable | Used for |
445
+ |----------|----------|
446
+ | `--gm-bg` | Panel background |
447
+ | `--gm-fg` | Primary text |
448
+ | `--gm-fg-muted` | Secondary text (descriptions, footer, ESC key) |
449
+ | `--gm-fg-subtle` | Placeholder, search icon, breadcrumb separators |
450
+ | `--gm-fg-icon` | Icon-class icons and the P/C badge text |
451
+ | `--gm-border` | Panel border and dividers |
452
+ | `--gm-hover-bg` / `--gm-selected-bg` | Hovered / selected item |
453
+ | `--gm-badge-bg` | P/C fallback icon badge |
454
+ | `--gm-kbd-bg` / `--gm-kbd-border` | Key caps and the param hint |
455
+ | `--gm-accent-bg` / `--gm-accent-hover-bg` / `--gm-accent-fg` | Breadcrumb action chip |
456
+ | `--gm-page-bg` / `--gm-page-fg` | "page" tag |
457
+ | `--gm-command-bg` / `--gm-command-fg` | "command" tag |
458
+ | `--gm-param-1` ... `--gm-param-5` | Parameter colors (cycled) |
459
+ | `--gm-radius` | Panel radius (items use this minus 0.25rem). Default `0.75rem` |
460
+ | `--gm-overlay` | Backdrop color. Default `rgb(0 0 0 / 50%)` |
461
+
462
+ Example, mapping to another design system's tokens:
463
+
464
+ ```css
465
+ gm-gigamenu {
466
+ --gm-bg: var(--surface-card);
467
+ --gm-fg: var(--text-color);
468
+ --gm-fg-muted: var(--text-color-secondary);
469
+ --gm-border: var(--surface-border);
470
+ --gm-hover-bg: var(--surface-hover);
471
+ --gm-selected-bg: color-mix(in srgb, var(--primary-color) 12%, transparent);
472
+ --gm-accent-bg: color-mix(in srgb, var(--primary-color) 15%, transparent);
473
+ --gm-accent-fg: var(--primary-color);
474
+ --gm-radius: var(--border-radius);
475
+ --gm-overlay: rgb(0 0 0 / 40%);
476
+ }
377
477
  ```
378
478
 
379
479
  ## Architecture