Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add VHeaderInternal (#1825)

Olga Bulat5e82520d7ba1
diff --git a/src/assets/icons/menu.svg b/src/assets/icons/menu.svg
new file mode 100644
index 000000000..7de91d45a
--- /dev/null
+++ b/src/assets/icons/menu.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path id="icon" fill-rule="evenodd" clip-rule="evenodd" d="M5 5H19V6.5H5V5ZM5 11.25H19V12.75H5V11.25ZM19 17.5H5V19H19V17.5Z" fill="currentColor"/>
+</svg>
diff --git a/src/components/VFooter/VFooter.vue b/src/components/VFooter/VFooter.vue
index f4a945307..b99606eb9 100644
--- a/src/components/VFooter/VFooter.vue
+++ b/src/components/VFooter/VFooter.vue
@@ -16,7 +16,7 @@
class="text-dark-charcoal"
:href="page.link"
show-external-icon
- >{{ $t(`navigation.${page.id}`) }}</VLink
+ >{{ $t(page.name) }}</VLink
>
</li>
</ul>
diff --git a/src/components/VHeader/VHeaderInternal.vue b/src/components/VHeader/VHeaderInternal.vue
new file mode 100644
index 000000000..411c75327
--- /dev/null
+++ b/src/components/VHeader/VHeaderInternal.vue
@@ -0,0 +1,135 @@
+<template>
+ <header
+ class="main-header z-30 flex h-20 w-full items-stretch justify-between gap-x-2 bg-white py-4 pe-3 ps-6 md:py-4 md:px-7"
+ >
+ <VHomeLink variant="dark" />
+ <nav class="justify-stretch md:justify-stretch hidden ms-auto md:flex">
+ <VPageLinks mode="dark" variant="inline" @close="closeModal" />
+ </nav>
+ <div class="flex md:hidden">
+ <VModal
+ :label="$t('header.aria.menu').toString()"
+ variant="full"
+ mode="dark"
+ modal-content-classes="flex md:hidden"
+ :visible="isModalVisible"
+ @open="openModal"
+ >
+ <template #trigger="{ a11yProps }">
+ <VIconButton
+ ref="menuButtonRef"
+ :icon-props="{ iconPath: menuIcon }"
+ :button-props="{ variant: 'plain' }"
+ :aria-label="$t('header.aria.menu')"
+ v-bind="a11yProps"
+ class="border-tx"
+ size="search-medium"
+ />
+ </template>
+
+ <template #top-bar>
+ <div
+ class="flex h-20 w-full justify-between bg-dark-charcoal py-4 text-white pe-3 ps-6"
+ >
+ <VHomeLink variant="light" />
+ <VIconButton
+ ref="closeButton"
+ :button-props="{ variant: 'plain' }"
+ :icon-props="{ iconPath: closeIcon }"
+ size="search-medium"
+ class="border-tx text-white focus-visible:ring-offset-tx"
+ :aria-label="$t('modal.close')"
+ @click="closeModal"
+ />
+ </div>
+ </template>
+ <template #default>
+ <VPageLinks mode="light" variant="column" @close="closeModal" />
+ <VLink
+ href="https://wordpress.org"
+ class="text-white hover:no-underline focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring focus-visible:ring-pink focus-visible:ring-offset-1 focus-visible:ring-offset-tx"
+ >
+ <i18n
+ tag="p"
+ path="footer.wordpress-affiliation"
+ class="mt-auto flex flex-row items-center text-sm"
+ >
+ <template #wordpress>
+ <WordPress class="aria-hidden text-white" />
+ <span class="sr-only">WordPress</span>
+ </template>
+ </i18n>
+ </VLink>
+ </template>
+ </VModal>
+ </div>
+ </header>
+</template>
+
+<script lang="ts">
+import {
+ defineComponent,
+ inject,
+ ref,
+ useRoute,
+ watch,
+} from '@nuxtjs/composition-api'
+
+import usePages from '~/composables/use-pages'
+
+import { IsMinScreenMdKey } from '~/types/provides'
+
+import VHomeLink from '~/components/VHeader/VHomeLink.vue'
+import VIconButton from '~/components/VIconButton/VIconButton.vue'
+import VLink from '~/components/VLink.vue'
+import VPageLinks from '~/components/VHeader/VPageLinks.vue'
+import VModal from '~/components/VModal/VModal.vue'
+
+import closeIcon from '~/assets/icons/close.svg'
+import menuIcon from '~/assets/icons/menu.svg'
+import WordPress from '~/assets/wordpress.svg?inline'
+
+export default defineComponent({
+ name: 'VHeaderInternal',
+ components: { VHomeLink, VIconButton, VLink, VModal, VPageLinks, WordPress },
+ setup() {
+ const menuButtonRef = ref<InstanceType<typeof VIconButton>>(null)
+
+ const { all: allPages, current: currentPage } = usePages(true)
+ const route = useRoute()
+
+ const isMinScreenMd = inject(IsMinScreenMdKey)
+
+ const isModalVisible = ref(false)
+ const closeModal = () => (isModalVisible.value = false)
+ const openModal = () => (isModalVisible.value = true)
+
+ // When clicking on an internal link in the modal, close the modal
+ watch(route, () => {
+ if (isModalVisible.value) {
+ closeModal()
+ }
+ })
+
+ watch(isMinScreenMd, (isMd) => {
+ if (isMd && isModalVisible.value) {
+ closeModal()
+ }
+ })
+
+ return {
+ menuButtonRef,
+
+ closeIcon,
+ menuIcon,
+
+ allPages,
+ currentPage,
+
+ isModalVisible,
+ closeModal,
+ openModal,
+ }
+ },
+})
+</script>
diff --git a/src/components/VHeader/VHomeLink.vue b/src/components/VHeader/VHomeLink.vue
new file mode 100644
index 000000000..b4c58e5cf
--- /dev/null
+++ b/src/components/VHeader/VHomeLink.vue
@@ -0,0 +1,36 @@
+<template>
+ <VLink
+ href="/"
+ class="flex items-stretch rounded-sm focus-visible:outline-none focus-visible:ring focus-visible:ring-pink focus-visible:ring-offset-1 focus-visible:ring-offset-tx"
+ :class="variant === 'dark' ? 'text-dark-charcoal' : 'text-white'"
+ >
+ <VBrand :is-fetching="false" :sr-text="$t('header.home-link').toString()" />
+ </VLink>
+</template>
+
+<script lang="ts">
+import { type PropType, defineComponent } from '@nuxtjs/composition-api'
+
+import VBrand from '~/components/VBrand/VBrand.vue'
+import VLink from '~/components/VLink.vue'
+
+export default defineComponent({
+ name: 'VHomeLink',
+ components: {
+ VBrand,
+ VLink,
+ },
+ props: {
+ /**
+ * In `light` mode, the links are white and the background is dark charcoal.
+ * In `dark` mode, the links are dark charcoal and the background is transparent.
+ *
+ * @default 'light'
+ */
+ variant: {
+ type: String as PropType<'light' | 'dark'>,
+ default: 'light',
+ },
+ },
+})
+</script>
diff --git a/src/components/VHeader/VPageLinks.vue b/src/components/VHeader/VPageLinks.vue
new file mode 100644
index 000000000..5f4854ea1
--- /dev/null
+++ b/src/components/VHeader/VPageLinks.vue
@@ -0,0 +1,87 @@
+<template>
+ <ul
+ class="flex"
+ :class="[
+ mode === 'dark' ? 'text-dark-charcoal' : 'bg-dark-charcoal text-white',
+ variant === 'inline'
+ ? 'flex-row items-center gap-8 text-sm'
+ : 'mt-3 flex-col items-end',
+ ]"
+ >
+ <li
+ v-for="page in allPages"
+ :key="page.id"
+ :class="{ 'heading-5': variant === 'column' }"
+ >
+ <VLink
+ class="rounded-sm py-3 focus-visible:outline-none focus-visible:ring focus-visible:ring-pink focus-visible:ring-offset-1 focus-visible:ring-offset-tx"
+ :class="[
+ { 'font-bold': currentPage === page.id },
+ mode === 'dark' ? 'text-dark-charcoal' : 'text-white',
+ variant === 'inline' ? '' : 'ps-3',
+ ]"
+ :href="page.link"
+ show-external-icon
+ @click="onClick(page.link)"
+ >{{ $t(page.name) }}</VLink
+ >
+ </li>
+ </ul>
+</template>
+
+<script lang="ts">
+import {
+ type PropType,
+ defineComponent,
+ useRoute,
+} from '@nuxtjs/composition-api'
+
+import usePages from '~/composables/use-pages'
+
+import VLink from '~/components/VLink.vue'
+
+export default defineComponent({
+ name: 'VPageLinks',
+ components: {
+ VLink,
+ },
+ props: {
+ /**
+ * In `light` mode, the links are white and the background is dark charcoal.
+ * In `dark` mode (in the modal), the links are dark charcoal and the background is transparent.
+ *
+ * @default 'light'
+ */
+ mode: {
+ type: String as PropType<'light' | 'dark'>,
+ default: 'light',
+ },
+ /**
+ * In `inline` mode, the links are displayed horizontally. It is used in the desktop header.
+ * In `column` mode, the links are displayed vertically. It is used in the mobile modal.
+ *
+ * @default 'inline'
+ */
+ variant: {
+ type: String as PropType<'inline' | 'column'>,
+ default: 'inline',
+ },
+ },
+ setup(_, { emit }) {
+ const { all: allPages, current: currentPage } = usePages(true)
+ const route = useRoute()
+
+ const onClick = (link: string) => {
+ if (link === route.value.path) {
+ emit('close')
+ }
+ }
+
+ return {
+ allPages,
+ currentPage,
+ onClick,
+ }
+ },
+})
+</script>
diff --git a/src/components/VHeader/meta/VHeaderInternal.stories.mdx b/src/components/VHeader/meta/VHeaderInternal.stories.mdx
new file mode 100644
index 000000000..2d4a51cb4
--- /dev/null
+++ b/src/components/VHeader/meta/VHeaderInternal.stories.mdx
@@ -0,0 +1,23 @@
+import { Canvas, Description, Meta, Story } from '@storybook/addon-docs'
+import VHeaderInternal from '~/components/VHeader/VHeaderInternal.vue'
+import VModalTarget from '~/components/VModal/VModalTarget.vue'
+
+<Meta title="Components/VHeader/VHeaderInternal" component={VHeaderInternal} />
+
+export const Template = (args) => ({
+ template: `<div class="fixed inset-0 w-full h-full"><VHeaderInternal v-bind="args" v-on="args" /><VModalTarget /></div>`,
+ components: { VHeaderInternal, VModalTarget },
+ setup() {
+ return { args }
+ },
+})
+
+# VHeaderInternal
+
+<Description of={VHeaderInternal} />
+
+The header component used on non-search pages. Fixed on scroll. Has links to the internal pages.
+
+<Canvas>
+ <Story name="Default">{Template.bind({})}</Story>
+</Canvas>
diff --git a/src/components/VIconButton/VIconButton.vue b/src/components/VIconButton/VIconButton.vue
index d2e371f58..ac9a14d5c 100644
--- a/src/components/VIconButton/VIconButton.vue
+++ b/src/components/VIconButton/VIconButton.vue
@@ -25,22 +25,22 @@ import VButton, { ButtonProps } from '~/components/VButton.vue'
import type { ButtonType } from '~/components/VButton.vue'
const SIZE_MAP = Object.freeze({
- tiny: { icon: ['w-6', 'h-6'], button: ['w-6', 'h-6'] },
- small: { icon: ['w-6', 'h-6'], button: ['w-10', 'h-10'] },
+ tiny: { icon: 'w-6 h-6', button: 'w-6 h-6' },
+ small: { icon: 'w-6 h-6', button: 'w-10 h-10' },
// TODO: audit the sizes after new header is done.
'new-small': { icon: 'w-4 h-4', button: 'w-8 h-8' },
'search-small': {
- icon: ['w-6', 'h-6'],
- button: ['w-10', 'md:w-12', 'h-10', 'md:h-12'],
+ icon: 'w-6 h-6',
+ button: 'w-10 md:w-12 h-10 md:h-12',
},
- 'search-medium': { icon: ['w-6', 'h-6'], button: ['w-12', 'h-12'] },
- 'search-large': { icon: ['w-6', 'h-6'], button: ['w-14', 'h-14'] },
+ 'search-medium': { icon: 'w-6 h-6', button: 'w-12 h-12' },
+ 'search-large': { icon: 'w-6 h-6', button: 'w-14 h-14' },
'search-standalone': {
- icon: ['w-6', 'h-6'],
- button: ['w-14', 'md:w-[69px]', 'h-14', 'md:h-[69px]'],
+ icon: 'w-6 h-6',
+ button: 'w-14 md:w-[69px] h-14 md:h-[69px]',
},
- medium: { icon: ['w-8', 'h-8'], button: ['w-14', 'h-14'] },
- large: { icon: ['w-12', 'h-12'], button: ['w-20', 'h-20'] },
+ medium: { icon: 'w-8 h-8', button: 'w-14 h-14' },
+ large: { icon: 'w-12 h-12', button: 'w-20 h-20' },
} as const)
type Size = keyof typeof SIZE_MAP
diff --git a/src/components/VModal/VModal.vue b/src/components/VModal/VModal.vue
index 249c3fc29..d0dd3908c 100644
--- a/src/components/VModal/VModal.vue
+++ b/src/components/VModal/VModal.vue
@@ -10,11 +10,11 @@
<slot
name="trigger"
:a11y-props="triggerA11yProps"
- :visible="visibleRef"
+ :visible="internalVisibleRef"
/>
</div>
<VModalContent
- :visible="visibleRef"
+ :visible="internalVisibleRef"
:trigger-element="triggerRef"
:hide-on-esc="hideOnEsc"
:hide-on-click-outside="hideOnClickOutside"
@@ -24,7 +24,13 @@
:aria-label="label"
:aria-labelledby="labelledBy"
:initial-focus-element="initialFocusElement"
+ :variant="variant"
+ :mode="mode"
+ :content-classes="modalContentClasses"
>
+ <template #top-bar>
+ <slot name="top-bar" />
+ </template>
<slot name="default" />
</VModalContent>
</div>
@@ -37,6 +43,7 @@ import {
watch,
reactive,
computed,
+ toRef,
} from '@nuxtjs/composition-api'
import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
@@ -104,6 +111,49 @@ export default defineComponent({
),
default: undefined,
},
+ /**
+ * The variant of the modal content.
+ * The `default` variant is a full-screen modal on mobile widths, and is a smaller mobile
+ * on a grayed out backdrop on larger screens.
+ *
+ * The `full` variant is a full-screen modal on all screen widths. It is currently
+ * only used for mobile version of the `VHeaderInternal` component.
+ *
+ * @default 'default'
+ */
+ variant: {
+ type: /** @type {import('@nuxtjs/composition-api').PropType<'default' | 'full'>} */ (
+ String
+ ),
+ default: 'default',
+ },
+ /**
+ * The color mode of the modal content.
+ * The default `light` mode uses dark charcoal content on the white background.
+ * The `dark` mode uses white content on the dark charcoal background.
+ *
+ * @default 'light'
+ */
+ mode: {
+ type: /** @type {import('@nuxtjs/composition-api').PropType<'dark' | 'light'>} */ (
+ String
+ ),
+ default: 'light',
+ },
+ /**
+ * This props allows for the modal to be opened or closed programmatically.
+ * The modal handles the visibility internally if this prop is not provided.
+ *
+ * @default undefined
+ */
+ visible: {
+ type: Boolean,
+ default: undefined,
+ },
+ modalContentClasses: {
+ type: String,
+ default: '',
+ },
},
emits: [
/**
@@ -115,8 +165,12 @@ export default defineComponent({
*/
'close',
],
- setup(_, { emit }) {
- const visibleRef = ref(false)
+ setup(props, { emit }) {
+ const visibleRef = toRef(props, 'visible')
+ const internalVisibleRef =
+ /** @type {import('@nuxtjs/composition-api').Ref<boolean>} */ (
+ ref(props.visible === undefined ? false : props.visible)
+ )
const nodeRef = ref()
/** @type {import('@nuxtjs/composition-api').Ref<HTMLElement | undefined>} */
@@ -127,28 +181,49 @@ export default defineComponent({
'aria-haspopup': 'dialog',
})
- const triggerRef = computed(() => triggerContainerRef.value?.firstChild)
+ const triggerRef = computed(
+ () =>
+ /** @type {HTMLElement | undefined} */ (
+ triggerContainerRef.value?.firstChild
+ )
+ )
- watch(visibleRef, (visible) => {
+ watch(internalVisibleRef, (visible) => {
triggerA11yProps['aria-expanded'] = !!visible
})
+ /**
+ * When the `visible` prop is set to a different value than internalVisibleRef,
+ * we update the internalVisibleRef to match the prop.
+ */
+ watch(visibleRef, (visible) => {
+ if (visible === undefined || visible === internalVisibleRef.value) return
+
+ if (visible) {
+ open()
+ } else {
+ close()
+ }
+ })
+
const { lock, unlock } = useBodyScrollLock({ nodeRef })
const open = () => {
- visibleRef.value = true
- emit('open')
+ internalVisibleRef.value = true
lock()
+ if (props.visible !== internalVisibleRef.value) {
+ emit('open')
+ }
}
const close = () => {
- visibleRef.value = false
- emit('close')
+ internalVisibleRef.value = false
unlock()
+ emit('close')
}
const onTriggerClick = () => {
- if (visibleRef.value === true) {
+ if (internalVisibleRef.value === true) {
close()
} else {
open()
@@ -157,10 +232,11 @@ export default defineComponent({
return {
nodeRef,
- visibleRef,
- close,
+ internalVisibleRef,
triggerContainerRef,
triggerRef,
+
+ close,
onTriggerClick,
triggerA11yProps,
}
diff --git a/src/components/VModal/VModalContent.vue b/src/components/VModal/VModalContent.vue
index ed37ff27b..19a3cbae8 100644
--- a/src/components/VModal/VModalContent.vue
+++ b/src/components/VModal/VModalContent.vue
@@ -4,11 +4,17 @@
<FocusTrap :initial-focus="() => false" :escape-deactivates="!hideOnEsc">
<div
class="fixed inset-0 z-40 flex min-h-screen justify-center overflow-y-auto bg-dark-charcoal bg-opacity-75"
+ :class="[
+ $style[`modal-backdrop-${variant}`],
+ $style[`modal-backdrop-${mode}`],
+ contentClasses,
+ ]"
>
<div
ref="dialogRef"
v-bind="$attrs"
- class="flex w-full flex-col md:max-w-[768px] lg:w-[768px] xl:w-[1024px] xl:max-w-[1024px]"
+ class="flex w-full flex-col"
+ :class="[$style[`modal-${variant}`], $style[`modal-${mode}`]]"
role="dialog"
aria-modal="true"
v-on="$listeners"
@@ -24,6 +30,7 @@
-->
<div
class="flex w-full shrink-0 justify-between bg-white py-4 pe-3 ps-4 md:justify-end md:bg-tx md:px-0 md:py-3"
+ :class="[$style[`top-bar-${variant}`], $style[`top-bar-${mode}`]]"
>
<VLogoButtonOld
class="md:hidden"
@@ -45,7 +52,11 @@
</slot>
<div
- class="w-full flex-grow bg-white text-left align-bottom md:rounded-t-md"
+ class="w-full flex-grow text-left align-bottom md:rounded-t-md"
+ :class="[
+ $style[`modal-content-${variant}`],
+ $style[`modal-content-${mode}`],
+ ]"
>
<slot />
</div>
@@ -113,6 +124,26 @@ export default defineComponent({
),
required: false,
},
+ variant: {
+ type: /** @type {import('@nuxtjs/composition-api').PropType<'default' | 'full'>} */ (
+ String
+ ),
+ default: 'default',
+ },
+ mode: {
+ type: /** @type {import('@nuxtjs/composition-api').PropType<'dark' | 'light'>} */ (
+ String
+ ),
+ default: 'light',
+ },
+ /**
+ * The tailwind classes to apply to the modal backdrop element.
+ * Can be used to make the modal hidden on some breakpoint.
+ */
+ contentClasses: {
+ type: String,
+ default: '',
+ },
},
setup(props, { emit, attrs }) {
if (!attrs['aria-label'] && !attrs['aria-labelledby']) {
@@ -149,4 +180,29 @@ export default defineComponent({
})
</script>
-<style module></style>
+<style module>
+.top-bar-default {
+ @apply flex w-full shrink-0 justify-between bg-white py-4 pe-3 ps-4 md:justify-end md:bg-tx md:px-0 md:py-3;
+}
+.top-bar-full {
+ @apply flex h-20 w-full shrink-0 justify-between bg-dark-charcoal px-4 py-3 md:items-stretch md:justify-start md:py-4 md:px-7;
+}
+.modal-default {
+ @apply md:max-w-[768px] lg:w-[768px] xl:w-[1024px] xl:max-w-[1024px];
+}
+.modal-dark {
+ @apply bg-dark-charcoal text-white;
+}
+.modal-light {
+ @apply bg-white text-dark-charcoal;
+}
+.modal-content-full {
+ @apply flex w-full flex-col justify-between px-6 pb-10;
+}
+.modal-content-dark {
+ @apply bg-dark-charcoal text-white;
+}
+.modal-content-light {
+ @apply bg-white text-dark-charcoal;
+}
+</style>
diff --git a/src/composables/use-pages.ts b/src/composables/use-pages.ts
index 70417fb83..3bf224b74 100644
--- a/src/composables/use-pages.ts
+++ b/src/composables/use-pages.ts
@@ -7,26 +7,32 @@ export default function usePages(isNew = false) {
? [
{
id: 'about',
+ name: 'navigation.about',
link: app.localePath('/about'),
},
{
id: 'licenses',
+ name: 'navigation.licenses',
link: 'https://creativecommons.org/about/cclicenses/',
},
{
id: 'get-involved',
+ name: 'navigation.get-involved',
link: 'https://github.com/WordPress/openverse/',
},
{
id: 'api',
+ name: 'navigation.api',
link: 'https://api.openverse.engineering/v1/',
},
{
id: 'privacy',
+ name: 'navigation.privacy',
link: 'https://wordpress.org/privacy',
},
{
id: 'feedback',
+ name: 'navigation.feedback',
link: app.localePath('/feedback'),
},
]
@@ -74,7 +80,11 @@ export default function usePages(isNew = false) {
]
const route = useRoute()
- const currentPageId = computed(() => route.value.name)
+ /**
+ * The route name of the current page is localized, so it looks like `index__en`.
+ * We need to remove the locale suffix to match the page id.
+ */
+ const currentPageId = computed(() => route.value?.name?.split('__')[0])
return { all: pages, current: currentPageId }
}
diff --git a/src/layouts/default.vue b/src/layouts/default.vue
index 28e0540e1..d8e72b4c1 100644
--- a/src/layouts/default.vue
+++ b/src/layouts/default.vue
@@ -4,12 +4,15 @@
<VTeleportTarget name="skip-to-content" :force-destroy="true" />
<VMigrationNotice />
<VTranslationStatusBanner />
- <VHeader v-if="isNewHeaderEnabled" />
+ <template v-if="isNewHeaderEnabled">
+ <VHeader v-if="isSearchRoute" />
+ <VHeaderInternal v-else />
+ </template>
<VHeaderOld v-else />
</div>
<main
- class="main embedded w-screen flex-shrink-0 flex-grow md:w-full"
+ class="main embedded w-full flex-shrink-0 flex-grow md:w-full"
:class="[
{ 'has-sidebar': isSidebarVisible },
isNewHeaderEnabled ? 'new-layout' : 'old-layout',
@@ -41,7 +44,11 @@ import { isMinScreen } from '~/composables/use-media-query'
import { useFilterSidebarVisibility } from '~/composables/use-filter-sidebar-visibility'
import { useFeatureFlagStore } from '~/stores/feature-flag'
-import { IsMinScreenLgKey, IsMinScreenMdKey } from '~/types/provides'
+import {
+ IsHeaderScrolledKey,
+ IsMinScreenLgKey,
+ IsMinScreenMdKey,
+} from '~/types/provides'
import VMigrationNotice from '~/components/VMigrationNotice.vue'
import VTranslationStatusBanner from '~/components/VTranslationStatusBanner.vue'
@@ -57,6 +64,7 @@ const embeddedPage = {
VMigrationNotice,
VTranslationStatusBanner,
VHeaderOld,
+ VHeaderInternal: () => import('~/components/VHeader/VHeaderInternal.vue'),
VHeader: () => import('~/components/VHeader/VHeader.vue'),
VFooter,
VModalTarget,
@@ -97,6 +105,7 @@ const embeddedPage = {
provide('isMinScreenMd', isMinScreenMd)
provide(IsMinScreenMdKey, isMinScreenMd)
provide(IsMinScreenLgKey, isMinScreenLg)
+ provide(IsHeaderScrolledKey, isHeaderScrolled)
// TODO: remove `headerHasTwoRows` provide after the new header is enabled.
const headerHasTwoRows = computed(
diff --git a/src/locales/en.json b/src/locales/en.json
index 38dff30b7..5e27a6cd4 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -66,7 +66,10 @@
"get-involved": "Get involved",
"api": "API",
"privacy": "Privacy",
- "feedback": "Feedback"
+ "feedback": "Feedback",
+ "sources": "Sources",
+ "external-sources": "External sources",
+ "search-help": "Search help"
},
"about": {
"title": "About {openverse}",
@@ -77,8 +80,9 @@
"content": "{openverse} searches across more than 300 million images from open APIs and the {common-crawl} dataset. It goes beyond simple search to aggregate results across multiple public repositories into a single catalog, and facilitates reuse through features like machine-generated tags and one-click attribution."
},
"planning": {
- "content": "Currently {openverse} only searches images, with search for audio and video provided through {meta}. But we plan to add additional media types such as open texts and audio, with the ultimate goal of providing access to all 1.4 billion CC licensed and public domain works on the web. All of our code is open source ({search}, {api}, {catalog}) and we {community}. You can see what {working}.",
+ "content": "Currently {openverse} only searches images, with search for audio and video provided through {meta}. But we plan to add additional media types such as open texts and audio, with the ultimate goal of providing access to all 1.4 billion CC licensed and public domain works on the web. All of our code is open source ({frontend}, {api}, {catalog}) and we {community}. You can see what {working}.",
"meta": "Meta Search",
+ "frontend": "{openverse} frontend",
"api": "{openverse} API",
"catalog": "{openverse} Catalog",
"community": "welcome community contribution",
diff --git a/src/pages/about.vue b/src/pages/about.vue
index de2adcd2e..76e082baf 100644
--- a/src/pages/about.vue
+++ b/src/pages/about.vue
@@ -19,9 +19,9 @@
<template #meta>
<VLink href="/meta-search">{{ $t('about.planning.meta') }}</VLink>
</template>
- <template #search>
+ <template #frontend>
<VLink href="https://github.com/wordpress/openverse-frontend/">{{
- $t('about.planning.meta')
+ $t('about.planning.frontend', { openverse: 'Openverse' })
}}</VLink>
</template>
<template #api>
diff --git a/test/locales/ar.json b/test/locales/ar.json
index c0a9ba9a6..efa7896ec 100644
--- a/test/locales/ar.json
+++ b/test/locales/ar.json
@@ -675,5 +675,16 @@
"search": {
"placeholder": "البحث عن محتوى"
}
+ },
+ "navigation": {
+ "about": "حول",
+ "licenses": "التراخيص",
+ "get-involved": "شارك",
+ "api": "API",
+ "privacy": "خصوصية",
+ "feedback": "استجابة",
+ "sources": "مصادر",
+ "external-sources": "مصادر خارجية",
+ "search-help": "بحث في المساعدة"
}
}
diff --git a/test/playwright/e2e/header-internal.spec.ts b/test/playwright/e2e/header-internal.spec.ts
new file mode 100644
index 000000000..cb8b82134
--- /dev/null
+++ b/test/playwright/e2e/header-internal.spec.ts
@@ -0,0 +1,59 @@
+import { test, expect } from '@playwright/test'
+
+import {
+ enableNewHeader,
+ scrollToBottom,
+ t,
+} from '~~/test/playwright/utils/navigation'
+
+test.use({
+ viewport: { width: 640, height: 600 },
+})
+
+test.skip('can open and close the modal on md breakpoint', async ({ page }) => {
+ await enableNewHeader(page)
+
+ await page.goto('/about')
+ const menuAriaLabel = t('header.aria.menu')
+
+ await page.locator(`[aria-label="${menuAriaLabel}"]`).click()
+ await expect(page.locator('[role="dialog"]')).toBeVisible()
+ await expect(
+ page.locator('div[role="dialog"] >> [aria-current="page"]')
+ ).toBeVisible()
+ await expect(
+ page.locator('div[role="dialog"] >> [aria-current="page"]')
+ ).toHaveText('About')
+
+ await page.locator('div[role="dialog"] >> [aria-label="Close"]').click()
+ await expect(page.locator(`[aria-label="${menuAriaLabel}"]`)).toBeVisible()
+})
+
+test.skip('the modal locks the scroll on md breakpoint', async ({ page }) => {
+ await enableNewHeader(page)
+
+ await page.goto('/about')
+ const menuAriaLabel = t('header.aria.menu')
+
+ await scrollToBottom(page)
+ await page.locator(`[aria-label="${menuAriaLabel}"]`).click()
+ await page.locator('div[role="dialog"] >> [aria-label="Close"]').click()
+
+ const scrollPosition = await page.evaluate(() => window.scrollY)
+ expect(scrollPosition).toBeGreaterThan(100)
+})
+
+test("the modal opens an external link in a new window and it doesn't close the modal", async ({
+ page,
+}) => {
+ await enableNewHeader(page)
+
+ await page.goto('/about')
+ const menuAriaLabel = t('header.aria.menu')
+
+ await scrollToBottom(page)
+ await page.locator(`[aria-label="${menuAriaLabel}"]`).click()
+ await page.locator('div[role="dialog"] >> text=API').click()
+
+ await expect(page.locator('[role="dialog"]')).toBeVisible()
+})
diff --git a/test/playwright/utils/navigation.ts b/test/playwright/utils/navigation.ts
index c754e8566..49cbbbf3d 100644
--- a/test/playwright/utils/navigation.ts
+++ b/test/playwright/utils/navigation.ts
@@ -342,3 +342,12 @@ export const pathWithDir = (rawPath: string, dir: string) => {
const path = rawPath.startsWith('/') ? rawPath : `/${rawPath}`
return dir === 'rtl' ? `/ar${path}` : path
}
+
+export const enableNewHeader = async (page: Page) => {
+ await page.goto('/preferences')
+ const newHeaderCheckboxLocator = 'input#new_header'
+
+ if (!(await page.locator(newHeaderCheckboxLocator).isChecked())) {
+ await page.click(newHeaderCheckboxLocator)
+ }
+}
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts b/test/storybook/visual-regression/v-header-internal.spec.ts
new file mode 100644
index 000000000..6ba6ff447
--- /dev/null
+++ b/test/storybook/visual-regression/v-header-internal.spec.ts
@@ -0,0 +1,40 @@
+import { test } from '@playwright/test'
+
+import breakpoints from '~~/test/playwright/utils/breakpoints'
+import { languageDirections } from '~~/test/playwright/utils/navigation'
+
+const headerSelector = '.main-header'
+const defaultUrl =
+ '/iframe.html?id=components-vheader-vheaderinternal--default-story'
+const pageUrl = (dir: typeof languageDirections[number]) =>
+ dir === 'ltr' ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`
+
+test.describe('VHeaderInternal', () => {
+ for (const dir of languageDirections) {
+ breakpoints.describeEachDesktop(({ expectSnapshot }) => {
+ test(`desktop-header-internal-${dir}`, async ({ page }) => {
+ await page.goto(pageUrl(dir))
+ await page.mouse.move(0, 150)
+ await expectSnapshot(
+ `desktop-header-internal-${dir}`,
+ page.locator(headerSelector)
+ )
+ })
+ })
+ breakpoints.describeEachMobile(({ expectSnapshot }) => {
+ test(`mobile-header-internal-${dir}`, async ({ page }) => {
+ await page.goto(pageUrl(dir))
+ await page.mouse.move(0, 150)
+ await expectSnapshot(
+ `mobile-header-internal-${dir}`,
+ page.locator(headerSelector)
+ )
+ })
+ test(`mobile-header-internal-modal-${dir}`, async ({ page }) => {
+ await page.goto(pageUrl(dir))
+ await page.locator('button[aria-haspopup="dialog"]').click()
+ await expectSnapshot(`mobile-header-internal-modal-${dir}`, page)
+ })
+ })
+ }
+})
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-2xl-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-2xl-linux.png
new file mode 100644
index 000000000..4df227b71
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-2xl-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-lg-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-lg-linux.png
new file mode 100644
index 000000000..96012008d
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-lg-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-md-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-md-linux.png
new file mode 100644
index 000000000..4703e5c57
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-md-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-xl-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-xl-linux.png
new file mode 100644
index 000000000..831eee169
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-ltr-xl-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-2xl-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-2xl-linux.png
new file mode 100644
index 000000000..1b8b3f092
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-2xl-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-lg-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-lg-linux.png
new file mode 100644
index 000000000..f919b485f
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-lg-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-md-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-md-linux.png
new file mode 100644
index 000000000..0b9c87956
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-md-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-xl-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-xl-linux.png
new file mode 100644
index 000000000..d0b5740ba
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/desktop-header-internal-rtl-xl-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-sm-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-sm-linux.png
new file mode 100644
index 000000000..3425ea742
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-sm-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-xs-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-xs-linux.png
new file mode 100644
index 000000000..7a0ab2582
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-ltr-xs-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-sm-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-sm-linux.png
new file mode 100644
index 000000000..9f0c21335
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-sm-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-xs-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-xs-linux.png
new file mode 100644
index 000000000..c0835b541
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-ltr-xs-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-sm-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-sm-linux.png
new file mode 100644
index 000000000..8fc729ee2
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-sm-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-xs-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-xs-linux.png
new file mode 100644
index 000000000..95d98bdd9
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-modal-rtl-xs-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-sm-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-sm-linux.png
new file mode 100644
index 000000000..f67544b52
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-sm-linux.png differ
diff --git a/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-xs-linux.png b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-xs-linux.png
new file mode 100644
index 000000000..351706773
Binary files /dev/null and b/test/storybook/visual-regression/v-header-internal.spec.ts-snapshots/mobile-header-internal-rtl-xs-linux.png differ
diff --git a/tsconfig.json b/tsconfig.json
index e924ead7b..da0171617 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -76,6 +76,7 @@
"src/components/VFilters/VLicenseExplanation.vue",
"src/components/VHeader/VFilterButton.vue",
"src/components/VHeader/VSearchBar/**.vue",
+ "src/components/VHeader/VPageLinks.vue",
"src/components/VImageDetails/VRelatedImages.vue",
"src/pages/feedback.vue",
"src/pages/search-help.vue",