ui: redesign image upload section
This commit is contained in:
parent
da40a63737
commit
b1f2d4e22d
|
@ -1,29 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex items-center">
|
<div>
|
||||||
<figure class="image" v-if="imageSrc && !imagePreviewLoadingError">
|
<o-upload
|
||||||
<img :src="imageSrc" @error="showImageLoadingError" />
|
rootClass="!flex"
|
||||||
</figure>
|
v-if="!imageSrc || imagePreviewLoadingError || pictureTooBig"
|
||||||
<figure class="image is-128x128" v-else>
|
@update:modelValue="onFileChanged"
|
||||||
<div
|
:accept="accept"
|
||||||
class="image-placeholder"
|
drag-drop
|
||||||
:class="{ error: imagePreviewLoadingError }"
|
|
||||||
>
|
>
|
||||||
<span class="has-text-centered" v-if="imagePreviewLoadingError">{{
|
<div
|
||||||
$t("Error while loading the preview")
|
class="w-100 rounded text-center p-4 rounded-xl border-dashed border-2 border-gray-600"
|
||||||
}}</span>
|
>
|
||||||
<span class="has-text-centered" v-else>{{
|
<span class="mx-auto flex w-fit">
|
||||||
textFallbackWithDefault
|
<Upload />
|
||||||
}}</span>
|
<span class="capitalize"
|
||||||
</div>
|
>{{ $t("Click to upload") }} {{ textFallbackWithDefault }}</span
|
||||||
</figure>
|
>
|
||||||
|
</span>
|
||||||
<div class="flex flex-col">
|
|
||||||
<p v-if="modelValue" class="inline-flex">
|
|
||||||
<span class="block truncate max-w-[200px]" :title="modelValue.name">{{
|
|
||||||
modelValue.name
|
|
||||||
}}</span>
|
|
||||||
<span>({{ formatBytes(modelValue.size) }})</span>
|
|
||||||
</p>
|
|
||||||
<p v-if="pictureTooBig" class="text-mbz-danger">
|
<p v-if="pictureTooBig" class="text-mbz-danger">
|
||||||
{{
|
{{
|
||||||
$t(
|
$t(
|
||||||
|
@ -32,23 +24,42 @@
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
<o-field class="justify-center" variant="primary">
|
<span
|
||||||
<o-upload @update:modelValue="onFileChanged" :accept="accept" drag-drop>
|
class="has-text-centered text-mbz-danger"
|
||||||
<span>
|
v-if="imagePreviewLoadingError"
|
||||||
<Upload />
|
>{{ $t("Error while loading the preview") }}</span
|
||||||
<span>{{ $t("Click to upload") }}</span>
|
>
|
||||||
</span>
|
</div>
|
||||||
</o-upload>
|
</o-upload>
|
||||||
</o-field>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
imageSrc &&
|
||||||
|
!imagePreviewLoadingError &&
|
||||||
|
!pictureTooBig &&
|
||||||
|
!imagePreviewLoadingError
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<figure
|
||||||
|
class="w-fit relative image mx-auto my-4"
|
||||||
|
v-if="imageSrc && !imagePreviewLoadingError"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="max-h-52 rounded-xl"
|
||||||
|
:src="imageSrc"
|
||||||
|
@error="showImageLoadingError"
|
||||||
|
/>
|
||||||
<o-button
|
<o-button
|
||||||
variant="text"
|
class="!absolute right-1 bottom-1"
|
||||||
|
variant="danger"
|
||||||
v-if="imageSrc"
|
v-if="imageSrc"
|
||||||
@click="removeOrClearPicture"
|
@click="removeOrClearPicture"
|
||||||
@keyup.enter="removeOrClearPicture"
|
@keyup.enter="removeOrClearPicture"
|
||||||
>
|
>
|
||||||
{{ $t("Clear") }}
|
{{ $t("Clear") }}
|
||||||
</o-button>
|
</o-button>
|
||||||
</div>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -56,9 +67,9 @@
|
||||||
@use "@/styles/_mixins" as *;
|
@use "@/styles/_mixins" as *;
|
||||||
figure.image {
|
figure.image {
|
||||||
// @include margin-right(30px);
|
// @include margin-right(30px);
|
||||||
max-height: 200px;
|
//max-height: 200px;
|
||||||
max-width: 200px;
|
//max-width: 200px;
|
||||||
overflow: hidden;
|
//overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-placeholder {
|
.image-placeholder {
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
}}</span>
|
}}</span>
|
||||||
<span v-else>{{ $t("I create an identity") }}</span>
|
<span v-else>{{ $t("I create an identity") }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
|
<o-field :label="t('Avatar')">
|
||||||
<picture-upload
|
<picture-upload
|
||||||
v-model="avatarFile"
|
v-model="avatarFile"
|
||||||
:defaultImage="identity.avatar"
|
:defaultImage="identity.avatar"
|
||||||
:maxSize="avatarMaxSize"
|
:maxSize="avatarMaxSize"
|
||||||
class="picture-upload"
|
class="picture-upload"
|
||||||
/>
|
/>
|
||||||
|
</o-field>
|
||||||
|
|
||||||
<o-field
|
<o-field
|
||||||
horizontal
|
horizontal
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
|
|
||||||
<form ref="form">
|
<form ref="form">
|
||||||
<h2>{{ t("General information") }}</h2>
|
<h2>{{ t("General information") }}</h2>
|
||||||
|
|
||||||
|
<o-field :label="t('Headline picture')">
|
||||||
<picture-upload
|
<picture-upload
|
||||||
v-model:modelValue="pictureFile"
|
v-model:modelValue="pictureFile"
|
||||||
:textFallback="t('Headline picture')"
|
:textFallback="t('Headline picture')"
|
||||||
:defaultImage="event.picture"
|
:defaultImage="event.picture"
|
||||||
/>
|
/>
|
||||||
|
</o-field>
|
||||||
|
|
||||||
<o-field
|
<o-field
|
||||||
:label="t('Title')"
|
:label="t('Title')"
|
||||||
|
|
Loading…
Reference in a new issue