From 5f5390f19de3c05975281a63319f49c85b5a48b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 24 Jan 2025 19:27:29 +0000 Subject: [PATCH] Customizable breadcrumb home --- README.md | 3 ++- src/ninja-header.ts | 33 ++++++++++++++++++++------------- src/ninja-keys.ts | 6 ++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b0e1f6b..77ec236 100644 --- a/README.md +++ b/README.md @@ -146,12 +146,13 @@ Library using flat data structure inside, as in the example above. But you can a | Field | Default | Description | |----------------------|-----------------------------|-------------------------------------------------------------| | placeholder | Type a command or search... | Placeholder for search | +| breadcrumbHome | Home | Text of root breadcrumb item | | disableHotkeys | false | If attribute exist will register all hotkey for all actions | | hideBreadcrumbs | false | Hide breadcrumbs on header if true | | openHotkey | cmd+k,ctrl+k | Open or close shortcut | | navigationUpHotkey | up,shift+tab | Navigation up shortcuts | | navigationDownHotkey | down,tab | Navigation down shortcuts | -| closeHotkey | esc | Close shortcut | +| closeHotkey | esc | Close shortcut | | goBackHotkey | backspace | Go back on one level if has parent menu | | selectHotkey | enter | Select action and execute handler or open submenu | | hotKeysJoinedView | false | If exist/true will display hotkeys inside one element | diff --git a/src/ninja-header.ts b/src/ninja-header.ts index b43b693..47814dd 100644 --- a/src/ninja-header.ts +++ b/src/ninja-header.ts @@ -55,14 +55,14 @@ export class NinjaHeader extends LitElement { } `; - @property() + @property({type: String}) placeholder = ''; @property({type: Boolean}) hideBreadcrumbs = false; - @property() - breadcrumbHome = 'Home'; + @property({type: String}) + breadcrumbHome = ''; @property({type: Array}) breadcrumbs: string[] = []; @@ -84,16 +84,23 @@ export class NinjaHeader extends LitElement { ` ); } - breadcrumbs = html``; + + if(this.breadcrumbHome || itemTemplates.length > 0) { + const breadcrumbHome = this.breadcrumbHome && html` + + `; + + breadcrumbs = html``; + } } return html` diff --git a/src/ninja-keys.ts b/src/ninja-keys.ts index f473dac..1412b6e 100644 --- a/src/ninja-keys.ts +++ b/src/ninja-keys.ts @@ -23,6 +23,11 @@ export class NinjaKeys extends LitElement { */ @property({type: String}) placeholder = 'Type a command or search...'; + /** + * First breadcrumb item + */ + @property({type: String}) breadcrumbHome = 'Home'; + /** * If true will register all hotkey for all actions */ @@ -419,6 +424,7 @@ export class NinjaKeys extends LitElement {