diff --git a/src/components/UIShell/UIShell.Story.svelte b/src/components/UIShell/UIShell.Story.svelte index c51ae050..2be69076 100644 --- a/src/components/UIShell/UIShell.Story.svelte +++ b/src/components/UIShell/UIShell.Story.svelte @@ -4,7 +4,9 @@ import UIShell from './UIShell.svelte'; import FormTest from './FormTest.svelte'; import SettingsAdjust20 from 'carbon-icons-svelte/lib/SettingsAdjust20'; + // import Binoculars20 from 'carbon-icons-svelte/lib/Binoculars20' import { leftPanelActions, leftPanelTypes } from './constants'; + import searchStore from './searchStore'; const navMenu = [ { @@ -61,13 +63,14 @@ *** actions 'search' and 'switcher' doesnt need to specify type and icon because those are predefined actions in the component. */ + const rightPanel = [ { action: leftPanelActions.search.actionString, type: leftPanelTypes.search, isVisible: true }, - { + { action: 'customsettings', type: leftPanelTypes.component, icon: [ @@ -189,13 +192,35 @@ }, isVisible: true } + // { + // action: 'customsearch', + // type: leftPanelTypes.search, + // icon: [ + // { + // class: undefined, + // skeleton: false, + // render: Binoculars20, + // title: 'binoculars', + // tabIndex: 0, + // focusable: false, + // style: undefined + // } + // ], + // isVisible: true + // } ]; + + function searchInStore(event) { + if (event.detail.action === leftPanelActions.search.actionString) { + searchStore.search(event.detail.textInput); + } + } {#if story === 'with-nav'} {:else if story === 'with-actions'} - + {:else} {/if} diff --git a/src/components/UIShell/UIShell.svelte b/src/components/UIShell/UIShell.svelte index c38e8a63..471da9d7 100644 --- a/src/components/UIShell/UIShell.svelte +++ b/src/components/UIShell/UIShell.svelte @@ -27,6 +27,6 @@ {/if} {#if rightPanel} - + {/if} diff --git a/src/components/UIShell/UIShellRightPanel/ActionComponent.svelte b/src/components/UIShell/UIShellRightPanel/ActionComponent.svelte index 5be913d0..93854289 100644 --- a/src/components/UIShell/UIShellRightPanel/ActionComponent.svelte +++ b/src/components/UIShell/UIShellRightPanel/ActionComponent.svelte @@ -1,14 +1,14 @@ - + diff --git a/src/components/UIShell/UIShellRightPanel/ActionGeneric.svelte b/src/components/UIShell/UIShellRightPanel/ActionGeneric.svelte index 4cebe9f3..679c1be1 100644 --- a/src/components/UIShell/UIShellRightPanel/ActionGeneric.svelte +++ b/src/components/UIShell/UIShellRightPanel/ActionGeneric.svelte @@ -1,11 +1,10 @@ -{#if action === leftPanelActions.switcher.actionString} - -{:else} - -{/if} + {#if linkIsActive} -
+
  • Link diff --git a/src/components/UIShell/UIShellRightPanel/ActionSearch.svelte b/src/components/UIShell/UIShellRightPanel/ActionSearch.svelte index 9b7754b9..7a7f34a1 100644 --- a/src/components/UIShell/UIShellRightPanel/ActionSearch.svelte +++ b/src/components/UIShell/UIShellRightPanel/ActionSearch.svelte @@ -1,17 +1,18 @@ @@ -115,6 +153,8 @@ dispatch('focusInputSearch')} - on:focusout={() => dispatch('focusOutInputSearch')} /> + on:focusout={() => dispatch('focusOutInputSearch')} + on:input={dispatchInputs} />
+{#if showResults} + +{/if} diff --git a/src/components/UIShell/UIShellRightPanel/ActionSearchResult.svelte b/src/components/UIShell/UIShellRightPanel/ActionSearchResult.svelte new file mode 100644 index 00000000..ac3121d1 --- /dev/null +++ b/src/components/UIShell/UIShellRightPanel/ActionSearchResult.svelte @@ -0,0 +1,72 @@ + + + + +{#if index === 0} +
  • + + {searchItem.title}  + → {searchItem.menu} + {searchItem.description} + +
  • +{:else} +
  • (onHover = true)} on:mouseleave={() => (onHover = false)}> + + {searchItem.title}  + → {searchItem.menu} + {searchItem.description} + +
  • +{/if} diff --git a/src/components/UIShell/UIShellRightPanel/UIShellRightPanel.svelte b/src/components/UIShell/UIShellRightPanel/UIShellRightPanel.svelte index 53e5d149..045439f7 100644 --- a/src/components/UIShell/UIShellRightPanel/UIShellRightPanel.svelte +++ b/src/components/UIShell/UIShellRightPanel/UIShellRightPanel.svelte @@ -11,7 +11,11 @@ rightPanel.forEach((item, index) => { orderedRightPanel[index] = undefined; if (item.action) { - if (Object.keys(leftPanelActions).indexOf(item.action.charAt(0).toLowerCase() + item.action.slice(1)) === -1) { + if ( + Object.keys(leftPanelActions).indexOf( + item.action.charAt(0).toLowerCase() + item.action.slice(1) + ) === -1 + ) { orderedRightPanel[customActions] = rightPanel[index]; customActions += 1; } @@ -41,6 +45,6 @@
    {#each orderedRightPanel as action, index} - + {/each}
    diff --git a/src/components/UIShell/searchStore.js b/src/components/UIShell/searchStore.js new file mode 100644 index 00000000..b9d06656 --- /dev/null +++ b/src/components/UIShell/searchStore.js @@ -0,0 +1,58 @@ +import { writable } from 'svelte/store'; + +const data = [ + { + href: '#', + title: 'Test title search 1', + menu: 'Test menu 1', + description: 'This is a description for seach #1' + }, + { + href: '#', + title: 'Changing text to simulate search', + menu: 'Test menu 2', + description: 'This is a description for seach #2' + }, + { + href: '#', + title: 'More testing texts', + menu: 'Test menu 3', + description: 'This is a description for seach #3' + }, + { + href: '#', + title: 'We can find here another test text', + menu: 'Test menu 4', + description: 'This is a description for seach #4' + } +]; + +const globalStore = writable(undefined); + +const store = { + subscribe: globalStore.subscribe, + search: searchString => { + if (searchString.length > 1) { + let resultSearch = []; + + data.forEach(item => { + if (item.title.toLowerCase().includes(searchString.toLowerCase())) { + resultSearch.push(item); + } + }); + + if (resultSearch.length > 0) { + globalStore.set(resultSearch); + } else { + globalStore.set(undefined); + } + } else { + globalStore.set(undefined); + } + }, + clear: () => { + globalStore.set(undefined); + } +}; + +export default store;