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

Commit ec07933

Browse files
authored
Update search types popover for the new homepage and header (#2071)
* Split homepage VR tests * Fix e2e tests * Update spacing in the internal header * Update search types popover for the new homepage * Revert changes to the VContentPage.vue * Revert changes to home page
1 parent 5907fd0 commit ec07933

File tree

8 files changed

+97
-32
lines changed

8 files changed

+97
-32
lines changed
Lines changed: 5 additions & 0 deletions
Loading

src/components/VContentSwitcher/VSearchTypeItem.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
:selected="selected"
44
:is-first="isFirst"
55
:as="component"
6-
class="h-16 text-base lg:h-12"
6+
class="label-regular"
7+
:size="size"
78
v-bind="{ href }"
89
@click.native="$emit('click', item)"
910
>

src/components/VContentSwitcher/VSearchTypePopover.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
</template>
1515
<VSearchTypes
1616
id="content-switcher-popover"
17-
class="min-w-[262px] pt-2"
17+
class="w-[260px] pt-2"
1818
size="small"
19-
:use-links="true"
19+
:use-links="placement === 'header'"
2020
@select="closePopover"
2121
/>
2222
</VPopover>
2323
</template>
2424

2525
<script lang="ts">
26-
import { defineComponent, ref } from "@nuxtjs/composition-api"
26+
import { defineComponent, PropType, ref } from "@nuxtjs/composition-api"
2727
2828
import VPopover from "~/components/VPopover/VPopover.vue"
2929
import VSearchTypeButton from "~/components/VContentSwitcher/VSearchTypeButton.vue"
@@ -38,6 +38,12 @@ export default defineComponent({
3838
VSearchTypeButton,
3939
VSearchTypes,
4040
},
41+
props: {
42+
placement: {
43+
type: String as PropType<"header" | "searchbar">,
44+
default: "header",
45+
},
46+
},
4147
setup() {
4248
const contentMenuPopover = ref<InstanceType<typeof VPopover> | null>(null)
4349

src/components/VContentSwitcher/VSearchTypes.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
:size="size"
55
:bordered="bordered"
66
type="radiogroup"
7-
class="z-10 min-w-[262px] max-w-full"
7+
class="z-10"
8+
:class="{ 'w-[260px]': size === 'small' }"
89
>
910
<div
1011
v-for="(category, index) in contentTypeGroups"
1112
:key="index"
12-
class="flex flex-col lg:gap-y-1"
13+
class="flex flex-col"
1314
:class="{
1415
'mt-2': index > 0,
1516
'border-t border-dark-charcoal-20 bg-dark-charcoal-06':
1617
index > 0 && !bordered,
18+
'gap-1': size === 'small',
1719
}"
1820
>
1921
<h4
2022
v-if="index !== 0"
2123
:class="bordered ? 'ps-0' : 'ps-6'"
22-
class="pt-6 pb-4 text-sr font-semibold uppercase pe-6"
24+
class="category pt-6 pb-4 uppercase pe-6"
2325
>
2426
{{ $t(`search-type.${category.heading}`) }}
2527
</h4>
@@ -57,13 +59,18 @@ import { defineEvent } from "~/types/emits"
5759
import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
5860
import VSearchTypeItem from "~/components/VContentSwitcher/VSearchTypeItem.vue"
5961
62+
type ContentTypeGroup = {
63+
heading: string
64+
items: SearchType[]
65+
}
66+
6067
export default defineComponent({
6168
name: "VSearchTypes",
6269
components: { VItemGroup, VSearchTypeItem },
6370
props: {
6471
/**
65-
* 'Small' size for mobile screens,
66-
* 'medium' size for larger screens.
72+
* 'Small' size is used in the popover,
73+
* 'medium' size is used in the mobile modal.
6774
*/
6875
size: {
6976
type: String as PropType<"small" | "medium">,
@@ -86,18 +93,18 @@ export default defineComponent({
8693
8794
const isActive = (item: SearchType) => item === content.activeType.value
8895
89-
const contentTypeGroups = computed(() => {
90-
const base = [
96+
const contentTypeGroups = computed<ContentTypeGroup[]>(() => {
97+
const base: ContentTypeGroup[] = [
9198
{
9299
heading: "heading",
93100
items: content.types,
94101
},
95102
]
96103
97-
if (content.additionalTypes.value.length && props.useLinks) {
104+
if (content.additionalTypes.value.length) {
98105
base.push({
99106
heading: "additional",
100-
items: content.additionalTypes.value,
107+
items: [...content.additionalTypes.value],
101108
})
102109
}
103110

src/components/VContentSwitcher/meta/VSearchTypePopover.stories.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@storybook/addon-docs"
88

99
import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover.vue"
10+
import { useFeatureFlagStore } from "~/stores/feature-flag"
1011

1112
<Meta
1213
title="Components/VContentSwitcher/VSearchTypePopover"
@@ -15,13 +16,24 @@ import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover
1516
select: {
1617
action: "select",
1718
},
19+
additionalTypes: {
20+
control: { type: "boolean" },
21+
},
22+
}}
23+
args={{
24+
additionalTypes: false,
1825
}}
1926
/>
2027

2128
export const Template = (args) => ({
2229
template: `<VSearchTypePopover active-item="image" v-bind="args" v-on="args"/>`,
2330
components: { VSearchTypePopover },
2431
setup() {
32+
const featureFlagStore = useFeatureFlagStore()
33+
featureFlagStore.toggleFeature(
34+
"external_sources",
35+
args.additionalTypes ? "on" : "off"
36+
)
2537
return { args }
2638
},
2739
})

src/components/VContentSwitcher/meta/VSearchTypes.stories.mdx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,39 @@ import {
77
} from "@storybook/addon-docs"
88

99
import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
10+
import { useFeatureFlagStore } from "~/stores/feature-flag"
1011

1112
<Meta
1213
title="Components/VContentSwitcher/VSearchTypes"
1314
components={VSearchTypes}
1415
argTypes={{
15-
select: {
16-
action: "select",
17-
},
1816
size: {
19-
control: {
20-
type: "select",
21-
options: ["small", "medium"],
22-
},
17+
options: ["small", "medium"],
18+
control: { type: "select" },
2319
},
2420
useLinks: {
25-
control: {
26-
type: "boolean",
27-
},
21+
control: { type: "boolean" },
22+
},
23+
additionalTypes: {
24+
control: { type: "boolean" },
2825
},
2926
}}
27+
args={{
28+
size: "medium",
29+
useLinks: false,
30+
additionalTypes: false,
31+
}}
3032
/>
3133

3234
export const Template = (args) => ({
33-
template: `<VSearchTypes active-item="image" v-bind="args" v-on="args"/>`,
35+
template: `<VSearchTypes v-bind="args" v-on="args"/>`,
3436
components: { VSearchTypes },
3537
setup() {
38+
const featureFlagStore = useFeatureFlagStore()
39+
featureFlagStore.toggleFeature(
40+
"external_sources",
41+
args.additionalTypes ? "on" : "off"
42+
)
3643
return { args }
3744
},
3845
})

src/components/VItemGroup/VItem.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<VButton
1919
data-item-group-item
2020
:as="as"
21-
class="group relative flex min-w-full justify-between py-2 px-6 hover:bg-dark-charcoal-10 focus:z-10 lg:px-2"
21+
class="group relative flex min-w-full justify-between py-2 hover:bg-dark-charcoal-10 focus:z-10"
2222
:class="[
2323
$style[`${contextProps.direction}-button`],
2424
$style[`${contextProps.size}-button`],
@@ -54,8 +54,9 @@
5454
contextProps.direction === 'vertical' &&
5555
contextProps.showCheck
5656
"
57-
class="absolute end-2 lg:end-5"
58-
:icon-path="checkmark"
57+
class="absolute end-2"
58+
:class="contextProps.size === 'small' ? 'end-3' : 'end-6'"
59+
:icon-path="itemIndicator"
5960
/>
6061
</VButton>
6162
</div>
@@ -82,7 +83,7 @@ import VButton from "~/components/VButton.vue"
8283
import VIcon from "~/components/VIcon/VIcon.vue"
8384
import { VPopoverContentContextKey } from "~/components/VPopover/VPopoverContent.vue"
8485
85-
import checkmark from "~/assets/icons/checkmark.svg"
86+
import itemIndicator from "~/assets/icons/item-indicator.svg"
8687
8788
export default defineComponent({
8889
name: "VItem",
@@ -165,7 +166,7 @@ export default defineComponent({
165166
})
166167
167168
return {
168-
checkmark,
169+
itemIndicator,
169170
contextProps,
170171
isInPopover,
171172
isFocused,
@@ -205,7 +206,7 @@ export default defineComponent({
205206
}
206207
207208
.has-check .vertical-content {
208-
@apply pe-8 lg:pe-8;
209+
@apply pe-8;
209210
}
210211
211212
.vertical-popover-item {
@@ -243,4 +244,10 @@ export default defineComponent({
243244
.horizontal-popover-item:last-of-type {
244245
@apply pe-2;
245246
}
247+
.small-button {
248+
@apply p-3;
249+
}
250+
.medium-button {
251+
@apply px-6 py-5;
252+
}
246253
</style>

src/composables/use-search-type.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
import { useSearchStore } from "~/stores/search"
1515
import { useFeatureFlagStore } from "~/stores/feature-flag"
1616

17+
import { useI18n } from "~/composables/use-i18n"
18+
1719
import allIcon from "~/assets/icons/all-content.svg"
1820
import audioIcon from "~/assets/icons/audio-content.svg"
1921
import imageIcon from "~/assets/icons/image-content.svg"
@@ -28,7 +30,16 @@ const icons = {
2830
[MODEL_3D]: model3dIcon,
2931
} as const
3032

33+
const labels = {
34+
[ALL_MEDIA]: "search-type.all",
35+
[IMAGE]: "search-type.image",
36+
[AUDIO]: "search-type.audio",
37+
[VIDEO]: "search-type.video",
38+
[MODEL_3D]: "search-type.model-3d",
39+
} as const
40+
3141
export default function useSearchType() {
42+
const i18n = useI18n()
3243
const activeType = computed(() => useSearchStore().searchType)
3344

3445
const previousSearchType = ref(activeType.value)
@@ -46,13 +57,22 @@ export default function useSearchType() {
4657
previousSearchType.value = searchType
4758
}
4859

60+
const getSearchTypeProps = (searchType?: SearchType) => {
61+
const type = searchType ?? activeType.value
62+
return {
63+
label: i18n.t(labels[type]).toString(),
64+
icon: icons[type],
65+
searchType: type,
66+
}
67+
}
68+
4969
return {
5070
setActiveType,
5171
activeType,
72+
getSearchTypeProps,
5273
types: searchTypes,
5374
icons,
75+
labels,
5476
additionalTypes,
5577
}
5678
}
57-
58-
export type UseSearchTypeReturn = ReturnType<typeof useSearchType>

0 commit comments

Comments
 (0)