Fixes: 1) Replace `ElNotification` with `useNotification` across all components and composables; 2) Add missing semicolons, consistent formatting, and type annotations in multiple files; 3) Resolve non-reactive elements in wishlist and cart state management; Extra: 1) Update i18n translations with new strings for promocodes, balance, authentication, and profile settings; 2) Refactor SCSS styles including variable additions and component-specific tweaks; 3) Remove redundant queries, unused imports, and `storePage.ts` file for cleanup.
265 lines
No EOL
5.4 KiB
Vue
265 lines
No EOL
5.4 KiB
Vue
<template>
|
|
<div class="search">
|
|
<div
|
|
@click="toggleSearch(true)"
|
|
class="search__wrapper"
|
|
:class="[{ active: isSearchActive }]"
|
|
>
|
|
<form class="search__form" @submit.prevent="submitSearch">
|
|
<input
|
|
type="text"
|
|
v-model="query"
|
|
:placeholder="t('fields.search')"
|
|
inputmode="search"
|
|
/>
|
|
<div class="search__tools">
|
|
<button
|
|
type="button"
|
|
@click="clearSearch"
|
|
v-if="query"
|
|
>
|
|
<icon name="gridicons:cross" size="16" />
|
|
</button>
|
|
<div class="search__tools-line" v-if="query"></div>
|
|
<button type="submit">
|
|
<icon name="tabler:search" size="16" />
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<div class="search__results" :class="[{ active: (searchResults && isSearchActive) || loading }]">
|
|
<skeletons-header-search v-if="loading" />
|
|
<div
|
|
class="search__results-inner"
|
|
v-for="(blocks, category) in filteredSearchResults"
|
|
:key="category"
|
|
>
|
|
<div class="search__results-title">
|
|
<p>{{ getBlockTitle(category) }}:</p>
|
|
</div>
|
|
<div
|
|
class="search__item"
|
|
v-for="item in blocks"
|
|
:key="item.uuid"
|
|
@click.stop="goTo(category, item)"
|
|
>
|
|
<div class="search__item-left">
|
|
<icon name="ic:twotone-search" size="18" />
|
|
<p>{{ item.name }}</p>
|
|
</div>
|
|
<icon name="line-md:external-link" size="18" />
|
|
</div>
|
|
</div>
|
|
<div class="search__results-empty" v-if="!hasResults && query && !loading">
|
|
<p>{{ t('header.search.empty') }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<transition name="opacity" mode="out-in">
|
|
<div
|
|
class="search__bg"
|
|
@click="toggleSearch(false)"
|
|
v-if="isSearchActive"
|
|
/>
|
|
</transition>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { useSearchUI } from "@/composables/search";
|
|
|
|
const {t} = useI18n();
|
|
const router = useRouter();
|
|
|
|
const {
|
|
query,
|
|
isSearchActive,
|
|
loading,
|
|
searchResults,
|
|
filteredSearchResults,
|
|
hasResults,
|
|
getBlockTitle,
|
|
clearSearch,
|
|
toggleSearch
|
|
} = useSearchUI();
|
|
|
|
function submitSearch() {
|
|
if (query.value) {
|
|
router.push({
|
|
path: '/search',
|
|
query: { q: query.value }
|
|
})
|
|
|
|
toggleSearch(false);
|
|
}
|
|
}
|
|
|
|
function goTo(category: string, item: any) {
|
|
let path = "/";
|
|
console.log('c', category)
|
|
console.log(item)
|
|
switch (category) {
|
|
case "products":
|
|
path = `/product/${item.slug}`;
|
|
break;
|
|
case "categories":
|
|
path = `/catalog/${item.slug}`;
|
|
break;
|
|
case "brands":
|
|
path = `/brand/${item.uuid}`;
|
|
break;
|
|
case "posts":
|
|
path = "/";
|
|
break;
|
|
}
|
|
|
|
toggleSearch(false);
|
|
router.push(path);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.search {
|
|
width: 100%;
|
|
position: relative;
|
|
z-index: 1;
|
|
height: 45px;
|
|
|
|
&__bg {
|
|
background-color: rgba(0, 0, 0, 0.2);
|
|
height: 100vh;
|
|
left: 0;
|
|
position: fixed;
|
|
top: 0;
|
|
width: 100vw;
|
|
z-index: 1;
|
|
transition: 0.2s;
|
|
}
|
|
|
|
&__wrapper {
|
|
width: 100%;
|
|
background-color: #f7f7f7;
|
|
border-radius: $default_border_radius;
|
|
transition: 0.2s;
|
|
position: relative;
|
|
z-index: 2;
|
|
|
|
&.active {
|
|
background-color: $white;
|
|
box-shadow: 0 0 0 1px #0000000a,0 4px 4px #0000000a,0 20px 40px #00000014;
|
|
}
|
|
|
|
@include hover {
|
|
background-color: $white;
|
|
box-shadow: 0 0 0 1px #0000000a,0 4px 4px #0000000a,0 20px 40px #00000014;
|
|
}
|
|
}
|
|
|
|
&__form {
|
|
width: 100%;
|
|
height: 45px;
|
|
position: relative;
|
|
|
|
& input {
|
|
background-color: transparent;
|
|
width: 100%;
|
|
height: 100%;
|
|
padding-inline: 20px 150px;
|
|
border: 1px solid #dedede;
|
|
border-radius: $default_border_radius;
|
|
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
}
|
|
|
|
&__tools {
|
|
position: absolute;
|
|
right: 20px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
|
|
& button {
|
|
cursor: pointer;
|
|
display: grid;
|
|
place-items: center;
|
|
border-radius: $default_border_radius;
|
|
padding: 5px 12px;
|
|
border: 1px solid $accent;
|
|
background-color: rgba($accent, 0.2);
|
|
transition: 0.2s;
|
|
|
|
font-size: 12px;
|
|
color: $accent;
|
|
|
|
@include hover {
|
|
background-color: rgba($accent, 1);
|
|
color: $white;
|
|
}
|
|
}
|
|
|
|
&-line {
|
|
background-color: $accent;
|
|
height: 15px;
|
|
width: 1px;
|
|
}
|
|
}
|
|
|
|
&__results {
|
|
max-height: 0;
|
|
overflow: auto;
|
|
transition: 0.2s;
|
|
|
|
&.active {
|
|
max-height: 40vh;
|
|
}
|
|
|
|
&-title {
|
|
background-color: rgba($accent, 0.2);
|
|
padding: 7px 20px;
|
|
|
|
font-weight: 600;
|
|
}
|
|
|
|
&-empty {
|
|
padding: 10px 20px;
|
|
font-size: 14px;
|
|
}
|
|
}
|
|
|
|
&__item {
|
|
cursor: pointer;
|
|
padding: 7px 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 30px;
|
|
transition: 0.2s;
|
|
font-size: 14px;
|
|
|
|
@include hover {
|
|
background-color: #efefef;
|
|
}
|
|
|
|
&-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
& p {
|
|
word-break: break-all;
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
-webkit-line-clamp: 1;
|
|
overflow: hidden;
|
|
}
|
|
|
|
& span {
|
|
color: #7c7c7c;
|
|
}
|
|
}
|
|
}
|
|
</style> |