Skip to content

Commit

Permalink
Move the script sections to the top of the components (#4762)
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat authored Aug 19, 2024
1 parent 975c543 commit 1186767
Show file tree
Hide file tree
Showing 107 changed files with 2,970 additions and 2,970 deletions.
12 changes: 6 additions & 6 deletions frontend/src/components/LoadingIcon.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "LoadingIcon",
}
</script>

<template>
<div class="lds-ring" data-testid="lds-ring">
<div />
Expand All @@ -7,12 +13,6 @@
</div>
</template>

<script lang="ts">
export default {
name: "LoadingIcon",
}
</script>

<style scoped>
.lds-ring {
display: inline-block;
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/components/TableSortIcon.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<script lang="ts">
import { defineComponent } from "vue"
export default defineComponent({
name: "TableSortIcon",
props: {
active: {
type: Boolean,
required: true,
},
},
})
</script>

<template>
<div class="flex flex-col" :class="[active ? 'text-default' : 'text-gray']">
<svg
Expand All @@ -23,17 +37,3 @@
</svg>
</div>
</template>

<script lang="ts">
import { defineComponent } from "vue"
export default defineComponent({
name: "TableSortIcon",
props: {
active: {
type: Boolean,
required: true,
},
},
})
</script>
74 changes: 37 additions & 37 deletions frontend/src/components/VAudioThumbnail/VAudioThumbnail.vue
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
<template>
<!-- Should be wrapped by a fixed-width parent -->
<div
class="relative h-0 w-full overflow-hidden bg-complementary pt-full"
:title="helpText"
>
<!-- Programmatic thumbnail -->
<svg
class="absolute inset-0"
:class="{ hidden: shouldBlur && isOk }"
:viewBox="`0 0 ${canvasSize} ${canvasSize}`"
>
<template v-for="i in dotCount">
<circle
v-for="j in dotCount"
:key="`${i}-${j}`"
class="fill-gray-12"
:cx="offset(j)"
:cy="offset(i)"
:r="radius(i, j)"
/>
</template>
</svg>

<div v-show="audio.thumbnail && isOk" class="thumbnail absolute inset-0">
<img
ref="imgEl"
class="h-full w-full overflow-clip object-cover object-center duration-200 motion-safe:transition-[filter,transform]"
:class="{ 'scale-150 blur-image': shouldBlur }"
:src="audio.thumbnail"
:alt="helpText"
@load="handleLoad"
/>
</div>
</div>
</template>

<script lang="ts">
import { useI18n } from "#imports"
Expand Down Expand Up @@ -125,3 +88,40 @@ export default defineComponent({
},
})
</script>

<template>
<!-- Should be wrapped by a fixed-width parent -->
<div
class="relative h-0 w-full overflow-hidden bg-complementary pt-full"
:title="helpText"
>
<!-- Programmatic thumbnail -->
<svg
class="absolute inset-0"
:class="{ hidden: shouldBlur && isOk }"
:viewBox="`0 0 ${canvasSize} ${canvasSize}`"
>
<template v-for="i in dotCount">
<circle
v-for="j in dotCount"
:key="`${i}-${j}`"
class="fill-gray-12"
:cx="offset(j)"
:cy="offset(i)"
:r="radius(i, j)"
/>
</template>
</svg>

<div v-show="audio.thumbnail && isOk" class="thumbnail absolute inset-0">
<img
ref="imgEl"
class="h-full w-full overflow-clip object-cover object-center duration-200 motion-safe:transition-[filter,transform]"
:class="{ 'scale-150 blur-image': shouldBlur }"
:src="audio.thumbnail"
:alt="helpText"
@load="handleLoad"
/>
</div>
</div>
</template>
66 changes: 33 additions & 33 deletions frontend/src/components/VAudioTrack/VAudioControl.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
<template>
<VIconButton
:tabindex="isTabbable ? 0 : -1"
class="audio-control"
:size="buttonSize"
:variant="layout === 'box' ? 'transparent-dark' : 'filled-dark'"
:icon-props="icon === undefined ? undefined : { name: icon, size: iSize }"
:label="$t(label)"
:connections="connections"
:disabled="!doneHydrating"
@click.stop.prevent="handleClick"
@mousedown="handleMouseDown"
>
<template #default>
<svg
v-if="isLoading"
class="loading p-2"
:class="`w-${iSize} h-${iSize}`"
xmlns="http://www.w3.org/2000/svg"
overflow="visible"
viewBox="0 0 12 12"
>
<circle cx="6" cy="6" r="6" vector-effect="non-scaling-stroke" />
<path
d="m 6 0 a 6 6 0 0 1 6 6"
stroke="white"
vector-effect="non-scaling-stroke"
/>
</svg>
</template>
</VIconButton>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from "vue"
Expand Down Expand Up @@ -178,6 +145,39 @@ export default defineComponent({
})
</script>

<template>
<VIconButton
:tabindex="isTabbable ? 0 : -1"
class="audio-control"
:size="buttonSize"
:variant="layout === 'box' ? 'transparent-dark' : 'filled-dark'"
:icon-props="icon === undefined ? undefined : { name: icon, size: iSize }"
:label="$t(label)"
:connections="connections"
:disabled="!doneHydrating"
@click.stop.prevent="handleClick"
@mousedown="handleMouseDown"
>
<template #default>
<svg
v-if="isLoading"
class="loading p-2"
:class="`w-${iSize} h-${iSize}`"
xmlns="http://www.w3.org/2000/svg"
overflow="visible"
viewBox="0 0 12 12"
>
<circle cx="6" cy="6" r="6" vector-effect="non-scaling-stroke" />
<path
d="m 6 0 a 6 6 0 0 1 6 6"
stroke="white"
vector-effect="non-scaling-stroke"
/>
</svg>
</template>
</VIconButton>
</template>

<style scoped>
@keyframes spinAnimation {
from {
Expand Down
100 changes: 50 additions & 50 deletions frontend/src/components/VAudioTrack/VAudioTrack.vue
Original file line number Diff line number Diff line change
@@ -1,53 +1,3 @@
<template>
<!-- eslint-disable vue/use-v-on-exact -->
<Component
:is="isComposite ? VLink : 'div'"
v-bind="containerAttributes"
class="audio-track group block overflow-hidden rounded-sm ring-pink-8 hover:no-underline"
:aria-label="ariaLabel"
:role="isComposite ? 'application' : undefined"
@keydown.shift.tab.exact="$emit('shift-tab', $event)"
@keydown="handleKeydown"
@blur="handleBlur"
@mousedown="handleMousedown"
@focus="handleFocus"
>
<Component
:is="layoutComponent"
:audio="audio"
:size="layoutSize"
:status="status"
:current-time="currentTime"
>
<template #controller="waveformProps">
<VWaveform
ref="waveformRef"
v-bind="waveformProps"
:is-parent-seeking="isSeeking"
:peaks="audio.peaks"
:audio-id="audio.id"
:current-time="currentTime"
:duration="duration"
:message="message"
@seeked="handleSeeked"
@toggle-playback="handleToggle"
@blur="handleWaveformBlur"
@focus="handleWaveformFocus"
/>
</template>

<template #audio-control="audioControlProps">
<VAudioControl
ref="audioControlRef"
:status="status"
v-bind="audioControlProps"
@toggle="handleToggle"
/>
</template>
</Component>
</Component>
</template>

<script lang="ts">
import { firstParam, useI18n, useRoute } from "#imports"
Expand Down Expand Up @@ -607,3 +557,53 @@ export default defineComponent({
},
})
</script>

<template>
<!-- eslint-disable vue/use-v-on-exact -->
<Component
:is="isComposite ? VLink : 'div'"
v-bind="containerAttributes"
class="audio-track group block overflow-hidden rounded-sm ring-pink-8 hover:no-underline"
:aria-label="ariaLabel"
:role="isComposite ? 'application' : undefined"
@keydown.shift.tab.exact="$emit('shift-tab', $event)"
@keydown="handleKeydown"
@blur="handleBlur"
@mousedown="handleMousedown"
@focus="handleFocus"
>
<Component
:is="layoutComponent"
:audio="audio"
:size="layoutSize"
:status="status"
:current-time="currentTime"
>
<template #controller="waveformProps">
<VWaveform
ref="waveformRef"
v-bind="waveformProps"
:is-parent-seeking="isSeeking"
:peaks="audio.peaks"
:audio-id="audio.id"
:current-time="currentTime"
:duration="duration"
:message="message"
@seeked="handleSeeked"
@toggle-playback="handleToggle"
@blur="handleWaveformBlur"
@focus="handleWaveformFocus"
/>
</template>

<template #audio-control="audioControlProps">
<VAudioControl
ref="audioControlRef"
:status="status"
v-bind="audioControlProps"
@toggle="handleToggle"
/>
</template>
</Component>
</Component>
</template>
62 changes: 31 additions & 31 deletions frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
<template>
<div
class="audio-track relative rounded"
:aria-label="ariaLabel"
role="region"
>
<VGlobalLayout :audio="audio">
<template #controller="waveformProps">
<VWaveform
v-bind="waveformProps"
:peaks="audio.peaks"
:audio-id="audio.id"
:current-time="currentTime"
:duration="duration"
:message="message"
@seeked="handleSeeked"
@toggle-playback="handleToggle"
/>
</template>

<template #audio-control="audioControlProps">
<VAudioControl
v-bind="audioControlProps"
:status="status"
@toggle="handleToggle"
/>
</template>
</VGlobalLayout>
</div>
</template>

<script lang="ts">
import { useI18n, useNuxtApp } from "#imports"
Expand Down Expand Up @@ -268,3 +237,34 @@ export default defineComponent({
},
})
</script>

<template>
<div
class="audio-track relative rounded"
:aria-label="ariaLabel"
role="region"
>
<VGlobalLayout :audio="audio">
<template #controller="waveformProps">
<VWaveform
v-bind="waveformProps"
:peaks="audio.peaks"
:audio-id="audio.id"
:current-time="currentTime"
:duration="duration"
:message="message"
@seeked="handleSeeked"
@toggle-playback="handleToggle"
/>
</template>

<template #audio-control="audioControlProps">
<VAudioControl
v-bind="audioControlProps"
:status="status"
@toggle="handleToggle"
/>
</template>
</VGlobalLayout>
</div>
</template>
Loading

0 comments on commit 1186767

Please sign in to comment.