Navigation Search Item v1.0
The <e-navigation-search-item> component is a component that can be used for .
Examples
Examples unavailable.
Source Code
e-navigation-search-item.vue
<script setup lang="ts">
import { computed, ref } from 'vue';
import { first, toLower } from 'lodash-es';
import { EMenuItem } from 'types/menu/EMenuItem';
import EIcon from '../e-icon/e-icon.vue';
export type Props = {
menu: EMenuItem;
isOpened?: boolean;
};
const props = withDefaults(defineProps<Props>(), {
isOpened: false
});
const emit = defineEmits<{
(e: 'toggle'): void;
}>();
const isFocused = ref(false);
const isHighlight = computed(() => {
return first(props.menu?.type) === 'highlight';
});
const searchItemClasses = computed(() => {
return {
highlight: isHighlight.value,
focused: isFocused.value
};
});
const subMenuItems = computed(() => {
return (props.menu?.menuItems ?? []) as EMenuItem[];
});
const searchTranslation = computed(() => {
return toLower(props.menu?.displayText);
});
function clicked() {
isFocused.value = true;
if (subMenuItems.value.length > 0) {
emit('toggle');
}
}
</script>
<template>
<div
class="e-navigation-search-item"
:class="searchItemClasses"
>
<div
v-if="isFocused && $slots.search"
class="e-navigation-search-content"
>
<slot name="search" />
</div>
<button
v-else
class="e-navigation-search-content"
:title="searchTranslation"
type="button"
@click="clicked"
>
<e-icon
:icon="['search.svg']"
title="Search"
/>
<span
class="e-navigation-button-text"
v-text="searchTranslation"
/>
</button>
</div>
</template>
<style scoped lang="scss">
.e-invisible {
opacity: 0;
width: 24px;
}
.e-navigation-search-item {
border: transparent 3px solid;
width: 276px;
border-radius: 15px;
padding: 0 8px;
margin-right: 25px;
user-select: none;
display: flex;
flex-direction: column;
fill: var(--e-foreground);
.e-navigation-search-content {
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
padding: 10px 5px;
border: none;
background-color: transparent;
text-align: left;
.e-navigation-button-text {
color: var(--e-foreground);
font-family: var(--e-navigation-button-font-family);
font-weight: 550;
flex: 1 1;
text-transform: lowercase;
margin-left: 5px;
text-align: left;
}
> span {
font-size: var(--e-navigation-button-font-size);
white-space: nowrap;
}
}
.e-icon {
width: 20px;
max-width: 20px;
max-height: 20px;
}
.e-query-block {
display: flex;
flex-direction: column;
gap: 10px;
padding-top: 10px;
}
&:hover {
cursor: pointer;
background-color: var(--e-navigation-button-hover-color);
transition: ease 0.1s;
}
&.highlight {
background-color: var(--e-accent);
border: var(--e-accent) 2px solid;
&:hover {
background-color: var(--e-accent), 0%;
.e-navigation-search-content {
.e-icon {
fill: var(--e-accent);
}
.e-navigation-button-text {
color: var(--e-accent);
}
}
}
}
&.focused {
padding: 0;
.e-navigation-search-content {
display: block;
padding: 0;
:deep(.e-text-input) {
.e-input {
height: 43px;
}
}
}
}
}
</style>