Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Update recent searches to match updated mockups (#3796)
Dhruv Bhanushali344b04f4ac7c
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vueindex 69414ab26..a6d9bedb6 100644--- a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue+++ b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue@@ -10,7 +10,7 @@aria-label="inputmodal"@close="deactivate">- <div class="flex w-full" :class="{ 'px-2': isRecentSearchesModalOpen }">+ <div class="flex w-full" :class="{ 'px-3': isRecentSearchesModalOpen }"><!-- Form action is a fallback for when JavaScript is disabled. --><formaction="/search"@@ -104,6 +104,7 @@class="mt-4"@select="handleSelect"@clear="handleClear"+ @clear-single="handleClearSingle"/></ClientOnly></VInputModal>@@ -278,6 +279,13 @@ export default defineComponent({ensureFocus(searchInputRef.value)}}+ /* Clear a specific recent search from the store. */+ const handleClearSingle = (idx: number) => {+ searchStore.clearRecentSearch(idx)+ if (searchInputRef.value) {+ ensureFocus(searchInputRef.value)+ }+ }const showRecentSearches = computed(() => isRecentSearchesModalOpen.value && entries.value.length > 0@@ -330,6 +338,7 @@ export default defineComponent({handleKeydown,handleSelect,handleClear,+ handleClearSingle,}},})diff --git a/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue b/frontend/src/components/VHeader/VSearchBar/VSearchBar.vueindex 54fcba7dc..250050b20 100644--- a/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue+++ b/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue@@ -50,6 +50,7 @@:class="recentClasses"@select="handleSelect"@clear="handleClear"+ @clear-single="handleClearSingle"@keydown.tab.native="hideRecentSearches"/></ClientOnly>@@ -227,6 +228,11 @@ export default defineComponent({inputFieldRef.value?.focusInput()searchStore.clearRecentSearches()}+ /* Clear a specific recent search from the store. */+ const handleClearSingle = (idx: number) => {+ inputFieldRef.value?.focusInput()+ searchStore.clearRecentSearch(idx)+ }return {searchBarEl,@@ -247,6 +253,7 @@ export default defineComponent({handleKeydown,handleSelect,handleClear,+ handleClearSingle,}},})diff --git a/frontend/src/components/VModal/VInputModal.vue b/frontend/src/components/VModal/VInputModal.vueindex 3f64834c7..5896dc805 100644--- a/frontend/src/components/VModal/VInputModal.vue+++ b/frontend/src/components/VModal/VInputModal.vue@@ -10,7 +10,7 @@<divref="dialogRef"v-bind="$attrs"- class="flex w-full flex-col px-4 py-4"+ class="flex w-full flex-col px-3 py-4"role="dialog"aria-modal="true"@keydown="onKeyDown"diff --git a/frontend/src/components/VRecentSearches/VRecentSearches.vue b/frontend/src/components/VRecentSearches/VRecentSearches.vueindex 1e7b76d8b..5abcff2df 100644--- a/frontend/src/components/VRecentSearches/VRecentSearches.vue+++ b/frontend/src/components/VRecentSearches/VRecentSearches.vue@@ -1,15 +1,15 @@<template><div- class="flex flex-col gap-1 rounded-sm border bg-white"- :class="bordered ? 'border-dark-charcoal-20 p-4 shadow-el-2' : 'border-tx'"+ class="flex flex-col rounded-sm bg-white"+ :class="{ 'border border-dark-charcoal-20 p-2 shadow-el-2': bordered }"data-testid="recent-searches"><div- class="flex flex-row items-center justify-between py-2"- :class="{ 'pe-2': !bordered }"+ class="flex h-10 flex-row items-center justify-between ps-3"+ :class="{ 'pe-1': !bordered }"><!-- Left margin to align with the text of recent searches. -->- <span class="category mx-2 my-1">+ <span class="category">{{ $t("recentSearches.heading") }}</span><VButton@@ -37,20 +37,36 @@:id="`option-${idx}`":key="idx"role="option"- class="description-regular my-1 rounded-sm border-1.5 p-2 hover:bg-dark-charcoal-10"+ class="group/entry label-regular flex h-10 flex-row items-center gap-2 rounded-sm border-1.5 pe-1 ps-2 hover:bg-dark-charcoal-10":class="idx === selectedIdx ? 'border-pink' : 'border-tx'":aria-selected="idx === selectedIdx"@click="handleClick(idx)">+ <VIcon name="search" />{{ entry }}+ <VIconButton+ variant="transparent-gray"+ :icon-props="{ name: 'close-small' }"+ size="small"+ :label="$t('recentSearches.clearSingle.label', { entry }).toString()"+ class="ms-auto group-hover/entry:flex"+ :class="{ hidden: bordered }"+ @click.stop="handleClearSingle(idx)"+ /></li><!-- eslint-enable --></ul>- <span v-else class="description-regular mx-2 my-3">+ <span+ v-else+ class="description-regular flex h-10 flex-row items-center ps-3"+ :class="{ 'pe-1': !bordered }"+ >{{ $t("recentSearches.none") }}</span>- <span class="caption-regular mx-2 my-3 text-dark-charcoal-70">+ <span+ class="mt-auto p-3 text-sm leading-close text-dark-charcoal-70 lg:leading-snug"+ >{{ $t("recentSearches.disclaimer") }}</span></div>@@ -62,6 +78,8 @@ import { defineComponent, type PropType } from "vue"import { defineEvent } from "~/types/emits"import VButton from "~/components/VButton.vue"+import VIcon from "~/components/VIcon/VIcon.vue"+import VIconButton from "~/components/VIconButton/VIconButton.vue"/*** List the recent searches of the user allowing them to go back to a previous@@ -69,7 +87,7 @@ import VButton from "~/components/VButton.vue"*/export default defineComponent({name: "VRecentSearches",- components: { VButton },+ components: { VIconButton, VIcon, VButton },props: {/*** the list of saved past searches@@ -95,6 +113,7 @@ export default defineComponent({emits: {select: defineEvent<[number]>(),clear: defineEvent(),+ "clear-single": defineEvent<[number]>(),},setup(_, { emit }) {const handleClick = (idx: number) => {@@ -103,10 +122,14 @@ export default defineComponent({const handleClear = () => {emit("clear")}+ const handleClearSingle = (idx: number) => {+ emit("clear-single", idx)+ }return {handleClick,handleClear,+ handleClearSingle,}},})diff --git a/frontend/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx b/frontend/src/components/VRecentSearches/meta/VRecentSearches.stories.mdxindex a5a6c4a10..5a6c5d1ef 100644--- a/frontend/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx+++ b/frontend/src/components/VRecentSearches/meta/VRecentSearches.stories.mdx@@ -18,6 +18,9 @@ import VRecentSearches from "~/components/VRecentSearches/VRecentSearches.vue"clear: {action: "clear",},+ clearSingle: {+ action: "clearSingle",+ },}}/>diff --git a/frontend/src/locales/scripts/en.json5 b/frontend/src/locales/scripts/en.json5index 9ec5b5315..6a79aaab8 100644--- a/frontend/src/locales/scripts/en.json5+++ b/frontend/src/locales/scripts/en.json5@@ -745,6 +745,9 @@text: "Clear",label: "Clear recent searches",},+ clearSingle: {+ label: "Clear recent search '{entry}'",+ },none: "No recent searches to show.",disclaimer: "Openverse does not store your recent searches, this information is kept locally in your browser.",},diff --git a/frontend/src/stores/search.ts b/frontend/src/stores/search.tsindex 6e96e3077..97b2409b0 100644--- a/frontend/src/stores/search.ts+++ b/frontend/src/stores/search.ts@@ -331,6 +331,9 @@ export const useSearchStore = defineStore("search", {clearRecentSearches() {this.recentSearches = []},+ clearRecentSearch(idx: number) {+ this.recentSearches.splice(idx, 1)+ },/*** Initial filters do not include the provider filters. We create the provider filters object* when we fetch the provider data on the Nuxt server initialization.diff --git a/frontend/tailwind.config.ts b/frontend/tailwind.config.tsindex ee79136a8..8f2e8274d 100644--- a/frontend/tailwind.config.ts+++ b/frontend/tailwind.config.ts@@ -212,6 +212,7 @@ export default {relaxed: "1.8",large: "1.7",normal: "1.5",+ close: "1.4",snug: "1.3",tight: "1.2",none: "1.0",