Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Implement the composite search bar for the mobile search header #1875

Merged
merged 8 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/VButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Component
:is="as"
:type="typeRef"
class="flex appearance-none items-center justify-center rounded-sm no-underline ring-offset-1 transition-shadow duration-100 ease-linear focus:outline-none"
class="group flex appearance-none items-center justify-center rounded-sm no-underline ring-offset-1 transition-shadow duration-100 ease-linear focus:outline-none"
:class="[
$style.button,
$style[variant],
Expand Down
2 changes: 1 addition & 1 deletion src/components/VHeader/VHeaderDesktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
: 'border-white'
"
>
<VLogoButton :is-fetching="isFetching" :is-search-route="true" />
<VLogoButton :is-fetching="isFetching" />

<VSearchBar
v-model.trim="searchTerm"
Expand Down
2 changes: 1 addition & 1 deletion src/components/VHeader/VHeaderInternal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineComponent({
name: 'VHeaderInternal',
components: { VHomeLink, VIconButton, VLink, VModal, VPageLinks, WordPress },
setup() {
const menuButtonRef = ref<InstanceType<typeof VIconButton>>(null)
const menuButtonRef = ref<InstanceType<typeof VIconButton> | null>(null)

const { all: allPages, current: currentPage } = usePages(true)
const route = useRoute()
Expand Down
51 changes: 22 additions & 29 deletions src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
<template>
<span class="relative inline-block h-8 w-8">
<VIconButton
size="new-small"
:icon-props="{ iconPath: sourceIcon }"
:button-props="{ variant: 'menu' }"
:aria-label="
areFiltersSelected
? $t('header.aria.menu-notification')
: $t('header.aria.menu')
"
aria-haspopup="dialog"
:aria-expanded="isPressed"
aria-controls="content-settings-modal"
@click="$emit('click')"
/>
<span
v-if="areFiltersSelected"
class="absolute top-[-2px] right-[-2px] h-[8px] w-[8px] rounded bg-pink"
/>
</span>
<VSearchBarButton
:icon-path="sourceIcon"
:aria-label="
areFiltersSelected
? $t('header.aria.menu-notification')
: $t('header.aria.menu')
"
aria-haspopup="dialog"
:aria-expanded="isPressed"
aria-controls="content-settings-modal"
inner-area-classes="bg-white hover:bg-dark-charcoal hover:text-white"
>
<template #notification>
<span
v-if="areFiltersSelected"
class="absolute top-[-2px] right-[-2px] h-[8px] w-[8px] rounded bg-pink"
/>
</template>
</VSearchBarButton>
</template>

<script lang="ts">
import { defineEvent } from '~/types/emits'

import VIconButton from '~/components/VIconButton/VIconButton.vue'
import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'

import sourceIcon from '~/assets/icons/source.svg'

export default {
name: 'VContentSettingsButton',
components: { VIconButton },
components: { VSearchBarButton },
props: {
isPressed: {
type: Boolean,
Expand All @@ -41,12 +37,9 @@ export default {
default: false,
},
},
emits: {
click: defineEvent(),
},
setup() {
return {
sourceIcon,
sourceIcon: sourceIcon as unknown as string,
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<template #trigger="{ visible, a11Props }">
<VContentSettingsButton
:is-pressed="visible"
:are-filters-selected="areFiltersSelected"
v-bind="a11Props"
class="me-2"
/>
</template>
<VTabs
Expand Down Expand Up @@ -111,6 +111,9 @@ export default defineComponent({
const changeSelectedTab = (tab: 'content-settings' | 'filters') => {
selectedTab.value = tab
}

const areFiltersSelected = computed(() => searchStore.isAnyFilterApplied)

const showClearFiltersButton = computed(
() => selectedTab.value === 'filters'
)
Expand Down Expand Up @@ -141,6 +144,7 @@ export default defineComponent({
selectedTab,
changeSelectedTab,

areFiltersSelected,
showClearFiltersButton,
isClearButtonDisabled,
clearFiltersLabel,
Expand Down
Loading