From a806aa34667183c594d2a7309f5abb5793ca47f2 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Mon, 3 Jul 2023 07:11:06 +0000 Subject: [PATCH] feat: search page UI (wip) --- server/graph/schemas/page.graphql | 25 ++- server/locales/en.json | 3 + ux/src/components/HeaderNav.vue | 52 +++-- ux/src/pages/Search.vue | 330 ++++++++++++++++++++++++++++++ ux/src/router/routes.js | 4 + 5 files changed, 390 insertions(+), 24 deletions(-) create mode 100644 ux/src/pages/Search.vue diff --git a/server/graph/schemas/page.graphql b/server/graph/schemas/page.graphql index fb35dd67..ed083b86 100644 --- a/server/graph/schemas/page.graphql +++ b/server/graph/schemas/page.graphql @@ -15,10 +15,18 @@ extend type Query { ): PageVersion searchPages( + siteId: UUID! query: String! path: String - locale: String - ): PageSearchResponse! + locale: [String] + tags: [String] + editor: String + publishState: PagePublishState + orderBy: PageSearchSort + orderByDirection: OrderByDirection + offset: Int + limit: Int + ): PageSearchResponse pages( limit: Int @@ -28,7 +36,7 @@ extend type Query { locale: String creatorId: Int authorId: Int - ): [PageListItem!]! + ): [PageListItem] pageById( id: UUID! @@ -261,10 +269,13 @@ type PageSearchResponse { } type PageSearchResult { - id: String + id: UUID title: String description: String + icon: String path: String + tags: [String] + updatedAt: Date locale: String } @@ -378,6 +389,12 @@ input PageTocDepthInput { max: Int! } +enum PageSearchSort { + relevancy + title + updated +} + enum PageOrderBy { CREATED ID diff --git a/server/locales/en.json b/server/locales/en.json index 233cb0a4..44fbacd8 100644 --- a/server/locales/en.json +++ b/server/locales/en.json @@ -1752,6 +1752,9 @@ "profile.title": "Profile", "profile.uploadNewAvatar": "Upload New Image", "profile.viewPublicProfile": "View Public Profile", + "search.filters": "Filters", + "search.results": "Search Results", + "search.sortBy": "Sort By", "tags.clearSelection": "Clear Selection", "tags.currentSelection": "Current Selection", "tags.locale": "Locale", diff --git a/ux/src/components/HeaderNav.vue b/ux/src/components/HeaderNav.vue index 0863becf..0cb602fb 100644 --- a/ux/src/components/HeaderNav.vue +++ b/ux/src/components/HeaderNav.vue @@ -31,37 +31,34 @@ q-header.bg-header.text-white.site-header( ) q-input( dark - v-model='state.search' + v-model='siteStore.search' standout='bg-white text-dark' dense rounded ref='searchField' style='width: 100%;' label='Search...' + @keyup.enter='onSearchEnter' + @focus='state.searchKbdShortcutShown = false' + @blur='state.searchKbdShortcutShown = true' ) template(v-slot:prepend) q-icon(name='las la-search') template(v-slot:append) - q-icon.cursor-pointer( - name='las la-times' - @click='state.search=``' - v-if='state.search.length > 0' - :color='$q.dark.isActive ? `blue` : `grey-4`' - ) - q-badge.q-ml-sm( + q-badge.q-mr-sm( + v-if='state.searchKbdShortcutShown' label='Ctrl+K' color='grey-7' outline @click='searchField.focus()' ) - //- q-btn.q-ml-md( - //- flat - //- round - //- dense - //- icon='las la-tags' - //- color='grey' - //- to='/_tags' - //- ) + q-icon.cursor-pointer( + name='las la-times' + size='20px' + @click='siteStore.search=``' + v-if='siteStore.search.length > 0' + color='grey-6' + ) q-toolbar( style='height: 64px;' dark @@ -124,17 +121,18 @@ q-header.bg-header.text-white.site-header( + + diff --git a/ux/src/router/routes.js b/ux/src/router/routes.js index a1bc5121..0f6c0b2c 100644 --- a/ux/src/router/routes.js +++ b/ux/src/router/routes.js @@ -32,6 +32,10 @@ const routes = [ { path: 'groups', component: () => import('src/pages/ProfileGroups.vue') } ] }, + { + path: '/_search', + component: () => import('src/pages/Search.vue') + }, { path: '/_admin', component: () => import('layouts/AdminLayout.vue'),