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

Commit

Permalink
Add option to show duration at the right edge
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Aug 19, 2021
1 parent e5cf41e commit f930b38
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/AudioTrack/Waveform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
>
{{ timeFmt(seekPercentage * duration) }}
</div>
<div
v-if="showDuration"
class="duration absolute top-1 right-0 px-1 font-bold text-sm pointer-events-none"
>
{{ timeFmt(duration) }}
</div>
</div>
</template>

Expand Down Expand Up @@ -99,6 +105,13 @@ export default {
type: Number,
default: 0,
},
/**
* whether to show the duration of the audio at the ending edge
*/
showDuration: {
type: Boolean,
default: false,
},
},
data: () => ({
barWidth: 2, // px
Expand Down Expand Up @@ -202,4 +215,9 @@ export default {
.seek {
left: var(--seek-time-left);
}
.duration {
/* opaque equivalent of dark-charcoal-04 on top of white */
background-color: rgb(247, 246, 247);
}
</style>
2 changes: 2 additions & 0 deletions src/components/AudioTrack/meta/Waveform.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Here 9 points are upsampled to as many as required to fill the viewport.
isReady: true,
currentTime: 2,
duration: 10,
showDuration: true,
}}
>
{Template.bind({})}
Expand All @@ -69,6 +70,7 @@ Here 1000 points are downsampled to as many as required to fill the viewport.
isReady: true,
currentTime: 2,
duration: 10,
showDuration: true,
}}
>
{Template.bind({})}
Expand Down

0 comments on commit f930b38

Please sign in to comment.