-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract reusable VAudioCollection.vue (#2695)
* Extract reusable VAudioCollection.vue Co-authored-by: Zack Krida <[email protected]> * Move analytics test to e2e * Move the gap setting to the `ol` level --------- Co-authored-by: Zack Krida <[email protected]>
- Loading branch information
Showing
15 changed files
with
386 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
frontend/src/components/VSearchResultsGrid/VAudioCollection.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<template> | ||
<section> | ||
<VGridSkeleton | ||
v-if="results.length === 0 && !fetchState.isFinished" | ||
is-for-tab="audio" | ||
/> | ||
<VSnackbar size="large" :is-visible="snackbar.isVisible.value"> | ||
<i18n path="audioResults.snackbar.text" tag="p"> | ||
<template | ||
v-for="keyboardKey in ['spacebar', 'left', 'right']" | ||
#[keyboardKey] | ||
> | ||
<kbd :key="keyboardKey" class="font-sans">{{ | ||
$t(`audioResults.snackbar.${keyboardKey}`) | ||
}}</kbd> | ||
</template> | ||
</i18n> | ||
</VSnackbar> | ||
<VAudioList | ||
:collection-label="collectionLabel" | ||
:is-related="isRelated" | ||
:results="results" | ||
@focus="snackbar.show" | ||
@interacted="snackbar.hide" | ||
@mousedown="snackbar.handleMouseDown" | ||
/> | ||
<footer v-if="!isRelated"> | ||
<VLoadMore /> | ||
</footer> | ||
</section> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, PropType } from "vue" | ||
import type { AudioDetail } from "~/types/media" | ||
import type { FetchState } from "~/types/fetch-state" | ||
import { useAudioSnackbar } from "~/composables/use-audio-snackbar" | ||
import VAudioList from "~/components/VSearchResultsGrid/VAudioList.vue" | ||
import VLoadMore from "~/components/VLoadMore.vue" | ||
import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue" | ||
import VSnackbar from "~/components/VSnackbar.vue" | ||
import type { NuxtError } from "@nuxt/types" | ||
/** | ||
* This component shows a loading skeleton if the results are not yet loaded, | ||
* and then shows the list of audio, with the Load more button if needed. | ||
*/ | ||
export default defineComponent({ | ||
name: "VAudioCollection", | ||
components: { | ||
VSnackbar, | ||
VAudioList, | ||
VGridSkeleton, | ||
VLoadMore, | ||
}, | ||
props: { | ||
results: { | ||
type: Array as PropType<AudioDetail[]>, | ||
default: () => [], | ||
}, | ||
/** | ||
* If used for Related audio, do not show the Load more button. | ||
*/ | ||
isRelated: { | ||
type: Boolean, | ||
required: true, | ||
}, | ||
fetchState: { | ||
type: Object as PropType<FetchState<NuxtError> | FetchState>, | ||
required: true, | ||
}, | ||
/** | ||
* The label used for the list of audio for accessibility. | ||
*/ | ||
collectionLabel: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
setup() { | ||
const snackbar = useAudioSnackbar() | ||
return { | ||
snackbar, | ||
} | ||
}, | ||
}) | ||
</script> |
Oops, something went wrong.