Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Update AudioTrack layouts as per new designs (#504)
Dhruv Bhanushali46b412d4c242
diff --git a/nuxt.config.js b/nuxt.config.jsindex ac7623cd2..4743f437f 100644--- a/nuxt.config.js+++ b/nuxt.config.js@@ -1,6 +1,7 @@import pkg from './package.json'import locales from './src/locales/scripts/valid-locales.json'import stringToBoolean from './src/utils/string-to-boolean'+import { VIEWPORTS } from './src/constants/screens'/*** Default environment variables are set on this key. Defaults are fallbacks to existing env vars.@@ -233,7 +234,7 @@ export default {name: '@storybook/addon-essentials',options: {backgrounds: false,- viewport: false,+ viewport: true,toolbars: true,},},@@ -244,6 +245,9 @@ export default {order: ['Introduction', ['Openverse UI']],},},+ viewport: {+ viewports: VIEWPORTS,+ },},},}diff --git a/src/components/AudioTrack/AudioTrack.vue b/src/components/AudioTrack/AudioTrack.vueindex 7bd013d1b..4af180c31 100644--- a/src/components/AudioTrack/AudioTrack.vue+++ b/src/components/AudioTrack/AudioTrack.vue@@ -4,12 +4,7 @@:aria-label="$t('audio-track.aria-label')"role="region">- <Component- :is="layoutComponent"- :audio="audio"- :size="size"- :aspect="aspect"- >+ <Component :is="layoutComponent" :audio="audio" :size="size"><template #controller="controllerProps"><AudioControllerv-model="status"@@ -40,6 +35,7 @@ import AudioController from '~/components/AudioTrack/AudioController.vue'import Full from '~/components/AudioTrack/layouts/Full.vue'import Row from '~/components/AudioTrack/layouts/Row.vue'+import Box from '~/components/AudioTrack/layouts/Box.vue'import Global from '~/components/AudioTrack/layouts/Global.vue'/**@@ -55,6 +51,7 @@ export default {// LayoutsFull,Row,+ Box,Global,},props: {@@ -81,16 +78,7 @@ export default {size: {type: String,default: 'm',- validator: (val) => ['s', 'm', 'l', 'xl'].includes(val),- },- /**- * whether to show the 'box' layout with a wider aspect ratio; This is- * opposed to the regular square layout.- */- aspect: {- type: String,- default: 'regular',- validator: (val) => ['regular', 'wide'].includes(val),+ validator: (val) => ['s', 'm', 'l'].includes(val),},},setup(props) {@@ -119,6 +107,7 @@ export default {const layoutMappings = {full: 'Full',row: 'Row',+ box: 'Box',global: 'Global',}const layoutComponent = computed(() => layoutMappings[props.layout])diff --git a/src/components/AudioTrack/Waveform.vue b/src/components/AudioTrack/Waveform.vueindex cde9f936b..790f942ff 100644--- a/src/components/AudioTrack/Waveform.vue+++ b/src/components/AudioTrack/Waveform.vue@@ -1,10 +1,14 @@<template><divref="el"- class="waveform relative bg-dark-charcoal-06 border-1.5 border-tx focus:border-pink focus:outline-none focus:shadow-ring overflow-hidden"- :style="{ '--unusable-height': `${Math.floor((1 - usableFrac) * 100)}%` }"- tabIndex="0"- role="slider"+ class="waveform group relative bg-background-var focus:outline-none overflow-hidden"+ :style="{+ '--usable-height': `${Math.floor(usableFrac * 100)}%`,+ '--unusable-height': `${Math.floor((1 - usableFrac) * 100)}%`,+ }"+ :tabIndex="!message && isReady ? 0 : -1"+ :role="!message && isReady ? 'slider' : null"+ :aria-disabled="!(!message && isReady)":aria-label="$t('waveform.label')"aria-orientation="horizontal"aria-valuemin="0"@@ -20,6 +24,36 @@@keydown.home.prevent="handlePosKeys(0)"@keydown.end.prevent="handlePosKeys(1)">+ <!-- Focus ring -->+ <svg+ class="hidden group-focus:block absolute inset-0 w-full h-full z-20 shadow-ring-1"+ xmlns="http://www.w3.org/2000/svg"+ :viewBox="viewBox"+ preserveAspectRatio="none"+ >+ <!-- Stroke is calculated from the centre of the path -->+ <rect+ class="stroke-pink"+ x="0.75"+ y="0.75"+ :width="waveformDimens.width - 1.5"+ :height="waveformDimens.height - 1.5"+ rx="2"+ fill="none"+ stroke-width="1.5"+ />+ <rect+ class="stroke-white"+ x="2"+ y="2"+ :width="waveformDimens.width - 4"+ :height="waveformDimens.height - 4"+ fill="none"+ stroke-width="1"+ rx="0.75"+ />+ </svg>+<!-- Progress bar --><svgclass="absolute inset-0 w-full h-full"@@ -40,7 +74,7 @@<!-- Bars --><svgclass="bars absolute bottom-0 w-full"- :style="{ '--usable-height': `${Math.floor(usableFrac * 100)}%` }"+ :class="{ 'with-space': showDuration || showTimestamps }"xmlns="http://www.w3.org/2000/svg":viewBox="viewBox"preserveAspectRatio="none"@@ -62,7 +96,7 @@<!-- Keyboard focus --><div- class="focus-indicator hidden absolute z-20 top-0 flex flex-col items-center justify-between bg-black h-full"+ class="focus-indicator hidden absolute z-30 top-0 flex flex-col items-center justify-between bg-black h-full":style="{ width: `${barWidth}px`, left: `${seekSpaceBefore}px` }"><div@@ -80,30 +114,32 @@<!-- Timestamps --><template v-if="isReady">- <div- ref="progressTimestampEl"- class="progress timestamp z-10 transform"- :class="[- ...(isProgressTimestampCutoff- ? ['bg-dark-charcoal-06']- : ['bg-yellow', '-translate-x-full']),- ]"- :style="{ '--progress-time-left': `${progressBarWidth}px` }"- >- {{ timeFmt(progressTimestamp) }}- </div>- <div- v-if="seekFrac"- ref="seekTimestampEl"- class="seek timestamp transform"- :class="{ '-translate-x-full': !isSeekTimestampCutoff }"- :style="{ '--seek-time-left': `${seekBarWidth}px` }"- >- {{ timeFmt(seekTimestamp) }}- </div>+ <template v-if="showTimestamps">+ <div+ ref="progressTimestampEl"+ class="progress timestamp z-10 transform"+ :class="[+ ...(isProgressTimestampCutoff+ ? ['bg-background-var']+ : ['bg-yellow', '-translate-x-full']),+ ]"+ :style="{ '--progress-time-left': `${progressBarWidth}px` }"+ >+ {{ timeFmt(progressTimestamp) }}+ </div>+ <div+ v-if="seekFrac"+ ref="seekTimestampEl"+ class="seek timestamp transform"+ :class="{ '-translate-x-full': !isSeekTimestampCutoff }"+ :style="{ '--seek-time-left': `${seekBarWidth}px` }"+ >+ {{ timeFmt(seekTimestamp) }}+ </div>+ </template><divv-if="showDuration"- class="duration timestamp right-0 bg-dark-charcoal-06"+ class="duration timestamp right-0 bg-background-var">{{ timeFmt(duration) }}</div>@@ -166,13 +202,6 @@ export default {type: Number,default: 0,},- /**- * whether to show the duration of the audio at the ending edge- */- showDuration: {- type: Boolean,- default: false,- },/*** the fraction of the waveform height to use for the bars and timestamp;* The remaining space can be used to place other elements.@@ -181,6 +210,14 @@ export default {type: Number,default: 1,},+ /**+ * selectively enable features in the waveform; Available features are+ * `'timestamp'` and `'duration'`.+ */+ features: {+ type: Array,+ default: () => ['timestamps'],+ },},setup(props, { emit }) {/* Utils */@@ -212,7 +249,7 @@ export default {*/const getPositionFrac = (event) => {const xPos = getPosition(event)- return xPos / waveformWidth.value+ return xPos / waveformDimens.value.width}/*** Get the number of peaks that will fit within the given width.@@ -226,15 +263,18 @@ export default {/* Element dimensions */const el = ref(null) // template ref- const waveformWidth = ref(0)- const updateWaveformWidth = () => {- waveformWidth.value = el.value.clientWidth+ const waveformDimens = ref({ width: 0, height: 0 })+ const updateWaveformDimens = () => {+ waveformDimens.value = {+ width: el.value.clientWidth,+ height: el.value.clientHeight,+ }}let observeronMounted(() => {- observer = new ResizeObserver(updateWaveformWidth)+ observer = new ResizeObserver(updateWaveformDimens)observer.observe(el.value)- updateWaveformWidth()+ updateWaveformDimens()})onBeforeUnmount(() => {if (observer) {@@ -242,6 +282,11 @@ export default {}})+ /* Features */++ const showDuration = computed(() => props.features.includes('duration'))+ const showTimestamps = computed(() => props.features.includes('timestamps'))+/* State */const isReady = computed(() => !props.message)@@ -250,23 +295,31 @@ export default {const barWidth = 2const barGap = 2- const peakCount = computed(() => getPeaksInWidth(waveformWidth.value))+ const peakCount = computed(() =>+ getPeaksInWidth(waveformDimens.value.width)+ )const normalizedPeaks = computed(() => {- const givenLength = props.peaks.length+ let samples = props.peaks++ const givenLength = samples.lengthconst required = peakCount.valueif (givenLength < required) {- return upsampleArray(props.peaks, required)+ samples = upsampleArray(samples, required)} else if (givenLength > required) {- return downsampleArray(props.peaks, required)+ samples = downsampleArray(samples, required)}- return props.peaks++ return samples.map((peak) => peak * waveformDimens.value.height)})/* SVG drawing */- const viewBox = computed(() => `0 0 ${waveformWidth.value} 1`)- const spaceBefore = (index) => index * barWidth + (index + 1) * barGap- const spaceAbove = (index) => 1 - normalizedPeaks.value[index]+ const viewBox = computed(() =>+ [0, 0, waveformDimens.value.width, waveformDimens.value.height].join(' ')+ )+ const spaceBefore = (index) => index * barWidth + index * barGap+ const spaceAbove = (index) =>+ waveformDimens.value.height - normalizedPeaks.value[index]/* Progress bar */@@ -275,7 +328,7 @@ export default {)const progressBarWidth = computed(() => {const frac = isDragging.value ? seekFrac.value : currentFrac.value- return waveformWidth.value * frac+ return waveformDimens.value.width * frac})/* Progress timestamp */@@ -296,7 +349,7 @@ export default {const seekFrac = ref(null)const seekBarWidth = computed(() => {const frac = seekFrac.value ?? currentFrac.value- return waveformWidth.value * frac+ return waveformDimens.value.width * frac})const seekIndex = computed(() => getPeaksInWidth(seekBarWidth.value))const seekSpaceBefore = computed(() => spaceBefore(seekIndex.value))@@ -390,11 +443,15 @@ export default {el, // template ref+ showDuration,+ showTimestamps,+isReady,barWidth,normalizedPeaks,+ waveformDimens,viewBox,spaceBefore,spaceAbove,@@ -436,12 +493,27 @@ export default {</script><style scoped lang="css">+.waveform {+ --v-background-color: var(+ --waveform-background-color,+ theme('colors.dark-charcoal.06')+ );+}+.timestamp {@apply absolute font-bold text-xs px-1 pointer-events-none;top: calc(var(--unusable-height) + theme('spacing[0.5]'));}+.bg-background-var {+ background-color: var(--v-background-color);+}+.bars {+ height: calc(var(--usable-height));+}++.bars.with-space {height: calc(var(--usable-height) - 1rem - 2 * theme('spacing[0.5]'));}diff --git a/src/components/AudioTrack/layouts/Box.vue b/src/components/AudioTrack/layouts/Box.vuenew file mode 100644index 000000000..df1d7e645--- /dev/null+++ b/src/components/AudioTrack/layouts/Box.vue@@ -0,0 +1,73 @@+<template>+ <div :style="{ width }">+ <!-- Should be wrapped by a fixed width parent -->+ <div class="box-track group relative bg-yellow h-0 w-full pt-full">+ <div class="absolute inset-0 flex flex-col">+ <div class="info flex-grow flex flex-col justify-between p-4">+ <span class="font-heading font-semibold leading-snug">{{+ audio.title+ }}</span>+ <div class="info">+ <VLicense+ v-if="!isSmall"+ class="mb-2 hidden group-hover:block group-focus:block"+ hide-name+ :license="audio.license"+ />+ <div>{{ $t(`audio-categories.${audio.category}`) }}</div>+ </div>+ </div>++ <div v-if="!isSmall" class="player flex flex-row">+ <slot name="play-pause" size="small" />+ <slot name="controller" :waveform-props="{ features: [] }" />+ </div>+ </div>+ </div>+ </div>+</template>++<script>+import { computed } from '@nuxtjs/composition-api'++import VLicense from '~/components/License/VLicense.vue'++export default {+ name: 'Box',+ components: { VLicense },+ props: ['audio', 'size'],+ setup(props) {+ const isSmall = computed(() => props.size === 's')++ const width = computed(() => {+ const magnitude = {+ l: 13.25,+ m: 12.25,+ s: 9.75,+ }[props.size ?? 'm']+ return `${magnitude}rem`+ })++ return {+ isSmall,++ width,+ }+ },+}+</script>++<style>+.box-track .audio-controller {+ @apply flex-grow;+ --waveform-background-color: theme('colors.yellow');+}++.box-track .play-pause {+ @apply text-dark-charcoal bg-yellow border-yellow focus:border-pink;+}++.box-track .waveform {+ @apply h-10;+}+</style>diff --git a/src/components/AudioTrack/layouts/Full.vue b/src/components/AudioTrack/layouts/Full.vueindex d06bc1cb3..c30b65ffd 100644--- a/src/components/AudioTrack/layouts/Full.vue+++ b/src/components/AudioTrack/layouts/Full.vue@@ -2,38 +2,51 @@<div class="full-track w-full"><slot name="controller" />- <div class="flex flex-row justify-between items-top mx-16 my-6">- <div class="left-content flex flex-row items-top gap-6">- <slot name="play-pause" size="medium" />+ <div+ class="flex flex-row flex-wrap items-top mx-6 sm:mx-16 my-4 sm:my-6 gap-6"+ >+ <slot name="play-pause" :size="isSmall ? 'small' : 'medium'" />- <div class="audio-info">- <h1 class="text-3xl font-heading font-semibold">{{ audio.title }}</h1>- <div class="subtitle mt-1">- <i18n- as="span"- path="audio-track.creator"- class="font-semibold leading-snug mt-1"- >- <template #creator>- <a- class="text-pink hover:text-pink"- :href="audio.creator_url"- >{{ audio.creator }}</a- >- </template>- </i18n>- <span class="text-dark-charcoal-70">{{ $t('interpunct') }}</span>- {{ timeFmt(audio.duration) }}- </div>+ <div class="audio-info order-2 sm:order-1 w-full sm:w-auto">+ <h1 class="text-base sm:text-3xl font-heading font-semibold">+ {{ audio.title }}+ </h1>+ <div+ class="subtitle mt-1 flex flex-col sm:flex-row sm:items-center gap-2"+ >+ <i18n+ as="span"+ path="audio-track.creator"+ class="font-semibold leading-snug"+ >+ <template #creator>+ <a+ class="text-pink hover:text-pink p-px rounded-sm focus:outline-none focus:ring focus:ring-pink"+ :href="audio.creator_url"+ >{{ audio.creator }}</a+ >+ </template>+ </i18n>++ <span v-if="!isSmall" class="text-dark-charcoal-70">{{+ $t('interpunct')+ }}</span>++ <div>{{ timeFmt(audio.duration) }}</div></div></div>- <DownloadButton :formats="getFormats(audio)" />+ <DownloadButton+ class="ms-auto order-1 sm:order-2"+ :formats="getFormats(audio)"+ /></div></div></template><script>+import { computed } from '@nuxtjs/composition-api'+import DownloadButton from '~/components/DownloadButton.vue'export default {@@ -41,8 +54,8 @@ export default {components: {DownloadButton,},- props: ['audio'],- setup() {+ props: ['audio', 'size'],+ setup(props) {/*** Format the time as hh:mm:ss, dropping the hour part if it is zero.* @param {number} ms - the number of milliseconds in the duration@@ -56,6 +69,7 @@ export default {}return '--:--'}+/*** Returns specific display name for file format if there is a mapping for* provider's format display names (like Jamendo's `mp32` -> `MP3 V0`).@@ -72,6 +86,7 @@ export default {}return format ? format.toUpperCase() : ''}+/*** Creates a list of { extension_name, download_url } objects* for DownloadButton@@ -94,9 +109,14 @@ export default {}return formats}++ const isSmall = computed(() => props.size === 's')+return {timeFmt,getFormats,++ isSmall,}},}diff --git a/src/components/AudioTrack/layouts/Row.vue b/src/components/AudioTrack/layouts/Row.vueindex aca536719..f95e0d0e9 100644--- a/src/components/AudioTrack/layouts/Row.vue+++ b/src/components/AudioTrack/layouts/Row.vue@@ -20,7 +20,7 @@<div class="flex-shrink-0" :class="{ 'w-70': isMedium }"><NuxtLink:to="localePath(`/audio/${audio.id}`)"- class="font-heading font-semibold text-dark-charcoal hover:text-dark-charcoal"+ class="font-heading font-semibold text-dark-charcoal hover:text-dark-charcoal p-px rounded-sm focus:outline-none focus:ring focus:ring-pink":class="{'text-2xl': isMedium || isLarge,'leading-snug': isSmall,@@ -34,31 +34,29 @@'text-sr': isSmall,'leading-snug': isMedium || isLarge,'flex-col gap-2': isSmall || isMedium,- 'flex-row items-center justify-between': isLarge,+ 'flex-row items-center': isLarge,}"><div class="part-a">- <i18n tag="span" class="font-semibold" path="audio-track.creator">- <template #creator>{{ audio.creator }}</template>- </i18n>- <span v-if="isSmall || isLarge">- {{ $t('interpunct') }} {{ timeFmt(audio.duration) }}- <template v-if="audio.category">- {{ $t('interpunct') }}- {{ $t(`audio-categories.${audio.category}`) }}- </template>- </span>+ <i18n tag="span" path="audio-track.creator">+ <template #creator>{{ audio.creator }}</template> </i18n+ ><span v-if="isLarge" class="mx-2">{{ $t('interpunct') }}</span></div>- <div class="part-b inline-flex gap-1">- <div v-if="isMedium">- {{ timeFmt(audio.duration) }} {{ $t('interpunct') }}- <template v-if="audio.category">- {{ $t(`audio-categories.${audio.category}`) }}- {{ $t('interpunct') }}- </template>- </div>- <VLicense :license="audio.license" />+ <div class="part-b inline-flex">+ <span v-if="isSmall">+ <span+ class="text-dark-charcoal font-semibold bg-dark-charcoal-06 p-1 rounded-sm"+ >{{ timeFmt(audio.duration) }}</span+ ><span class="mx-2">{{ $t('interpunct') }}</span>+ </span>++ <span v-if="audio.category">+ <span>{{ $t(`audio-categories.${audio.category}`) }}</span+ ><span class="mx-2">{{ $t('interpunct') }}</span>+ </span>++ <VLicense :hide-name="isSmall" :license="audio.license" /></div></div></div>@@ -71,7 +69,10 @@}"><slot name="play-pause" :size="isLarge ? 'medium' : 'large'" />- <slot name="controller" />+ <slot+ name="controller"+ :waveform-props="{ features: ['timestamps', 'duration'] }"+ /></div></div></article>@@ -125,6 +126,7 @@ export default {.row-track .audio-controller {@apply flex-grow;+ --waveform-background-color: theme('colors.white');}.row-track .waveform {diff --git a/src/components/AudioTrack/meta/AudioTrack.stories.mdx b/src/components/AudioTrack/meta/AudioTrack.stories.mdxindex bba33b7b3..7556e56d0 100644--- a/src/components/AudioTrack/meta/AudioTrack.stories.mdx+++ b/src/components/AudioTrack/meta/AudioTrack.stories.mdx@@ -18,8 +18,8 @@ import wavWaveform from './wav-waveform.json'component={AudioTrack}argTypes={{format: {- defaultValue: 'ogg',- options: ['ogg', 'mp3', 'flac', 'wav'],+ defaultValue: 'mp3',+ options: ['mp3', 'ogg', 'flac', 'wav'],control: 'select',},layout: {@@ -29,12 +29,7 @@ import wavWaveform from './wav-waveform.json'},size: {defaultValue: 'm',- options: ['s', 'm', 'l', 'xl'],- control: 'select',- },- aspect: {- defaultValue: 'regular',- options: ['regular', 'wide'],+ options: ['s', 'm', 'l'],control: 'select',},audio: {@@ -46,7 +41,7 @@ import wavWaveform from './wav-waveform.json'export const commonAttrs = () => ({id: Math.floor(Math.random() * 1e9),creator: 'Wolfgang Amadeus Mozart',- creatorUrl: 'https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart',+ creator_url: 'https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart',category: 'music',thumbnail:'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Croce-Mozart-Detail.jpg/370px-Croce-Mozart-Detail.jpg',@@ -114,56 +109,139 @@ export const Template = (args, { argTypes }) => ({## LayoutsThe component can be rendered in a multiple different layouts, by-specifying a `layout`. The layout can further be customised by the `size` and-`aspect` props.+specifying a `layout`. The layout can further be customised by the `size` prop.### Full (default)+#### Size M (default)+<Canvas>- <Story name="Full">{Template.bind({})}</Story>+ <Story+ name="Full (medium)"+ args={+ {+ // layout: 'full', (default)+ // size: 'm', (default)+ }+ }+ >+ {Template.bind({})}+ </Story>+</Canvas>++#### Size S (mobile)++<Canvas>+ <Story+ name="Full (small)"+ args={{+ // layout: 'full', (default)+ size: 's',+ }}+ parameters={{+ viewport: { defaultViewport: 'mob' },+ }}+ >+ {Template.bind({})}+ </Story></Canvas>### Row-**Sizes:** S (small) and M (medium) and L (large)+#### Size L<Canvas><Story- name="Row (small)"+ name="Row (large)"args={{layout: 'row',- size: 's',+ size: 'l',}}>{Template.bind({})}</Story></Canvas>+#### Size M (default)+<Canvas><Storyname="Row (medium)"args={{layout: 'row',- size: 'm',+ // size: 'm', (default)}}>{Template.bind({})}</Story></Canvas>+#### Size S (mobile)+<Canvas><Story- name="Row (large)"+ name="Row (small)"args={{layout: 'row',+ size: 's',+ }}+ parameters={{+ viewport: { defaultViewport: 'mob' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++### Box++#### Sizes L and M (default)++Box sizes L and M are identical with the only difference being the `width`+dimension.++<Canvas>+ <Story+ name="Box (large)"+ args={{+ layout: 'box',size: 'l',}}>{Template.bind({})}</Story>+ <Story+ name="Box (medium)"+ args={{+ layout: 'box',+ // size: 'm', (default)+ }}+ >+ {Template.bind({})}+ </Story></Canvas>-### Global+#### Size S (mobile)++<Canvas>+ <Story+ name="Box (small)"+ args={{+ layout: 'box',+ size: 's',+ }}+ parameters={{+ viewport: { defaultViewport: 'mob' },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++### Global (mobile exclusive)++This version of the player is affixed to the bottom of the screen and retained+across pages when navigating.<Canvas><Story@@ -171,6 +249,9 @@ specifying a `layout`. The layout can further be customised by the `size` andargs={{layout: 'global',}}+ parameters={{+ viewport: { defaultViewport: 'mob' },+ }}>{Template.bind({})}</Story>diff --git a/src/components/AudioTrack/meta/Waveform.stories.mdx b/src/components/AudioTrack/meta/Waveform.stories.mdxindex c69eb5fd9..43a3360db 100644--- a/src/components/AudioTrack/meta/Waveform.stories.mdx+++ b/src/components/AudioTrack/meta/Waveform.stories.mdx@@ -47,7 +47,7 @@ Here 9 points are upsampled to as many as required to fill the viewport.peaks: [0.5, 1, 0.5, 0, 0.5, 1, 0.5, 0, 0.5], // triangular wave with 9 pointscurrentTime: 2,duration: 10,- showDuration: true,+ features: ['timestamps', 'duration'],}}>{Template.bind({})}@@ -68,7 +68,28 @@ Here 1000 points are downsampled to as many as required to fill the viewport.), // sine wave with 1000 pointscurrentTime: 2,duration: 10,- showDuration: true,+ features: ['timestamps', 'duration'],+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## Background++The background color for the waveform can be changed as required. To do so, set+the `--waveform-background-color` CSS custom property on the component or on the+`.waveform` class.++<Canvas>+ <Story+ name="Background"+ args={{+ peaks: [0.5, 1, 0.5, 0, 0.5],+ currentTime: 2,+ duration: 10,+ features: ['timestamps', 'duration'],+ style: { '--waveform-background-color': '#d7fcd4' },}}>{Template.bind({})}@@ -99,7 +120,7 @@ contains both the bars and the timestamps so the actual bar height is less thanpeaks: [0.5, 1, 0.5, 0, 0.5],currentTime: 2,duration: 10,- showDuration: true,+ features: ['timestamps', 'duration'],usableFrac: 0.5,}}>@@ -107,6 +128,26 @@ contains both the bars and the timestamps so the actual bar height is less than</Story></Canvas>+## Features++Certain features in the waveform can be enabled or disabled, as required, to+meet the design requirements and space/information density constraints. The+`features` prop allows you to enable only the needed features.++<Canvas>+ <Story+ name="Selective features"+ args={{+ peaks: [0.5, 1, 0.5, 0, 0.5],+ currentTime: 2,+ duration: 10,+ features: ['timestamps', 'duration'],+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>+## Message stateThe waveform bars are set to zero height when the `message` prop is passed. Theydiff --git a/src/components/Skeleton/AudioTrackSkeleton.vue b/src/components/Skeleton/AudioTrackSkeleton.vueindex eaf80ef41..dc4d33aa5 100644--- a/src/components/Skeleton/AudioTrackSkeleton.vue+++ b/src/components/Skeleton/AudioTrackSkeleton.vue@@ -55,9 +55,9 @@ export default {animation: shimmer 3s infinite linear;background: linear-gradient(to right,- theme('colors.dark-charcoal-10') 4%,- theme('colors.dark-charcoal-20') 25%,- theme('colors.dark-charcoal-10') 36%+ theme('colors.dark-charcoal.10') 4%,+ theme('colors.dark-charcoal.20') 25%,+ theme('colors.dark-charcoal.10') 36%);background-size: 1000px 100%;}diff --git a/src/components/Skeleton/VBone.vue b/src/components/Skeleton/VBone.vueindex d64685ae0..9802aec41 100644--- a/src/components/Skeleton/VBone.vue+++ b/src/components/Skeleton/VBone.vue@@ -23,9 +23,9 @@ export default {animation: shimmer 3s infinite linear;background: linear-gradient(to right,- theme('colors.dark-charcoal-10') 4%,- theme('colors.dark-charcoal-20') 25%,- theme('colors.dark-charcoal-10') 36%+ theme('colors.dark-charcoal.10') 4%,+ theme('colors.dark-charcoal.20') 25%,+ theme('colors.dark-charcoal.10') 36%);background-size: 1000px 100%;}diff --git a/src/constants/screens.js b/src/constants/screens.jsindex 745ea9fcf..98a5a4bbc 100644--- a/src/constants/screens.js+++ b/src/constants/screens.js@@ -2,12 +2,25 @@* Mapping of a breakpoint name to the lower-bound of its screen-width range* @type {Map<string, number>}*/-export const SCREEN_SIZES = new Map()-SCREEN_SIZES.set('2xl', 1536)-SCREEN_SIZES.set('xl', 1280)-SCREEN_SIZES.set('lg', 1024)-SCREEN_SIZES.set('md', 768)-SCREEN_SIZES.set('sm', 640)+export const SCREEN_SIZES = new Map([+ ['2xl', 1536],+ ['xl', 1280],+ ['lg', 1024],+ ['md', 768],+ ['sm', 640],+])++export const VIEWPORTS = Object.fromEntries(+ [...Array.from(SCREEN_SIZES), ['mob', 400]].map(([key, val]) => {+ return [+ key,+ {+ name: `${key} (${val}px)`,+ styles: { width: `${val}px`, height: '768px' },+ },+ ]+ })+)/*** Get the breakpoint in which the screen with the given width lies.diff --git a/tailwind.config.js b/tailwind.config.jsindex 9aa62a78c..b33b4c8ef 100644--- a/tailwind.config.js+++ b/tailwind.config.js@@ -28,7 +28,6 @@ module.exports = {// Brandyellow: '#ffe033',- 'dark-charcoal': '#30272e',pink: '#c52b9b',primary: '#3e58e1', // will change to pink after redesign launch// Active@@ -45,21 +44,25 @@ module.exports = {'admin-gray': '#dcdcde',// Dark Charcoal- 'dark-charcoal-06': '#f3f2f2',- 'dark-charcoal-10': '#eae9ea',- 'dark-charcoal-20': '#d6d4d5',- 'dark-charcoal-30': '#c1bec0',- 'dark-charcoal-40': '#aca9ab',- 'dark-charcoal-50': '#989397',- 'dark-charcoal-60': '#837d82',- 'dark-charcoal-70': '#6e686d',- 'dark-charcoal-80': '#595258',+ 'dark-charcoal': {+ DEFAULT: '#30272e',+ '06': '#f3f2f2',+ 10: '#eae9ea',+ 20: '#d6d4d5',+ 30: '#c1bec0',+ 40: '#aca9ab',+ 50: '#989397',+ 60: '#837d82',+ 70: '#6e686d',+ 80: '#595258',+ },// Special keywordstx: 'transparent',curr: 'currentColor',},fill: (theme) => theme('colors'),+ stroke: (theme) => theme('colors'),spacing: {// Constants'0.5px': '0.5px',@@ -196,6 +199,7 @@ module.exports = {},boxShadow: {ring: 'inset 0 0 0 1px white',+ 'ring-1.5': 'inset 0 0 0 1.5px white',},},},@@ -211,6 +215,7 @@ module.exports = {borderWidth: ['focus', 'focus-within'],padding: ['focus', 'focus-within'],boxShadow: ['focus', 'active'],+ display: ['group-hover', 'group-focus'],},},plugins: [require('tailwindcss-rtl')],