From: Adam Dullage Date: Wed, 17 Aug 2022 17:46:45 +0000 (+0100) Subject: Redesign search results page X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=c929972f2653ea60f5ffb1d0d85052c19e5168ec;p=flatnotes.git Redesign search results page --- diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 8aabe52..813b5ef 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -10,8 +10,7 @@ import NavBar from "./NavBar"; import NoteViewerEditor from "./NoteViewerEditor"; import RecentlyModified from "./RecentlyModified"; import SearchInput from "./SearchInput"; -import { SearchResult } from "../classes"; -import api from "../api"; +import SearchResults from "./SearchResults"; export default { name: "App", @@ -24,10 +23,22 @@ export default { SearchInput, Logo, NoteViewerEditor, + SearchResults, }, data: function() { - return constants.dataDefaults(); + return { + views: { + login: 0, + home: 1, + note: 2, + search: 3, + }, + currentView: 1, + + noteTitle: null, + searchTerm: null, + }; }, methods: { @@ -50,7 +61,6 @@ export default { else if (basePath == constants.basePaths.search) { this.updateDocumentTitle("Search"); this.searchTerm = helpers.getSearchParam(constants.params.searchTerm); - this.getSearchResults(); this.currentView = this.views.search; } @@ -79,15 +89,12 @@ export default { window.open(href); } else { history.pushState(null, "", href); - this.resetData(); + this.noteTitle = null; + this.searchTerm = null; this.route(); } }, - resetData: function() { - Object.assign(this.$data, constants.dataDefaults()); - }, - updateDocumentTitle: function(suffix) { window.document.title = (suffix ? `${suffix} - ` : "") + "flatnotes"; }, @@ -98,38 +105,6 @@ export default { this.navigate(`/${constants.basePaths.login}`); }, - getSearchResults: function() { - let parent = this; - this.searchFailed = false; - api - .get("/api/search", { params: { term: this.searchTerm } }) - .then(function(response) { - parent.searchResults = []; - if (response.data.length == 0) { - parent.searchFailedIcon = "search"; - parent.searchFailedMessage = "No Results"; - parent.searchFailed = true; - } else { - response.data.forEach(function(result) { - parent.searchResults.push( - new SearchResult( - result.title, - result.lastModified, - result.titleHighlights, - result.contentHighlights - ) - ); - }); - } - }) - .catch(function(error) { - if (!error.handled) { - parent.searchFailed = true; - parent.unhandledServerErrorToast(); - } - }); - }, - newNote: function() { this.navigate(`/${constants.basePaths.new}`); }, @@ -143,11 +118,13 @@ export default { }, focusSearchInput: function() { - document.getElementById("search-input").focus(); + let input = document.getElementById("search-input"); + input.focus(); + input.select(); }, openSearch: function() { - if (this.currentView == this.views.home) { + if ([this.views.home, this.views.search].includes(this.currentView)) { this.focusSearchInput(); EventBus.$emit("highlight-search-input"); } else if (this.currentView != this.views.login) { diff --git a/flatnotes/src/components/App.vue b/flatnotes/src/components/App.vue index fc90a09..9667281 100644 --- a/flatnotes/src/components/App.vue +++ b/flatnotes/src/components/App.vue @@ -11,7 +11,7 @@ - + -
- -
- -
- - -
-
- -

-
-
+
+ +
diff --git a/flatnotes/src/components/LoadingIndicator.vue b/flatnotes/src/components/LoadingIndicator.vue index 00ac052..3919544 100644 --- a/flatnotes/src/components/LoadingIndicator.vue +++ b/flatnotes/src/components/LoadingIndicator.vue @@ -2,7 +2,10 @@
- +

{{ failedMessage }}

@@ -11,6 +14,10 @@ + + diff --git a/flatnotes/src/constants.js b/flatnotes/src/constants.js index 93e2596..92fb975 100644 --- a/flatnotes/src/constants.js +++ b/flatnotes/src/constants.js @@ -8,29 +8,3 @@ export const basePaths = { // Params export const params = { searchTerm: "term", redirect: "redirect" }; - -// Initial State -export const dataDefaults = function() { - return { - // Views - views: { - login: 0, - home: 1, - note: 2, - search: 3, - }, - - // State - currentView: 1, - - // Note Data - noteTitle: null, - - // Search Result Data - searchFailed: false, - searchFailedMessage: "Failed to load Search Results", - searchFailedIcon: null, - searchTerm: null, - searchResults: null, - }; -}; diff --git a/flatnotes/src/index.html b/flatnotes/src/index.html index bb33b64..a15291e 100644 --- a/flatnotes/src/index.html +++ b/flatnotes/src/index.html @@ -20,7 +20,7 @@ - +
diff --git a/flatnotes/src/main.scss b/flatnotes/src/main.scss index 2174eb0..1675c9b 100644 --- a/flatnotes/src/main.scss +++ b/flatnotes/src/main.scss @@ -17,14 +17,11 @@ body { font-family: "Inter", sans-serif; } -.clickable-link { - cursor: pointer; +a { + color: inherit; &:hover { - font-weight: bold; - } - a { text-decoration: none; - color: inherit; + filter: opacity(70%); } } @@ -37,6 +34,10 @@ body { max-width: 500px; } +.search-results-view { + max-width: 700px; +} + .search-input { box-shadow: 0 0 20px $drop-shadow; } @@ -58,5 +59,5 @@ body { } } .bttn:hover { - background-color: $button-background + background-color: $button-background; }