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

Commit f2c1694

Browse files
authored
Move new homepage and 404 to the default layout (#2075)
* Move the home and 404 pages to default layout * Update snapshots * Fix layout background not re-rendering on changing page * Fix homepage search type selection
1 parent ec07933 commit f2c1694

File tree

66 files changed

+563
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+563
-297
lines changed

src/components/VContentSwitcher/VSearchTypePopover.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
class="w-[260px] pt-2"
1818
size="small"
1919
:use-links="placement === 'header'"
20-
@select="closePopover"
20+
@select="handleSelect"
2121
/>
2222
</VPopover>
2323
</template>
2424

2525
<script lang="ts">
2626
import { defineComponent, PropType, ref } from "@nuxtjs/composition-api"
2727
28+
import type { SearchType } from "~/constants/media"
29+
2830
import VPopover from "~/components/VPopover/VPopover.vue"
2931
import VSearchTypeButton from "~/components/VContentSwitcher/VSearchTypeButton.vue"
3032
import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
@@ -44,16 +46,17 @@ export default defineComponent({
4446
default: "header",
4547
},
4648
},
47-
setup() {
49+
setup(_, { emit }) {
4850
const contentMenuPopover = ref<InstanceType<typeof VPopover> | null>(null)
4951
50-
const closePopover = () => {
52+
const handleSelect = (searchType: SearchType) => {
53+
emit("select", searchType)
5154
contentMenuPopover.value?.close()
5255
}
5356
5457
return {
5558
checkIcon,
56-
closePopover,
59+
handleSelect,
5760
contentMenuPopover,
5861
}
5962
},

src/components/VFourOhFour.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22
<div
3-
class="error relative flex min-h-screen flex-col overflow-x-hidden bg-yellow"
3+
class="error relative flex flex-col overflow-x-hidden"
4+
:class="
5+
isNewHeaderEnabled ? 'flex-grow px-6 sm:px-0' : 'min-h-screen bg-yellow'
6+
"
47
>
58
<svg
69
class="z-0 pointer-events-none absolute top-20 -mt-[10%] -ml-[20%] w-[140%] fill-dark-charcoal px-6 opacity-5 lg:mx-auto lg:ml-0 lg:w-full lg:px-16"
@@ -11,7 +14,7 @@
1114
>
1215
<use :href="`${Oops}#oops`" />
1316
</svg>
14-
<div>
17+
<div v-if="!isNewHeaderEnabled">
1518
<VLink href="/" class="relative z-10 text-dark-charcoal">
1619
<VBrand class="m-6 text-[18px] lg:mx-10 lg:my-8" />
1720
</VLink>
@@ -37,11 +40,14 @@
3740
</template>
3841
</i18n>
3942
</p>
40-
<VStandaloneSearchBar route="404" @submit="handleSearch" />
43+
<VStandaloneSearchBar
44+
v-if="isNewHeaderEnabled"
45+
route="404"
46+
@submit="handleSearch"
47+
/>
48+
<VStandaloneSearchBarOld v-else route="404" @submit="handleSearch" />
4149
</div>
4250
</main>
43-
44-
<VFooter v-if="isNewHeaderEnabled" mode="internal" />
4551
</div>
4652
</template>
4753

@@ -53,20 +59,21 @@ import { useFeatureFlagStore } from "~/stores/feature-flag"
5359
5460
import { ALL_MEDIA } from "~/constants/media"
5561
56-
import VStandaloneSearchBar from "~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue"
62+
import VStandaloneSearchBarOld from "~/components/VHeaderOld/VSearchBar/VStandaloneSearchBarOld.vue"
5763
import VLink from "~/components/VLink.vue"
5864
import VBrand from "~/components/VBrand/VBrand.vue"
59-
import VFooter from "~/components/VFooter/VFooter.vue"
6065
6166
import Oops from "~/assets/oops.svg"
6267
6368
export default defineComponent({
6469
name: "VFourOhFour",
6570
components: {
6671
VLink,
67-
VStandaloneSearchBar,
72+
VStandaloneSearchBarOld,
73+
VStandaloneSearchBar: () =>
74+
import("~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue"),
75+
6876
VBrand,
69-
VFooter,
7077
},
7178
props: ["error"],
7279
setup() {

src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<form
3-
class="search-bar group flex h-[57px] flex-row items-center rounded-sm border-tx bg-white md:h-[69px]"
3+
class="search-bar group flex h-14 flex-row items-center rounded-sm border-tx bg-white sm:h-16"
44
@submit.prevent="handleSearch"
55
>
66
<div
@@ -29,7 +29,19 @@
2929
<!-- @slot Extra information goes here -->
3030
<slot />
3131
</div>
32-
<VSearchButton type="submit" size="standalone" :route="route" />
32+
<VButton
33+
type="submit"
34+
:aria-label="$t('search.search')"
35+
size="disabled"
36+
:variant="isHomeRoute ? 'primary' : 'plain'"
37+
class="h-full w-14 flex-shrink-0 transition-none rounded-s-none sm:w-16"
38+
:class="{
39+
'search-button border-black p-0.5px ps-1.5px hover:bg-pink hover:text-white focus:border-tx focus-visible:bg-pink focus-visible:text-white group-focus-within:border-pink group-focus-within:border-tx group-focus-within:bg-pink group-focus-within:text-white group-focus-within:hover:bg-dark-pink group-hover:border-pink group-hover:border-tx group-hover:bg-pink group-hover:text-white group-focus:border-tx':
40+
!isHomeRoute,
41+
}"
42+
>
43+
<VIcon :icon-path="searchIcon" />
44+
</VButton>
3345
</form>
3446
</template>
3547

@@ -43,7 +55,10 @@ import {
4355
4456
import { defineEvent } from "~/types/emits"
4557
46-
import VSearchButton from "~/components/VHeader/VSearchBar/VSearchButton.vue"
58+
import VButton from "~/components/VButton.vue"
59+
import VIcon from "~/components/VIcon/VIcon.vue"
60+
61+
import searchIcon from "~/assets/icons/search.svg"
4762
4863
/**
4964
* Displays a search input for a search query and is attached to an action button
@@ -54,7 +69,7 @@ import VSearchButton from "~/components/VHeader/VSearchBar/VSearchButton.vue"
5469
*/
5570
export default defineComponent({
5671
name: "VStandaloneSearchBar",
57-
components: { VSearchButton },
72+
components: { VButton, VIcon },
5873
props: {
5974
route: {
6075
type: String as PropType<"home" | "404">,
@@ -81,6 +96,8 @@ export default defineComponent({
8196
inputRef,
8297
handleSearch,
8398
isHomeRoute,
99+
100+
searchIcon,
84101
}
85102
},
86103
})
@@ -89,4 +106,8 @@ export default defineComponent({
89106
.input-field {
90107
border-inline-end-width: 0;
91108
}
109+
110+
.search-button {
111+
border-inline-start-width: 0;
112+
}
92113
</style>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<template>
2+
<form
3+
class="search-bar group flex h-[57px] flex-row items-center rounded-sm border-tx bg-white md:h-[69px]"
4+
@submit.prevent="handleSearch"
5+
>
6+
<div
7+
class="input-field search-field group flex h-full flex-grow items-center overflow-hidden rounded-sm border p-0.5px pe-1.5px rounded-e-none border-e-0 focus-within:border-1.5 focus-within:border-pink focus-within:bg-dark-charcoal-06 focus-within:p-0 focus-within:pe-1.5px group-hover:bg-dark-charcoal-06"
8+
:class="[isHomeRoute ? 'border-tx' : 'border-black']"
9+
>
10+
<input
11+
id="search-bar"
12+
ref="inputRef"
13+
type="search"
14+
name="q"
15+
:placeholder="
16+
$t(
17+
isHomeRoute ? 'hero.search.placeholder' : '404.search-placeholder'
18+
).toString()
19+
"
20+
class="h-full w-full appearance-none rounded-none bg-tx text-base leading-none text-dark-charcoal placeholder-dark-charcoal-70 ms-4 focus:outline-none md:text-2xl"
21+
:aria-label="
22+
isHomeRoute
23+
? $t('search.search-bar-label', {
24+
openverse: 'Openverse',
25+
}).toString()
26+
: $t('404.search-placeholder').toString()
27+
"
28+
/>
29+
<!-- @slot Extra information goes here -->
30+
<slot />
31+
</div>
32+
<VSearchButton
33+
class="flex-shrink-0"
34+
type="submit"
35+
size="standalone"
36+
:route="route"
37+
/>
38+
</form>
39+
</template>
40+
41+
<script lang="ts">
42+
import {
43+
computed,
44+
defineComponent,
45+
PropType,
46+
ref,
47+
} from "@nuxtjs/composition-api"
48+
49+
import { defineEvent } from "~/types/emits"
50+
51+
import VSearchButton from "~/components/VHeader/VSearchBar/VSearchButton.vue"
52+
53+
/**
54+
* Displays a search input for a search query and is attached to an action button
55+
* that fires a search request. Can contain other elements like the search type
56+
* popover. Is uncontrolled: Vue code does not try to set a default value when
57+
* hydrating the server-rendered code, so the value entered before full hydration
58+
* is not removed.
59+
*/
60+
export default defineComponent({
61+
name: "VStandaloneSearchBarOld",
62+
components: { VSearchButton },
63+
props: {
64+
route: {
65+
type: String as PropType<"home" | "404">,
66+
default: "home",
67+
},
68+
},
69+
emits: {
70+
submit: defineEvent<[string]>(),
71+
},
72+
setup(props, { emit }) {
73+
const inputRef = ref<HTMLInputElement | null>(null)
74+
75+
// Only emit `submit` if the input value is not blank
76+
const handleSearch = () => {
77+
const searchTerm = inputRef.value?.value.trim()
78+
if (searchTerm) {
79+
emit("submit", searchTerm)
80+
}
81+
}
82+
83+
const isHomeRoute = computed(() => props.route === "home")
84+
85+
return {
86+
inputRef,
87+
handleSearch,
88+
isHomeRoute,
89+
}
90+
},
91+
})
92+
</script>
93+
<style scoped>
94+
.input-field {
95+
border-inline-end-width: 0;
96+
}
97+
</style>

src/components/VHomeGallery/VHomeGallery.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import {
5757
import { useReducedMotion } from "~/composables/use-media-query"
5858
import useResizeObserver from "~/composables/use-resize-observer"
5959
60+
import VLink from "~/components/VLink.vue"
61+
6062
import imageInfo from "~/assets/homepage_images/image_info.json"
6163
6264
export const GALLERY_SETS = [
@@ -74,6 +76,7 @@ export type GallerySet = typeof GALLERY_SETS[number]
7476
*/
7577
export default defineComponent({
7678
name: "VHomeGallery",
79+
components: { VLink },
7780
props: {
7881
/**
7982
* the set of images to use for the gallery grid
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<template>
2+
<div>
3+
<h2
4+
class="mt-auto mb-2 text-[40px] font-light leading-tight lg:text-[63px]"
5+
>
6+
{{ $t("hero.subtitle") }}
7+
</h2>
8+
9+
<p class="text-base leading-relaxed">
10+
{{ $t("hero.description") }}
11+
</p>
12+
13+
<VStandaloneSearchBar class="mt-4 md:mt-6" @submit="handleSearch">
14+
<VSearchTypePopover
15+
class="mx-3 group-focus-within:bg-white group-hover:bg-white"
16+
:active-item="searchType"
17+
placement="searchbar"
18+
@select="setSearchType"
19+
/>
20+
</VStandaloneSearchBar>
21+
22+
<!-- Disclaimer for large screens -->
23+
<i18n path="hero.disclaimer.content" tag="p" class="mt-4 text-sr">
24+
<template #openverse>Openverse</template>
25+
<template #license>
26+
<VLink
27+
href="https://creativecommons.org/licenses/"
28+
class="text-dark-charcoal underline hover:text-dark-charcoal"
29+
>{{ $t("hero.disclaimer.license") }}</VLink
30+
>
31+
</template>
32+
</i18n>
33+
</div>
34+
</template>
35+
<script lang="ts">
36+
import type { SearchType } from "~/constants/media"
37+
38+
import VLink from "~/components/VLink.vue"
39+
import VStandaloneSearchBar from "~/components/VHeader/VSearchBar/VStandaloneSearchBar.vue"
40+
import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover.vue"
41+
42+
import type { PropType } from "@nuxtjs/composition-api"
43+
44+
export default {
45+
name: "VHomepageContent",
46+
components: { VSearchTypePopover, VStandaloneSearchBar, VLink },
47+
props: {
48+
handleSearch: {
49+
type: Function as PropType<(query: string) => void>,
50+
required: true,
51+
},
52+
searchType: {
53+
type: String as PropType<SearchType>,
54+
required: true,
55+
},
56+
setSearchType: {
57+
type: Function as PropType<(searchType: SearchType) => void>,
58+
required: true,
59+
},
60+
},
61+
}
62+
</script>
63+
<style>
64+
@screen lg {
65+
}
66+
</style>

0 commit comments

Comments
 (0)