Skip to content

Commit f379194

Browse files
committed
♻️ create seperate FormErrorMessage.vue component
1 parent 5333c35 commit f379194

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed

src/components/FileDropzone/MucFileDropzone.vue

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,25 @@
2222
additionalInformation
2323
}}</span>
2424
</div>
25-
<span
26-
v-if="!validFileSizes && maxFileSizeWarning"
27-
class="m-error-message drop-zone-error-message"
28-
>
29-
<MucIcon
30-
icon="warning--filled"
31-
class="icon"
32-
/>
33-
<span>
34-
{{ maxFileSizeWarning }}
35-
</span>
36-
</span>
37-
<span
38-
v-if="!validTotalFileSizes && maxTotalFileSizeWarning"
39-
class="m-error-message drop-zone-error-message"
40-
>
41-
<MucIcon icon="warning--filled" />
42-
<span>
43-
{{ maxTotalFileSizeWarning }}
44-
</span>
45-
</span>
46-
<span
47-
v-if="!validFilesAmount"
48-
class="m-error-message drop-zone-error-message"
49-
>
50-
<MucIcon icon="warning--filled" />
51-
<span>
52-
{{ invalidAmountWarning }}
53-
</span>
54-
</span>
25+
26+
<form-error-message v-if="!validFileSizes && maxFileSizeWarning">
27+
{{ maxFileSizeWarning }}
28+
</form-error-message>
29+
30+
<form-error-message v-if="!validTotalFileSizes && maxTotalFileSizeWarning">
31+
{{ maxTotalFileSizeWarning }}
32+
</form-error-message>
33+
34+
<form-error-message v-if="!validFilesAmount">
35+
{{ invalidAmountWarning }}
36+
</form-error-message>
5537
</template>
5638

5739
<script setup lang="ts">
5840
import { onMounted, onUpdated, ref, watch } from "vue";
5941
6042
import { MucButton } from "../Button";
61-
import { MucIcon } from "../Icon";
43+
import FormErrorMessage from "../Form/FormErrorMessage.vue";
6244
import IconFileUpload from "./IconFileUpload.vue";
6345
6446
const {
@@ -297,19 +279,6 @@ const _clearWarnings = () => {
297279
cursor: pointer;
298280
}
299281
300-
.drop-zone-error-message {
301-
display: flex;
302-
align-items: flex-start;
303-
}
304-
305-
.drop-zone-error-message .icon {
306-
margin-top: 0;
307-
}
308-
309-
.drop-zone-error-message span {
310-
margin-left: 4px;
311-
}
312-
313282
.drop-zone-additional-information {
314283
font-size: 14px;
315284
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script setup lang="ts">
2+
3+
import {MucIcon} from "../Icon";
4+
</script>
5+
6+
<template>
7+
<span
8+
class="m-error-message form-error-message"
9+
>
10+
<MucIcon icon="warning--filled" />
11+
<span>
12+
<slot></slot>
13+
</span>
14+
</span>
15+
</template>
16+
17+
<style scoped>
18+
.form-error-message {
19+
display: flex;
20+
align-items: flex-start;
21+
}
22+
23+
.form-error-message .icon {
24+
margin-top: 0;
25+
}
26+
27+
.form-error-message span {
28+
margin-left: 4px;
29+
}
30+
</style>

0 commit comments

Comments
 (0)