Skip to content

Commit 6a36ace

Browse files
committed
Deleted unused code and the remaining one prettier
1 parent eaa5955 commit 6a36ace

File tree

15 files changed

+84
-101
lines changed

15 files changed

+84
-101
lines changed

src/App.vue

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
<script setup lang="ts">
32
import ThemeSwitch from './components/ThemeSwitch.vue';
43
import Nav from './components/Nav.vue';
54
import FileUpload from './components/FileUpload.vue';
65
import FileItem from './components/FileItem.vue';
76
import { useFileDataStore } from './stores/fileData';
87
import { storeToRefs } from 'pinia';
9-
import type { FileObj } from './file';
8+
import type { FileObj } from './types/file';
109
import { computed, ref, watch } from 'vue';
1110
import { useImageCompression } from './composables/useImageCompression';
1211
import { useZipCompression } from './composables/useZipCompression';
@@ -57,57 +56,54 @@ watch(anyUncompressed, async (newVal) => {
5756
isZipCompressing.value = false;
5857
}
5958
});
60-
6159
</script>
6260

6361
<template>
6462
<header>
6563
<Nav />
6664
<ThemeSwitch />
67-
<h1 class="title">{{ $t("translation.header") }}</h1>
65+
<h1 class="title">{{ $t('translation.header') }}</h1>
6866
</header>
6967

7068
<main>
7169
<div class="explanation-wrapper">
72-
<p class="explanation">{{ $t("translation.subtitle") }}</p>
70+
<p class="explanation">{{ $t('translation.subtitle') }}</p>
7371
<a
7472
href="https://nomanssky.fandom.com/wiki/Special:Upload?multiple=true"
7573
role="button"
7674
target="_blank"
7775
rel="noopener noreferrer"
78-
>{{ $t("translation.buttonwiki") }}</a
76+
>{{ $t('translation.buttonwiki') }}</a
7977
>
8078
</div>
81-
<h2 class="subheading">{{ $t("translation.input") }}</h2>
79+
<h2 class="subheading">{{ $t('translation.input') }}</h2>
8280
<FileUpload />
8381

84-
<h2 class="subheading">{{ $t("translation.filelist") }}</h2>
82+
<h2 class="subheading">{{ $t('translation.filelist') }}</h2>
8583
<div class="buttons">
8684
<button
8785
:aria-busy="isCompressing"
8886
:class="{ 'is-success': files.length && !anyUncompressed }"
8987
:disabled="!files.length || !anyUncompressed"
9088
@click="compressFiles"
9189
>
92-
{{ files.length && !anyUncompressed
93-
? $t("translation.allcompressed")
94-
: $t("translation.compress")
95-
}} </button>
90+
{{ files.length && !anyUncompressed ? $t('translation.allcompressed') : $t('translation.compress') }}
91+
</button>
9692
<a
9793
:aria-busy="isZipCompressing"
9894
:aria-disabled="!zipData"
9995
:href="zipData || undefined"
10096
role="button"
10197
download
10298
>
103-
{{ $t("translation.downloadzip") }}
99+
{{ $t('translation.downloadzip') }}
104100
</a>
105101
<button
106102
:disabled="!files.length"
107103
class="secondary"
108104
@click="files = []"
109105
>
110-
{{ $t("translation.clearlist") }}
106+
{{ $t('translation.clearlist') }}
111107
</button>
112108
</div>
113109
<div class="file-list">
@@ -174,4 +170,4 @@ watch(anyUncompressed, async (newVal) => {
174170
margin: 0;
175171
}
176172
}
177-
</style>
173+
</style>

src/components/FileItem.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ const computeFileSize = (size: number) =>
3939
/>
4040
</a>
4141
<div>
42-
<div><span class="field-title">{{ $t("translation.name") }}</span> {{ fileObj.file.name }}</div>
43-
<div><span class="field-title">{{ $t("translation.originalsize") }}</span> {{ computeFileSize(orgSize) }}MB</div>
44-
<div v-if="compSize"><span class="field-title">{{ $t("translation.compressedsize") }}</span> {{ computeFileSize(compSize) }}MB</div>
42+
<div>
43+
<span class="field-title">{{ $t('translation.name') }}</span> {{ fileObj.file.name }}
44+
</div>
45+
<div>
46+
<span class="field-title">{{ $t('translation.originalsize') }}</span> {{ computeFileSize(orgSize) }}MB
47+
</div>
48+
<div v-if="compSize">
49+
<span class="field-title">{{ $t('translation.compressedsize') }}</span> {{ computeFileSize(compSize) }}MB
50+
</div>
4551
<div
4652
v-if="fileObj.isTooLarge"
4753
class="error"
4854
>
49-
<span class="field-title">{{ $t("translation.error") }}</span> {{ $t("translation.filetoolarge") }}
55+
<span class="field-title">{{ $t('translation.error') }}</span> {{ $t('translation.filetoolarge') }}
5056
</div>
5157
</div>
5258
<a
@@ -55,7 +61,7 @@ const computeFileSize = (size: number) =>
5561
:href="fileObj.isCompressed ? fileData : undefined"
5662
role="button"
5763
download
58-
>{{ $t("translation.download") }}</a
64+
>{{ $t('translation.download') }}</a
5965
>
6066
<button
6167
class="secondary delete-button"

src/components/FileUpload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function addFiles(uploadedFiles: FileList) {
4747
@drop.prevent="dropFile"
4848
@dragover.prevent
4949
>
50-
<span class="drop-title">{{ $t("translation.dropfiles") }}</span>
50+
<span class="drop-title">{{ $t('translation.dropfiles') }}</span>
5151
<input
5252
type="file"
5353
id="fileUpload"

src/components/Nav.vue

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
<template>
2-
<nav>
2+
<nav>
33
<ul>
44
<li>
5-
<a href=".." title="Other pages">← {{ $t("translation.viewother") }}</a>
5+
<a
6+
href=".."
7+
title="Other pages"
8+
>← {{ $t('translation.viewother') }}</a
9+
>
610
</li>
711
</ul>
812
<ul>
913
<li>
1014
<select v-model="selectedLocale">
11-
<option
12-
v-for="locale in $i18n.availableLocales"
13-
:key="`locale-${locale}`"
14-
:value="locale"
15-
>
16-
{{ locale }}
17-
</option>
18-
</select>
15+
<option
16+
v-for="locale in $i18n.availableLocales"
17+
:key="`locale-${locale}`"
18+
:value="locale"
19+
>
20+
{{ locale }}
21+
</option>
22+
</select>
1923
</li>
2024
</ul>
2125
</nav>
2226
</template>
2327

2428
<script setup lang="ts">
25-
import { watch, ref } from "vue";
26-
import { useI18n } from "../hooks/useI18n";
29+
import { watch, ref } from 'vue';
30+
import { useI18n } from '../hooks/useI18n';
2731
2832
const { locale } = useI18n();
2933
@@ -33,6 +37,6 @@ const selectedLocale = ref<Locales>(locale.value);
3337
3438
watch(selectedLocale, (newVal) => {
3539
locale.value = newVal;
36-
localStorage.setItem("lang", newVal);
40+
localStorage.setItem('lang', newVal);
3741
});
3842
</script>

src/components/NavBarThemeSwitch.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import ThemeSwitch from './ThemeSwitch.vue';
55
<template>
66
<nav>
77
<ul>
8-
<li>
9-
</li>
8+
<li></li>
109
</ul>
1110
<ul>
1211
<li>

src/components/ThemeSwitch.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ function switchTheme(theme: string | undefined = undefined) {
1212
</script>
1313

1414
<template>
15-
<div style="text-align: right;">
15+
<div style="text-align: right">
1616
<button
1717
role="button"
1818
class="themeswitcher"
1919
id="themeSwitch"
2020
@click="switchTheme()"
21-
style="width: auto;"
21+
style="width: auto"
2222
>
23-
{{ $t("translation.switchtheme") }}
23+
{{ $t('translation.switchtheme') }}
2424
</button>
2525
</div>
2626
</template>
27-

src/file.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/hooks/useI18n.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ type Leaves<ObjectType> = ObjectType extends Record<string, unknown>
1616
{ [Key in keyof ObjectType]-?: Join<Key, Leaves<ObjectType[Key]>> }[keyof ObjectType]
1717
: '';
1818

19-
export type I18NLeaves = Leaves<typeof messages['Español']>;
19+
export type I18NLeaves = Leaves<(typeof messages)['Español']>;
2020

2121
// This function adds type safety to the i18n t function.
2222
export function useI18n() {
2323
// eslint-disable-next-line @typescript-eslint/unbound-method
2424
const { t, te, d, n, tm, rt, ...globalApi } = i18n.global;
2525

26-
type RemoveFirstFromTuple<T extends unknown[]> = ((...b: T) => void) extends (...b: infer I) => void
27-
? I
28-
: [];
26+
type RemoveFirstFromTuple<T extends unknown[]> = ((...b: T) => void) extends (...b: infer I) => void ? I : [];
2927

3028
const typedT = t as (...args: [I18NLeaves, ...Partial<RemoveFirstFromTuple<Parameters<typeof t>>>]) => string;
3129

src/i18n/en-EN/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import translation from "./translation";
1+
import translation from './translation';
22

33
export default {
4-
translation
5-
}
4+
translation,
5+
};

src/i18n/en-EN/translation.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
export default {
2-
hello: 'Hello',
3-
en: 'English',
4-
es: 'Español',
5-
home: 'Home',
6-
viewother: 'View other pages',
7-
switchtheme: 'Switch Theme',
8-
dropfiles: "Drop files here",
9-
name: "Name:",
10-
originalsize: "Original Size:",
11-
compressedsize: "Compressed Size:",
12-
download: "Download",
13-
error: "Error:",
14-
filetoolarge: "File is too large!",
15-
header: "Image Compressor",
16-
subtitle: "Compresses images to < 10MB",
17-
buttonwiki: "Open NMS Wiki Image Upload",
18-
input: "Input",
19-
allcompressed: "All Compressed!",
20-
compress: "Compress",
21-
filelist: "File List",
22-
downloadzip: "Dowload ZIP",
23-
clearlist: "Clear List"
24-
}
2+
hello: 'Hello',
3+
en: 'English',
4+
es: 'Español',
5+
home: 'Home',
6+
viewother: 'View other pages',
7+
switchtheme: 'Switch Theme',
8+
dropfiles: 'Drop files here',
9+
name: 'Name:',
10+
originalsize: 'Original Size:',
11+
compressedsize: 'Compressed Size:',
12+
download: 'Download',
13+
error: 'Error:',
14+
filetoolarge: 'File is too large!',
15+
header: 'Image Compressor',
16+
subtitle: 'Compresses images to < 10MB',
17+
buttonwiki: 'Open NMS Wiki Image Upload',
18+
input: 'Input',
19+
allcompressed: 'All Compressed!',
20+
compress: 'Compress',
21+
filelist: 'File List',
22+
downloadzip: 'Dowload ZIP',
23+
clearlist: 'Clear List',
24+
};

0 commit comments

Comments
 (0)