Skip to content

Commit 9935812

Browse files
committed
Format components directory
1 parent 6e583f2 commit 9935812

File tree

170 files changed

+1554
-1320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+1554
-1320
lines changed

frontend/viewer/src/lib/components/ListItem.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
'disabled:pointer-events-none disabled:contrast-[0.8]',
4242
loading && 'animate-pulse',
4343
skeleton && 'cursor-default hover:bg-transparent pointer-events-none shadow-none',
44-
className)}
44+
className,
45+
)}
4546
role="row"
4647
bind:this={ref}
4748
{...restProps}
4849
>
4950
{#if typeof icon === 'string'}
50-
<Icon {icon} class="size-6"/>
51+
<Icon {icon} class="size-6" />
5152
{:else}
5253
{@render icon?.()}
5354
{/if}
5455
<div class="flex flex-col grow">
5556
{@render children?.()}
5657
</div>
5758
{@render actions?.()}
58-
5959
</button>

frontend/viewer/src/lib/components/Loading.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
66
type Props = HTMLAttributes<HTMLSpanElement>;
77
8-
let {
9-
class: className,
10-
...restProps
11-
}: Props = $props();
8+
let {class: className, ...restProps}: Props = $props();
129
</script>
1310

1411
<Icon icon="i-mdi-loading" class={cn('animate-spin', className)} {...restProps} />

frontend/viewer/src/lib/components/OpenInFieldWorksButton.svelte

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
import {Icon} from './ui/icon';
1212
1313
type Props = {
14-
entry: IEntry
14+
entry: IEntry;
1515
} & ButtonProps;
1616
17-
const {
18-
entry,
19-
class: className,
20-
...rest
21-
}: Props = $props();
17+
const {entry, class: className, ...rest}: Props = $props();
2218
2319
const appLauncher = useAppLauncherService();
2420
const projectContext = useProjectContext();
@@ -36,22 +32,31 @@
3632
}
3733
}
3834
if (opened) {
39-
AppNotification.displayAction($t`This project is now open in FieldWorks. To continue working in FieldWorks Lite, close the project in FieldWorks and click Reopen.`, {
40-
label: $t`Reopen`,
41-
callback: () => window.location.reload()
42-
}, 'warning');
35+
AppNotification.displayAction(
36+
$t`This project is now open in FieldWorks. To continue working in FieldWorks Lite, close the project in FieldWorks and click Reopen.`,
37+
{
38+
label: $t`Reopen`,
39+
callback: () => window.location.reload(),
40+
},
41+
'warning',
42+
);
4343
} else {
4444
AppNotification.display($t`Unable to open in FieldWorks`, 'error');
4545
}
4646
}
4747
48-
const mergedProps = $derived(mergeProps({
49-
onclick: openInFlex,
50-
}, rest));
48+
const mergedProps = $derived(
49+
mergeProps(
50+
{
51+
onclick: openInFlex,
52+
},
53+
rest,
54+
),
55+
);
5156
</script>
5257

5358
<!--button must be a link otherwise it won't follow the redirect to a protocol handler-->
54-
<button class={cn(buttonVariants({ variant: 'ghost'}), className)} {...mergedProps}>
59+
<button class={cn(buttonVariants({variant: 'ghost'}), className)} {...mergedProps}>
5560
<Icon src={flexLogo} alt={$t`FieldWorks logo`} />
5661
{$t`Open in FieldWorks`}
5762
</button>

frontend/viewer/src/lib/components/ThemePicker.svelte

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
1111
const themes = [msg`green`, msg`blue`, msg`rose`, msg`orange`, msg`violet`, msg`stone`];
1212
let {
13-
buttonProps = {}
13+
buttonProps = {},
1414
}: {
15-
buttonProps?: Partial<ButtonProps>
15+
buttonProps?: Partial<ButtonProps>;
1616
} = $props();
17-
1817
</script>
1918

2019
<Popover.Root>
2120
<Popover.Trigger>
2221
{#snippet child({props})}
2322
<Button variant="ghost" size="icon" {...mergeProps(props, buttonProps)}>
24-
<Icon icon="i-mdi-white-balance-sunny"
23+
<Icon
24+
icon="i-mdi-white-balance-sunny"
2525
class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 text-primary"
2626
/>
27-
<Icon icon="i-mdi-weather-night"
27+
<Icon
28+
icon="i-mdi-weather-night"
2829
class="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 text-primary"
2930
/>
3031
<span class="sr-only">{$t`Choose theme`}</span>
@@ -55,12 +56,14 @@
5556
>
5657
<span
5758
data-theme={themeName}
58-
class={cn('flex size-5 shrink-0 -translate-x-1 items-center justify-center rounded-full bg-primary',
59-
mode.current === 'dark' && 'dark',
60-
mode.current === 'light' && 'light')}
59+
class={cn(
60+
'flex size-5 shrink-0 -translate-x-1 items-center justify-center rounded-full bg-primary',
61+
mode.current === 'dark' && 'dark',
62+
mode.current === 'light' && 'light',
63+
)}
6164
>
6265
{#if isActive}
63-
<Icon icon="i-mdi-check" class="text-white size-4"/>
66+
<Icon icon="i-mdi-check" class="text-white size-4" />
6467
{/if}
6568
</span>
6669
<span class="capitalize">
@@ -105,5 +108,3 @@
105108
</div>
106109
</Popover.Content>
107110
</Popover.Root>
108-
109-

frontend/viewer/src/lib/components/audio/AudioDialog.svelte

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,34 @@
1616
open = $bindable(false),
1717
title = undefined,
1818
onSubmit = () => {},
19-
children = undefined
20-
} : {
21-
open: boolean,
22-
title?: string,
23-
onSubmit?: (audioId: string) => void,
24-
children?: Snippet
19+
children = undefined,
20+
}: {
21+
open: boolean;
22+
title?: string;
23+
onSubmit?: (audioId: string) => void;
24+
children?: Snippet;
2525
} = $props();
26-
useBackHandler({addToStack: () => open, onBack: () => open = false, key: 'audio-dialog'});
26+
useBackHandler({addToStack: () => open, onBack: () => (open = false), key: 'audio-dialog'});
2727
const lexboxApi = useLexboxApi();
2828
2929
let submitting = $state(false);
3030
let selectedFile = $state<File>();
3131
let finalAudio = $state<File>();
3232
const tooBig = $derived((finalAudio?.size ?? 0) > 10 * 1024 * 1024);
3333
34-
watch(() => open, () => {
35-
if (!open) reset();
36-
});
34+
watch(
35+
() => open,
36+
() => {
37+
if (!open) reset();
38+
},
39+
);
3740
38-
watch(() => selectedFile, () => {
39-
if (!selectedFile) finalAudio = undefined;
40-
})
41+
watch(
42+
() => selectedFile,
43+
() => {
44+
if (!selectedFile) finalAudio = undefined;
45+
},
46+
);
4147
4248
function close() {
4349
open = false;
@@ -71,10 +77,10 @@
7177
const response = await lexboxApi.saveFile(finalAudio, {filename: finalAudio.name, mimeType: finalAudio.type});
7278
switch (response.result) {
7379
case UploadFileResult.SavedLocally:
74-
AppNotification.display($t`Audio saved locally`, { type: 'success', timeout: 'short' });
80+
AppNotification.display($t`Audio saved locally`, {type: 'success', timeout: 'short'});
7581
break;
7682
case UploadFileResult.SavedToLexbox:
77-
AppNotification.display($t`Audio saved and uploaded to Lexbox`, { type: 'success', timeout: 'short' });
83+
AppNotification.display($t`Audio saved and uploaded to Lexbox`, {type: 'success', timeout: 'short'});
7884
break;
7985
case UploadFileResult.TooBig:
8086
throw new Error($t`File too big`);
@@ -130,10 +136,11 @@
130136
}
131137
</script>
132138

133-
134139
<Dialog.Root bind:open>
135-
<Dialog.DialogContent onOpenAutoFocus={(e) => e.preventDefault()} class={cn('sm:min-h-[min(calc(100%-16px),30rem)]',
136-
children ? 'grid-rows-[auto_auto_1fr]' : 'grid-rows-[auto_1fr]')}>
140+
<Dialog.DialogContent
141+
onOpenAutoFocus={(e) => e.preventDefault()}
142+
class={cn('sm:min-h-[min(calc(100%-16px),30rem)]', children ? 'grid-rows-[auto_auto_1fr]' : 'grid-rows-[auto_1fr]')}
143+
>
137144
<Dialog.DialogHeader>
138145
<Dialog.DialogTitle>{title || $t`Add audio`}</Dialog.DialogTitle>
139146
</Dialog.DialogHeader>
@@ -142,19 +149,18 @@
142149
<div>{@render children?.()}</div>
143150
{/if}
144151
{#if !selectedFile}
145-
<AudioProvider {onFileSelected} {onRecordingComplete}/>
152+
<AudioProvider {onFileSelected} {onRecordingComplete} />
146153
{:else}
147-
<AudioEditor audio={selectedFile} bind:finalAudio onDiscard={onDiscard}/>
154+
<AudioEditor audio={selectedFile} bind:finalAudio {onDiscard} />
148155
{#if tooBig}
149156
<p class="text-destructive text-lg text-end">{$t`File too big`}</p>
150157
{/if}
151158
<Dialog.DialogFooter>
152-
<Button onclick={() => open = false} variant="secondary">{$t`Cancel`}</Button>
159+
<Button onclick={() => (open = false)} variant="secondary">{$t`Cancel`}</Button>
153160
<Button onclick={() => submitAudio()} disabled={tooBig || !finalAudio} loading={submitting}>
154161
{$t`Save audio`}
155162
</Button>
156163
</Dialog.DialogFooter>
157164
{/if}
158165
</Dialog.DialogContent>
159166
</Dialog.Root>
160-

frontend/viewer/src/lib/components/audio/audio-editor.svelte

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
onDiscard: () => void;
1818
};
1919
20-
let {
21-
audio,
22-
finalAudio = $bindable(undefined),
23-
onDiscard
24-
}: Props = $props();
20+
let {audio, finalAudio = $bindable(undefined), onDiscard}: Props = $props();
2521
2622
let audioApi = $state<WaveSurfer>();
2723
let playing = $state(false);
@@ -30,33 +26,45 @@
3026
const formattedDuration = $derived(duration ? formatDigitalDuration({seconds: duration}) : 'unknown');
3127
let ffmpegApi: FFmpegApi | undefined;
3228
33-
let ffmpegFile = resource(() => audio, async (audio, _, {signal}) => {
34-
ffmpegApi ??= await FFmpegApi.create();
35-
return await ffmpegApi.toFFmpegFile(audio, AbortSignal.any([signal, abortController.signal]));
36-
});
29+
let ffmpegFile = resource(
30+
() => audio,
31+
async (audio, _, {signal}) => {
32+
ffmpegApi ??= await FFmpegApi.create();
33+
return await ffmpegApi.toFFmpegFile(audio, AbortSignal.any([signal, abortController.signal]));
34+
},
35+
);
3736
38-
let flacFile = resource(() => [ffmpegFile.current], async ([file], _, {signal}) => {
39-
if (!file) return;
40-
ffmpegApi ??= await FFmpegApi.create();
41-
return await ffmpegApi.convertToFlac(file, AbortSignal.any([signal, abortController.signal]));
42-
});
37+
let flacFile = resource(
38+
() => [ffmpegFile.current],
39+
async ([file], _, {signal}) => {
40+
if (!file) return;
41+
ffmpegApi ??= await FFmpegApi.create();
42+
return await ffmpegApi.convertToFlac(file, AbortSignal.any([signal, abortController.signal]));
43+
},
44+
);
4345
44-
let readFile = resource(() => [flacFile.current], async ([file], _, {signal}) => {
45-
if (!file) return;
46-
ffmpegApi ??= await FFmpegApi.create();
47-
return await ffmpegApi.readFile(file, AbortSignal.any([signal, abortController.signal]));
48-
});
46+
let readFile = resource(
47+
() => [flacFile.current],
48+
async ([file], _, {signal}) => {
49+
if (!file) return;
50+
ffmpegApi ??= await FFmpegApi.create();
51+
return await ffmpegApi.readFile(file, AbortSignal.any([signal, abortController.signal]));
52+
},
53+
);
4954
50-
watch(() => [readFile.current, readFile.loading] as const, ([file, loading]) => {
51-
if (loading || !file) {
52-
finalAudio = undefined;
53-
} else {
54-
finalAudio = file;
55-
}
56-
});
55+
watch(
56+
() => [readFile.current, readFile.loading] as const,
57+
([file, loading]) => {
58+
if (loading || !file) {
59+
finalAudio = undefined;
60+
} else {
61+
finalAudio = file;
62+
}
63+
},
64+
);
5765
5866
const loading = $derived(ffmpegFile.loading || flacFile.loading || readFile.loading);
59-
const error = $derived((ffmpegFile.error || flacFile.error || readFile.error)?.toString());
67+
const error = $derived((ffmpegFile.error || flacFile.error || readFile.error)?.toString());
6068
6169
const abortController = new AbortController();
6270
onDestroy(() => {
@@ -81,28 +89,30 @@
8189

8290
<div class="flex flex-col gap-4 items-center justify-center">
8391
{#if loading || !finalAudio}
84-
<Loading class="self-center justify-self-center size-16"/>
92+
<Loading class="self-center justify-self-center size-16" />
8593
{:else}
86-
<span class="inline-grid grid-cols-[auto_auto_1rem_auto_auto] gap-2 items-baseline">
87-
<Label class="justify-self-end">{$t`Length:`}</Label> <span>{$t`${formattedDuration}`}</span>
88-
<span></span>
89-
<Label class="justify-self-end">{$t`Size:`}</Label> <span>{$t`${mb} MB`}</span>
90-
{#if finalAudio.name}
91-
<Label class="justify-self-end">{$t`File name:`}</Label>
92-
<span class="col-span-4">{$t`${finalAudio.name}`}</span>
93-
{/if}
94-
<DevContent>
95-
<Label class="justify-self-end">{$t`Type:`}</Label>
96-
<span class="col-span-4">{$t`${finalAudio.type}`}</span>
97-
</DevContent>
98-
</span>
94+
<span class="inline-grid grid-cols-[auto_auto_1rem_auto_auto] gap-2 items-baseline">
95+
<Label class="justify-self-end">{$t`Length:`}</Label> <span>{$t`${formattedDuration}`}</span>
96+
<span></span>
97+
<Label class="justify-self-end">{$t`Size:`}</Label> <span>{$t`${mb} MB`}</span>
98+
{#if finalAudio.name}
99+
<Label class="justify-self-end">{$t`File name:`}</Label>
100+
<span class="col-span-4">{$t`${finalAudio.name}`}</span>
101+
{/if}
102+
<DevContent>
103+
<Label class="justify-self-end">{$t`Type:`}</Label>
104+
<span class="col-span-4">{$t`${finalAudio.type}`}</span>
105+
</DevContent>
106+
</span>
99107
<!-- contain-inline-size prevents wavesurfer from freaking out inside a grid -->
100108
<!-- pb ensures the waveform timeline is in the bounds of this container -->
101109
<div class="w-full h-32 pb-3 contain-inline-size border-y">
102-
<Waveform audio={finalAudio} bind:playing bind:audioApi bind:duration showTimeline autoplay class="size-full"/>
110+
<Waveform audio={finalAudio} bind:playing bind:audioApi bind:duration showTimeline autoplay class="size-full" />
103111
</div>
104112
<div class="flex gap-2">
105-
<Button onclick={() => downloadAudio()} disabled={!finalAudio} variant="secondary" icon="i-mdi-download">{$t`Download`}</Button>
113+
<Button onclick={() => downloadAudio()} disabled={!finalAudio} variant="secondary" icon="i-mdi-download"
114+
>{$t`Download`}</Button
115+
>
106116
<Button variant="secondary" icon="i-mdi-close" onclick={onDiscard} disabled={!audio}>{$t`Discard`}</Button>
107117
<Button
108118
icon={playing ? 'i-mdi-pause' : 'i-mdi-play'}

0 commit comments

Comments
 (0)