Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Set default size of VAudioTrack with a computed property (#814)
Krystle Salazarf5b7518c3942
diff --git a/src/components/VAllResultsGrid/VAudioCell.vue b/src/components/VAllResultsGrid/VAudioCell.vueindex b7d62be71..39b4d9a61 100644--- a/src/components/VAllResultsGrid/VAudioCell.vue+++ b/src/components/VAllResultsGrid/VAudioCell.vue@@ -2,7 +2,6 @@<VAudioTrack:audio="audio"layout="box"- size="full"@boxedAudioClick="navigateToSinglePage"/></template>diff --git a/src/components/VAudioTrack/VAudioTrack.vue b/src/components/VAudioTrack/VAudioTrack.vueindex 59c93c878..38f89187f 100644--- a/src/components/VAudioTrack/VAudioTrack.vue+++ b/src/components/VAudioTrack/VAudioTrack.vue@@ -6,7 +6,7 @@v-bind="layoutBasedProps"v-on="layoutBasedListeners">- <Component :is="layoutComponent" :audio="audio" :size="size">+ <Component :is="layoutComponent" :audio="audio" :size="_size"><template #controller="waveformProps"><VWaveformv-bind="waveformProps"@@ -91,7 +91,6 @@ const propTypes = {type: /** @type {import('@nuxtjs/composition-api').PropType<'s' | 'm' | 'l'>} */ (String),- default: 'm',/*** @param {string} val*/@@ -345,6 +344,16 @@ export default defineComponent({}const layoutComponent = computed(() => layoutMappings[props.layout])+ /**+ * Sets default size if not provided.+ */+ const _size = computed(() => {+ if (isBoxed && !props.size) {+ return null+ }+ return 'm'+ })+/*** A ref used on the play/pause button,* so we can capture clicks and skip@@ -396,6 +405,7 @@ export default defineComponent({duration,layoutComponent,+ _size,layoutBasedProps,layoutBasedListeners,diff --git a/src/components/VAudioTrack/layouts/VBoxLayout.vue b/src/components/VAudioTrack/layouts/VBoxLayout.vueindex ae3a7f5cd..8d83e06f1 100644--- a/src/components/VAudioTrack/layouts/VBoxLayout.vue+++ b/src/components/VAudioTrack/layouts/VBoxLayout.vue@@ -1,6 +1,6 @@<template><div :style="{ width }">- <!-- Should be wrapped by a fixed width parent -->+ <!-- The width is determined by the parent element if the 'size' property is not specified. --><divclass="box-track group relative bg-yellow h-0 w-full pt-full rounded-sm">@@ -47,8 +47,9 @@ export default defineComponent({l: 13.25,m: 12.25,s: 9.75,- }[props.size ?? 'm']- return `${magnitude}rem`+ }[props.size]++ return props.size ? `${magnitude}rem` : null})return {