Skip to content

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

Fix logo button paddings and simplify implementation (#767)

sarayourfriend4e9aa6985ffe
diff --git a/src/components/VHeader/VLogoButton.vue b/src/components/VHeader/VLogoButton.vue
index 0d5fe5e75..d49a3487a 100644
--- a/src/components/VHeader/VLogoButton.vue
+++ b/src/components/VHeader/VLogoButton.vue
@@ -1,30 +1,33 @@
<template>
- <NuxtLink
+ <VButton
+ as="NuxtLink"
to="/"
- class="rounded-sm ring-offset-1 focus:outline-none focus-visible:ring focus-visible:ring-pink -ms-2 inline-flex items-center hover:bg-yellow mr-auto"
- :class="{
- 'pe-3 md:pe-0': isSearchRoute && !isHeaderScrolled,
- 'md:pe-3': !isSearchRoute,
- }"
+ variant="plain"
+ size="disabled"
+ class="max-w-min hover:bg-yellow"
>
- <VLogoLoader :status="isFetching ? 'loading' : 'idle'" />
+ <VLogoLoader
+ :status="isFetching ? 'loading' : 'idle'"
+ :auto-resize="autoResizeLogo"
+ />
<OpenverseLogoText
v-if="!isHeaderScrolled"
- class="logo-text -ml-1 mt-1"
+ class="-ml-1 mt-1 me-3"
:class="{ 'md:hidden': isSearchRoute }"
width="95"
height="15"
/>
- </NuxtLink>
+ </VButton>
</template>
<script>
import { defineComponent } from '@nuxtjs/composition-api'
import OpenverseLogoText from '~/assets/icons/openverse-logo-text.svg?inline'
import VLogoLoader from '~/components/VLogoLoader/VLogoLoader.vue'
+import VButton from '~/components/VButton.vue'
const VLogoButton = defineComponent({
name: 'VLogoButton',
- components: { OpenverseLogoText, VLogoLoader },
+ components: { OpenverseLogoText, VLogoLoader, VButton },
props: {
isFetching: {
type: Boolean,
@@ -38,14 +41,11 @@ const VLogoButton = defineComponent({
type: Boolean,
required: true,
},
+ autoResizeLogo: {
+ type: Boolean,
+ default: true,
+ },
},
})
export default VLogoButton
</script>
-<style scoped>
-@media (max-width: 370px) {
- .logo-text {
- display: none;
- }
-}
-</style>
diff --git a/src/components/VLogoLoader/VLogoLoader.types.js b/src/components/VLogoLoader/VLogoLoader.types.js
index 64db22616..17570da62 100644
--- a/src/components/VLogoLoader/VLogoLoader.types.js
+++ b/src/components/VLogoLoader/VLogoLoader.types.js
@@ -4,6 +4,10 @@ export const propTypes = {
default: 'idle',
required: false,
},
+ autoResize: {
+ type: Boolean,
+ default: true,
+ },
}
/** @typedef {import('@nuxtjs/composition-api').ExtractPropTypes<typeof propTypes>} Props */
diff --git a/src/components/VLogoLoader/VLogoLoader.vue b/src/components/VLogoLoader/VLogoLoader.vue
index 2516aea62..91f537e5b 100644
--- a/src/components/VLogoLoader/VLogoLoader.vue
+++ b/src/components/VLogoLoader/VLogoLoader.vue
@@ -4,11 +4,12 @@
xmlns="http://www.w3.org/2000/svg"
:class="{
[$style.loading]: status === 'loading' && !prefersReducedMotion,
+ 'w-10 h-10': autoResize,
}"
aria-hidden="true"
:data-prefers-reduced-motion="prefersReducedMotion"
data-testid="logo-loader"
- class="w-10 h-10 md:w-12 md:h-12 p-3 rounded inline-flex justify-center items-center"
+ class="w-12 h-12 md:w-12 md:h-12 p-3 rounded inline-flex justify-center items-center"
>
<path
data-logo-part-1
diff --git a/src/pages/index.vue b/src/pages/index.vue
index ffe2c6202..2c3b5de7b 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -4,63 +4,67 @@
>
<!-- TODO: Refine min-width for different breakpoints, remove magic numbers -->
<header
- class="flex-grow w-full lg:w-auto lg:min-w-[32rem] xl:min-w-[64rem] box-border px-6 lg:pl-30 lg:pr-0 xl:px-40 mx-auto flex flex-col justify-center"
+ class="flex-grow w-full lg:w-auto lg:min-w-[32rem] xl:min-w-[64rem] box-border flex flex-col justify-between lg:justify-center"
>
- <NuxtLink to="/" class="relative z-10">
- <h1>
- <span class="sr-only">{{ $t('hero.brand') }}</span>
- <!-- width and height chosen w.r.t. viewBox "0 0 280 42" -->
- <OpenverseLogo
- aria-hidden="true"
- class="lg:-translate-x-24 w-30 lg:h-[63px] lg:w-auto pt-6 lg:pt-0"
- />
- </h1>
- </NuxtLink>
-
- <h2 class="text-4xl lg:text-6xl mt-auto lg:mt-6">
- {{ $t('hero.subtitle') }}
- </h2>
- <div class="flex justify-start gap-4 mt-4 md:hidden">
- <VContentTypeButton
- v-for="type in supportedContentTypes"
- :key="type"
- :content-type="type"
- :selected="type === contentType"
- @select="setContentType"
- />
- </div>
- <VSearchBar
- v-model.trim="searchTerm"
- class="max-w-[40rem] mt-4 lg:mt-8"
- size="standalone"
- :placeholder="$t('hero.search.placeholder')"
- @submit="handleSearch"
- >
- <ClientOnly>
- <VContentSwitcherPopover
- v-if="isMinScreenMd"
- ref="contentSwitcher"
- class="mx-3"
- :active-item="contentType"
+ <VLogoButton class="lg:hidden ms-3" :auto-resize-logo="false" />
+
+ <div class="px-6 lg:pl-30 lg:pr-0 xl:px-40 mx-auto w-full lg:w-auto">
+ <NuxtLink to="/" class="relative z-10 hidden lg:block">
+ <h1>
+ <span class="sr-only">{{ $t('hero.brand') }}</span>
+ <!-- width and height chosen w.r.t. viewBox "0 0 280 42" -->
+ <OpenverseLogo
+ aria-hidden="true"
+ class="lg:-translate-x-24 w-30 lg:h-[63px] lg:w-auto pt-6 lg:pt-0"
+ />
+ </h1>
+ </NuxtLink>
+
+ <h2 class="text-4xl lg:text-6xl mt-auto lg:mt-6">
+ {{ $t('hero.subtitle') }}
+ </h2>
+ <div class="flex justify-start gap-4 mt-4 md:hidden">
+ <VContentTypeButton
+ v-for="type in supportedContentTypes"
+ :key="type"
+ :content-type="type"
+ :selected="type === contentType"
@select="setContentType"
/>
- </ClientOnly>
- </VSearchBar>
-
- <!-- Disclaimer for large screens -->
- <i18n
- path="hero.disclaimer.content"
- tag="p"
- class="hidden lg:block text-sr mt-4"
- >
- <template #license>
- <a
- href="https://creativecommons.org/licenses/"
- class="text-dark-charcoal hover:text-dark-charcoal underline"
- >{{ $t('hero.disclaimer.license') }}</a
- >
- </template>
- </i18n>
+ </div>
+ <VSearchBar
+ v-model.trim="searchTerm"
+ class="max-w-[40rem] mt-4 lg:mt-8"
+ size="standalone"
+ :placeholder="$t('hero.search.placeholder')"
+ @submit="handleSearch"
+ >
+ <ClientOnly>
+ <VContentSwitcherPopover
+ v-if="isMinScreenMd"
+ ref="contentSwitcher"
+ class="mx-3"
+ :active-item="contentType"
+ @select="setContentType"
+ />
+ </ClientOnly>
+ </VSearchBar>
+
+ <!-- Disclaimer for large screens -->
+ <i18n
+ path="hero.disclaimer.content"
+ tag="p"
+ class="hidden lg:block text-sr mt-4"
+ >
+ <template #license>
+ <a
+ href="https://creativecommons.org/licenses/"
+ class="text-dark-charcoal hover:text-dark-charcoal underline"
+ >{{ $t('hero.disclaimer.license') }}</a
+ >
+ </template>
+ </i18n>
+ </div>
</header>
<!-- Image carousel -->
@@ -128,6 +132,7 @@ import OpenverseLogo from '~/assets/logo.svg?inline'
import VContentSwitcherPopover from '~/components/VContentSwitcher/VContentSwitcherPopover.vue'
import VContentTypeButton from '~/components/VContentSwitcher/VContentTypeButton.vue'
import VSearchBar from '~/components/VHeader/VSearchBar/VSearchBar.vue'
+import VLogoButton from '~/components/VHeader/VLogoButton.vue'
const HomePage = {
name: 'home-page',
@@ -137,6 +142,7 @@ const HomePage = {
VContentSwitcherPopover,
VContentTypeButton,
VSearchBar,
+ VLogoButton,
},
head: {
meta: [