Skip to content

Commit 5836e12

Browse files
committed
styling
1 parent f134c15 commit 5836e12

File tree

5 files changed

+61
-54
lines changed

5 files changed

+61
-54
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"jszip": "^3.10.1",
1717
"pinia": "^2.1.6",
1818
"sass": "^1.64.1",
19-
"simple-image-compressor": "^1.0.3",
19+
"simple-image-compressor": "^1.2.0",
2020
"vue": "^3.4.19",
2121
"vue-i18n": "^9.8.0"
2222
},

src/App.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ async function editFileObj(fileObj: FileObj) {
3535
async function compressFiles() {
3636
isCompressing.value = true;
3737
38-
const promises = [];
39-
4038
const uncompressedFiles = files.value.filter((fileObj: FileObj) => !fileObj.isCompressed);
4139
42-
for (const fileObj of uncompressedFiles) {
43-
promises.push(editFileObj(fileObj));
44-
}
40+
const promises = uncompressedFiles.map(editFileObj);
4541
4642
await Promise.all(promises);
4743
isCompressing.value = false;

src/components/FileItem.vue

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,53 @@ const computeFileSize = (size: number) =>
2929

3030
<template>
3131
<div class="file-item">
32-
<a
33-
:href="fileData"
34-
rel="noopener noreferrer"
35-
target="_blank"
36-
>
37-
<img
38-
:src="fileData"
39-
alt="Image preview"
40-
class="preview"
41-
width="200"
42-
/>
43-
</a>
44-
<div>
45-
<div>
46-
<span class="field-title">{{ t('translation.name') }}</span> {{ fileObj.file.name }}
47-
</div>
32+
<div class="item-set">
33+
<a
34+
:href="fileData"
35+
rel="noopener noreferrer"
36+
target="_blank"
37+
>
38+
<img
39+
:src="fileData"
40+
alt="Image preview"
41+
class="preview"
42+
width="200"
43+
/>
44+
</a>
4845
<div>
49-
<span class="field-title">{{ t('translation.originalsize') }}</span> {{ computeFileSize(orgSize) }}MB
46+
<div>
47+
<span class="field-title">{{ t('translation.name') }}</span> {{ fileObj.file.name }}
48+
</div>
49+
<div>
50+
<span class="field-title">{{ t('translation.originalsize') }}</span> {{ computeFileSize(orgSize) }}MB
51+
</div>
52+
<div v-if="compSize">
53+
<span class="field-title">{{ t('translation.compressedsize') }}</span> {{ computeFileSize(compSize) }}MB
54+
</div>
55+
<div
56+
v-if="fileObj.isTooLarge"
57+
class="error"
58+
>
59+
<span class="field-title">{{ t('translation.error') }}</span> {{ t('translation.filetoolarge') }}
60+
</div>
5061
</div>
51-
<div v-if="compSize">
52-
<span class="field-title">{{ t('translation.compressedsize') }}</span> {{ computeFileSize(compSize) }}MB
53-
</div>
54-
<div
55-
v-if="fileObj.isTooLarge"
56-
class="error"
62+
</div>
63+
<div class="item-set">
64+
<a
65+
:class="{ secondary: !fileObj.isCompressed }"
66+
:disabled="!fileObj.isCompressed || undefined"
67+
:href="fileObj.isCompressed ? fileData : undefined"
68+
role="button"
69+
download
70+
>{{ t('translation.download') }}</a
5771
>
58-
<span class="field-title">{{ t('translation.error') }}</span> {{ t('translation.filetoolarge') }}
59-
</div>
72+
<button
73+
class="secondary delete-button"
74+
@click="$emit('remove')"
75+
>
76+
77+
</button>
6078
</div>
61-
<a
62-
:class="{ secondary: !fileObj.isCompressed }"
63-
:disabled="!fileObj.isCompressed || undefined"
64-
:href="fileObj.isCompressed ? fileData : undefined"
65-
role="button"
66-
download
67-
>{{ t('translation.download') }}</a
68-
>
69-
<button
70-
class="secondary delete-button"
71-
@click="$emit('remove')"
72-
>
73-
74-
</button>
7579
</div>
7680
</template>
7781

@@ -85,9 +89,15 @@ const computeFileSize = (size: number) =>
8589
padding-inline: 1rem;
8690
align-items: center;
8791
width: 100%;
88-
justify-content: center;
92+
justify-content: space-between;
8993
flex-wrap: wrap;
9094
95+
.item-set {
96+
display: flex;
97+
gap: 1rem;
98+
flex-wrap: wrap;
99+
}
100+
91101
.field-title {
92102
font-weight: bold;
93103
}

src/hooks/useI18n.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ type Join<FirstType, SecondType> = FirstType extends string | number
1111
/**
1212
* Helper type that transforms an object tree into a union type of all possibles leaves.
1313
*/
14-
type Leaves<ObjectType> = ObjectType extends Record<string, unknown>
15-
? // eslint-disable-next-line @typescript-eslint/no-unused-vars
16-
{ [Key in keyof ObjectType]-?: Join<Key, Leaves<ObjectType[Key]>> }[keyof ObjectType]
17-
: '';
14+
type Leaves<ObjectType> =
15+
ObjectType extends Record<string, unknown>
16+
? // eslint-disable-next-line @typescript-eslint/no-unused-vars
17+
{ [Key in keyof ObjectType]-?: Join<Key, Leaves<ObjectType[Key]>> }[keyof ObjectType]
18+
: '';
1819

1920
export type I18NLeaves = Leaves<(typeof messages)['Español']>;
2021

0 commit comments

Comments
 (0)