pleroma-fe/src/components/image_cropper/image_cropper.vue

102 lines
2.6 KiB
Vue
Raw Normal View History

2019-02-07 03:05:59 -05:00
<template>
<div class="image-cropper">
2019-02-08 21:59:33 -05:00
<div v-if="dataUrl">
2025-03-30 17:06:19 +03:00
<cropper-canvas
background
class="image-cropper-canvas"
ref="cropperCanvas"
height="25em"
>
<cropper-image
2019-07-05 10:17:44 +03:00
:src="dataUrl"
2025-03-30 17:06:19 +03:00
alt="Picture"
ref="cropperImage"
class="image-cropper-image"
translatable
scalable
/>
<cropper-shade hidden />
<cropper-handle action="select" plain />
<cropper-selection
ref="cropperSelection"
initial-coverage="1"
aspect-ratio="1"
movable
resizable
@change="onCropperSelectionChange"
2019-07-05 10:17:44 +03:00
>
2025-03-30 17:06:19 +03:00
<cropper-grid role="grid" covered></cropper-grid>
<cropper-crosshair centered></cropper-crosshair>
<cropper-handle action="move" theme-color="rgba(255, 255, 255, 0.35)"></cropper-handle>
<cropper-handle action="n-resize"></cropper-handle>
<cropper-handle action="e-resize"></cropper-handle>
<cropper-handle action="s-resize"></cropper-handle>
<cropper-handle action="w-resize"></cropper-handle>
<cropper-handle action="ne-resize"></cropper-handle>
<cropper-handle action="nw-resize"></cropper-handle>
<cropper-handle action="se-resize"></cropper-handle>
<cropper-handle action="sw-resize"></cropper-handle>
</cropper-selection>
</cropper-canvas>
2019-02-08 21:59:33 -05:00
<div class="image-cropper-buttons-wrapper">
2019-07-05 10:17:44 +03:00
<button
class="button-default btn"
2019-07-05 10:17:44 +03:00
type="button"
:disabled="submitting"
@click="submit()"
v-text="saveText"
/>
<button
class="button-default btn"
2019-07-05 10:17:44 +03:00
type="button"
:disabled="submitting"
@click="destroy"
v-text="cancelText"
/>
<button
class="button-default btn"
2019-07-05 10:17:44 +03:00
type="button"
:disabled="submitting"
@click="submit(false)"
v-text="saveWithoutCroppingText"
/>
2020-10-21 00:01:28 +03:00
<FAIcon
2019-07-05 10:17:44 +03:00
v-if="submitting"
2020-10-21 00:01:28 +03:00
spin
icon="circle-notch"
2019-07-05 10:17:44 +03:00
/>
2019-02-07 03:05:59 -05:00
</div>
2019-02-08 21:59:33 -05:00
</div>
2019-07-05 10:17:44 +03:00
<input
ref="input"
type="file"
2024-02-07 15:53:49 +02:00
class="input image-cropper-img-input"
2019-07-05 10:17:44 +03:00
:accept="mimes"
>
2019-02-07 03:05:59 -05:00
</div>
</template>
<script src="./image_cropper.js"></script>
<style lang="scss">
.image-cropper {
&-img-input {
display: none;
}
2025-03-30 17:06:19 +03:00
&-canvas {
height: 25em;
width: 25em;
2019-02-07 03:05:59 -05:00
}
2019-02-08 21:59:33 -05:00
&-buttons-wrapper {
2025-03-30 17:06:19 +03:00
display: grid;
grid-gap: 0.5em;
grid-template-columns: 1fr 1fr 1fr;
2019-03-18 18:19:42 -07:00
button {
2025-03-30 17:06:19 +03:00
margin-top: 1em;
2019-03-18 18:19:42 -07:00
}
2019-02-07 03:05:59 -05:00
}
}
</style>