Skip to content

Commit 756212f

Browse files
authored
Merge pull request #13 from NMSCD/dev
use custom file compressor package
2 parents b1733d5 + 3ea8db3 commit 756212f

File tree

16 files changed

+509
-444
lines changed

16 files changed

+509
-444
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ charset = utf-8
55
indent_style = space
66
indent_size = 2
77
end_of_line = lf
8-
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: 'npm' # See documentation for possible values
9+
directory: '/' # Location of package manifests
10+
target-branch: 'dev'
11+
schedule:
12+
interval: 'weekly'
13+
14+
- package-ecosystem: 'github-actions'
15+
directory: '/'
16+
target-branch: 'dev'
17+
schedule:
18+
interval: 'weekly'

package-lock.json

Lines changed: 450 additions & 404 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
"format": "prettier --write src/"
1313
},
1414
"dependencies": {
15-
"@picocss/pico": "^1.5.10",
16-
"image-conversion": "^2.1.1",
15+
"@picocss/pico": "^2.0.0",
1716
"jszip": "^3.10.1",
1817
"pinia": "^2.1.6",
1918
"sass": "^1.64.1",
19+
"simple-image-compressor": "^1.0.1",
2020
"vue": "^3.3.4",
2121
"vue-i18n": "^9.8.0"
2222
},
2323
"devDependencies": {
2424
"@tsconfig/node20": "^20.1.2",
2525
"@types/node": "^20.10.5",
26-
"@vitejs/plugin-vue": "^4.2.3",
26+
"@vitejs/plugin-vue": "^5.0.3",
2727
"@vue/tsconfig": "^0.5.1",
2828
"npm-run-all": "^4.1.5",
2929
"prettier": "^3.0.0",

src/components/FileItem.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { computed, ref, watchEffect } from 'vue';
3-
import type { FileObj } from '../types/file';
4-
import { useI18n } from '../hooks/useI18n';
3+
import type { FileObj } from '@/types/file';
4+
import { useI18n } from '@/hooks/useI18n';
55
66
const { t } = useI18n();
77
@@ -59,8 +59,8 @@ const computeFileSize = (size: number) =>
5959
</div>
6060
</div>
6161
<a
62-
:aria-disabled="!fileObj.isCompressed"
6362
:class="{ secondary: !fileObj.isCompressed }"
63+
:disabled="!fileObj.isCompressed || undefined"
6464
:href="fileObj.isCompressed ? fileData : undefined"
6565
role="button"
6666
download
@@ -80,12 +80,13 @@ const computeFileSize = (size: number) =>
8080
display: flex;
8181
gap: 2rem;
8282
border: 1px solid;
83-
border-radius: var(--border-radius);
83+
border-radius: var(--pico-border-radius);
8484
padding: 0.25rem;
8585
padding-inline: 1rem;
8686
align-items: center;
8787
width: 100%;
88-
justify-content: space-between;
88+
justify-content: center;
89+
flex-wrap: wrap;
8990
9091
.field-title {
9192
font-weight: bold;

src/components/FileUpload.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { ref } from 'vue';
3-
import { useFileDataStore } from '../stores/fileData';
3+
import { useFileDataStore } from '@/stores/fileData';
44
import { storeToRefs } from 'pinia';
5-
import type { FileObj } from '../types/file';
6-
import { useI18n } from '../hooks/useI18n';
5+
import type { FileObj } from '@/types/file';
6+
import { useI18n } from '@/hooks/useI18n';
77
88
const dragActive = ref(false);
99
@@ -69,7 +69,7 @@ function addFiles(uploadedFiles: FileList) {
6969
justify-content: center;
7070
align-items: center;
7171
height: 200px;
72-
border-radius: var(--border-radius);
72+
border-radius: var(--pico-border-radius);
7373
border: 2px dashed;
7474
cursor: pointer;
7575
transition:
@@ -90,7 +90,7 @@ function addFiles(uploadedFiles: FileList) {
9090
width: max-content;
9191
height: auto;
9292
padding: 5px;
93-
border-radius: var(--border-radius);
93+
border-radius: var(--pico-border-radius);
9494
border: 1px solid;
9595
9696
&::file-selector-button {

src/components/NavBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { watch, ref } from 'vue';
3-
import { useI18n } from '../hooks/useI18n';
3+
import { useI18n } from '@/hooks/useI18n';
44
import ThemeSwitch from './ThemeSwitch.vue';
55
66
const { t, locale } = useI18n();

src/components/ThemeSwitch.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { useI18n } from '../hooks/useI18n';
2+
import { useI18n } from '@/hooks/useI18n';
33
44
const { t } = useI18n();
55
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { compress, EImageType } from 'image-conversion';
1+
import { compressImage, imageTypes } from 'simple-image-compressor';
2+
import { maxSize } from '@/variables/constants';
23

34
export async function useImageCompression(file: File, quality: number = 1): Promise<File> {
4-
const maxSize = 10000000;
55
if (file.size < maxSize) return file; // if below 10 MB, don't do anything
6-
const res = await compress(file, {
6+
const res = await compressImage(file, {
77
quality,
8-
type: EImageType.JPEG,
9-
scale: 1,
8+
type: imageTypes.JPEG,
109
});
1110
const lowerQuality = quality - 0.01; // NoSonar reduce quality by 1%;
1211
if (res.size > maxSize) return await useImageCompression(file, lowerQuality); // compress original file with lower quality setting to avoid double compression
1312
const fileName = file.name.split('.').slice(0, -1).join('.');
1413
const newFileName = fileName + '-min.jpg';
15-
return new File([res], newFileName, { type: EImageType.JPEG });
14+
return new File([res], newFileName, { type: imageTypes.JPEG });
1615
}

src/composables/useZipCompression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import JSZip from 'jszip';
22
import { storeToRefs } from 'pinia';
3-
import { useFileDataStore } from '../stores/fileData';
3+
import { useFileDataStore } from '@/stores/fileData';
44

55
export async function useZipCompression(): Promise<string> {
66
const zip = new JSZip();

0 commit comments

Comments
 (0)