diff --git a/desktop-app/app/components/Addressinput/index.js b/desktop-app/app/components/Addressinput/index.js index 3db7938f..1000e93b 100644 --- a/desktop-app/app/components/Addressinput/index.js +++ b/desktop-app/app/components/Addressinput/index.js @@ -174,10 +174,6 @@ class AddressBar extends React.Component { {this.state.finalUrlResult?.length && this.state.canShowSuggestions ? ( ( -
-
    - {filteredSearchResults?.map( - (eachResult, index) => +
    +
      + {filteredSearchResults?.map((eachResult, index) => { + const favicon = eachResult.pageMeta?.favicons?.[0]; + const title = eachResult.pageMeta?.title; + const url = eachResult.url; + return ( index < 8 && ( -
    • -
      handleUrlChange(eachResult.url, index)}> - {eachResult.url} +
    • +
      handleUrlChange(eachResult.url, index)} + > +
      + {favicon ? ( + { + event.target.style.display = 'none'; + event.target.nextSibling.style.display = 'block'; + }} + /> + ) : ( +
      + +
      + )} +
      + +
      +
      +
      + {title} + {url} +
    • ) - )} + ); + })}
    ); diff --git a/desktop-app/app/components/UrlSearchResults/style.css b/desktop-app/app/components/UrlSearchResults/style.css new file mode 100644 index 00000000..4d928f16 --- /dev/null +++ b/desktop-app/app/components/UrlSearchResults/style.css @@ -0,0 +1,70 @@ +.searchBarSuggestionsContainer { + width: calc(100% + 2px); + max-height: 20em; + position: absolute; + overflow: hidden; + left: -1px; + top: 1.8em; + background: #4b4b4c; + border-radius: 0 0 14px 14px; + border-right: solid 1px #7587ec; + border-bottom: solid 1px #7587ec; + border-left: solid 1px #7587ec; +} + +.searchBarSuggestionsListUl { + padding: 0; + margin: 0; + list-style: none; +} + +.searchBarSuggestionsListItems { + display: flex; + align-items: center; + line-height: 22px; + color: #cacaca; + padding: 0.4em 1em; + cursor: default; +} + +.searchBarSuggestionsActiveListItems { + background: #7587ec; + color: white; +} + +.searchBarSuggestionsListItems:hover { + background: gray; + color: white; +} + +.pageFavIconWrapper { + width: 16px; + height: 16px; +} + +.pageFavIcon { + display: block; + width: 16px; + height: 16px; +} + +.pageDefaultFavIconWrapper { + font-size: 16px; + height: 16px; +} + +.pageTitleAndUrlContainer { + margin-left: 16px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.pageTitle::after { + content: '-'; + margin: 0 8px; +} + +.pageUrl { + font-weight: bold; +} diff --git a/desktop-app/app/reducers/browser.js b/desktop-app/app/reducers/browser.js index 27b7fbd2..50d3022f 100644 --- a/desktop-app/app/reducers/browser.js +++ b/desktop-app/app/reducers/browser.js @@ -361,6 +361,10 @@ export default function browser( updateExistingUrl(action.address); return {...state, address: action.address, currentPageMeta: {}}; case NEW_PAGE_META_FIELD: + updateExistingUrl(state.address, { + name: action.name, + value: action.value, + }); return { ...state, currentPageMeta: { diff --git a/desktop-app/app/services/searchUrlSuggestions/index.js b/desktop-app/app/services/searchUrlSuggestions/index.js index 4e3685c7..13afe642 100644 --- a/desktop-app/app/services/searchUrlSuggestions/index.js +++ b/desktop-app/app/services/searchUrlSuggestions/index.js @@ -28,9 +28,15 @@ const _sortedExistingUrlSearchResult = filteredData => { export const searchUrlUtils = url => { if (url) { - const filteredData = filter(previousSearchResults, eachResult => - eachResult.url.toLowerCase().includes(url) - ); + const filteredData = filter(previousSearchResults, eachResult => { + if (eachResult.pageMeta?.title) { + return ( + eachResult.pageMeta.title.toLowerCase().includes(url) || + eachResult.url.toLowerCase().includes(url) + ); + } + return eachResult.url.toLowerCase().includes(url); + }); const finalResult = _sortedExistingUrlSearchResult(filteredData); return finalResult; } @@ -48,7 +54,7 @@ const normalizeURL = url => { return url; }; -export const updateExistingUrl = url => { +export const updateExistingUrl = (url, pageMeta = null) => { url = normalizeURL(url); if (previousSearchResults?.length) { let updatedSearchResults = [...previousSearchResults]; @@ -60,6 +66,12 @@ export const updateExistingUrl = url => { if (index !== (undefined || -1 || null)) { updatedSearchResults[index].visitedCount = 1 + updatedSearchResults[index].visitedCount; + if (pageMeta) { + updatedSearchResults[index].pageMeta = { + ...updatedSearchResults[index].pageMeta, + [pageMeta.name]: pageMeta.value, + }; + } } else { updatedSearchResults = [ {url, visitedCount: 1}, @@ -75,6 +87,7 @@ export const updateExistingUrl = url => { url, visitedCount: 1, }); + addUrlToSearchResults(addNewUrl); previousSearchResults = addNewUrl; }